Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
10 views5 pages

Database Management

The document provides comprehensive guidelines on managing redo log files and control files in an Oracle database, including commands for viewing, adding, dropping, and clearing log files. It also covers how to multiplex and create control files, emphasizing the importance of backing up control files before making modifications. Additionally, it includes SQL commands for identifying log files, data files, and control files within the database.

Uploaded by

Ugoh Jessie
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views5 pages

Database Management

The document provides comprehensive guidelines on managing redo log files and control files in an Oracle database, including commands for viewing, adding, dropping, and clearing log files. It also covers how to multiplex and create control files, emphasizing the importance of backing up control files before making modifications. Additionally, it includes SQL commands for identifying log files, data files, and control files within the database.

Uploaded by

Ugoh Jessie
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5

==========================

REDO LOG FILES MANAGEMENT


=========================

To desc log views, use v$logs, v$logfile;

The log writer writes in parallel to the members of a log group and once these
members are filled(reaches the specified size which has to be
consistent), it begins writing tothe second group and this process is called a log
switch.

SQL> select GROUP#,MEMBER from v$logfile;


GROUP# MEMBER
---------- --------------------------------------------------
1 /u01/oradata/test/datafile/redo01_01.log
1 /u01/oradata/test/datafile/redo01_02.log
2 /u01/oradata/test/datafile/redo02_01.log
2 /u01/oradata/test/datafile/redo02_02.log
3 /u01/oradata/test/datafile/redo03_01.log
3 /u01/oradata/test/datafile/redo03_02.log

Ideally, the replicates of each group should be on a different mount point for
disaster recovery.

SQL> archive log list


Database log mode No Archive Mode
Automatic archival Disabled
Archive destination /u01/app/ARCHIVE
Oldest online log sequence 18
Current log sequence 20

To enable archive log mode


==========================
SQL> shu immediate;

SQL> startup mount

SQL> alter database archivelog;

Database altered.

SQL> archive log list;


Database log mode Archive Mode
Automatic archival Enabled
Archive destination /u01/app/ARCHIVE
Oldest online log sequence 21
Next log sequence to archive 23
Current log sequence 23

SQL> alter database open;

SQL> ALTER DATABASE ADD LOGFILE GROUP 4('/u01/oradata/test/datafile/redo04_01.log',


'/u01/oradata/test/datafile/redo04_02.log') SIZE 300M

SQL> ALTER DATABASE ADD LOGFILE GROUP 5('/u01/oradata/test/datafile/redo05_01.log',


'/u01/oradata/test/datafile/redo05_02.log') SIZE 300M

SQL> select GROUP#, STATUS, MEMBER,IS_RECOVERY_DEST_FILE from v$logfile;


GROUP# STATUS MEMBER IS_
---------- ------- -------------------------------------------------- ---
1 /u01/oradata/test/datafile/redo01_01.log NO
1 /u01/oradata/test/datafile/redo01_02.log NO
2 /u01/oradata/test/datafile/redo02_01.log NO
2 /u01/oradata/test/datafile/redo02_02.log NO
3 /u01/oradata/test/datafile/redo03_01.log NO
3 /u01/oradata/test/datafile/redo03_02.log NO
4 /u01/oradata/test/datafile/redo04_01.log NO
4 /u01/oradata/test/datafile/redo04_02.log NO
5 /u01/oradata/test/datafile/redo05_01.log NO
5 /u01/oradata/test/datafile/redo05_02.log NO

SQL> ALTER DATABASE DROP LOGFILE GROUP 5;

SQL> select GROUP#,STATUS,MEMBER,IS_RECOVERY_DEST_FILE from v$logfile;

GROUP# STATUS MEMBER IS_


---------- ------- -------------------------------------------------- ---
1 /u01/oradata/test/datafile/redo01_01.log NO
1 /u01/oradata/test/datafile/redo01_02.log NO
2 /u01/oradata/test/datafile/redo02_01.log NO
2 /u01/oradata/test/datafile/redo02_02.log NO
3 /u01/oradata/test/datafile/redo03_01.log NO
3 /u01/oradata/test/datafile/redo03_02.log NO
4 /u01/oradata/test/datafile/redo04_01.log NO
4 /u01/oradata/test/datafile/redo04_02.log NO

P.S A log file can only be dropped when inactive, it can't be drop when current or
active.

To add/ remove members from a group;


====================================

SQL> ALTER DATABASE ADD LOGFILE MEMBER '/u01/oradata/test/datafile/redo04_03.log'


TO ('/u01/oradata/test/datafile/redo04_01.log', '/u01/oradata/test/
datafile/redo04_02.log')

SQL> ALTER DATABASE ADD LOGFILE MEMBER '/u01/oradata/test/datafile/redo04_03.log'


[reuse] to GROUP 4;

SQL> select MEMBERS,GROUP#,BYTES/1024/1024,MEMBERS,STATUS FROM v$log;

MEMBERS GROUP# BYTES/1024/1024 MEMBERS STATUS


---------- ---------- --------------- ---------- ----------------
2 1 100 2 INACTIVE
2 2 100 2 INACTIVE
2 3 100 2 CURRENT
3 4 300 3 UNUSED

SQL> ALTER DATABASE DROP LOGFILE MEMBER '/u01/oradata/test/datafile/redo04_03.log'

P.S: Make sure a redo log group is archived (if archiving is enabled) before
dropping it. To see whether this has happened, use the V$LOG view.
P.S.S: A redo log file becomes INVALID if the database cannot access it. It becomes
STALE if the database suspects that it is not complete or correct.
A stale log file becomes valid again the next time its group is made the active
group.
To rename members of a group;
===============================

This can only be done in mount stage.

SQL> ALTER DATABASE RENAME FILE '/u01/oradata/test/datafile/redo04_01.log',


'/u01/oradata/test/datafile/redo04_02.log'
TO '/u02/oradata/test/datafile/redo04_01.log',
'/u02/oradata/test/datafile/redo04_02.log';

To relocate members of a group;


===============================
You can use operating system commands to relocate redo logs, then use the ALTER
DATABASE statement to make their new names (locations) known to the
database.

P.S: As a precaution, after renaming or relocating a set of redo log files,


immediately back up the database control file.

Clearing a redolog file


=======================
A redo log file might become corrupted while the database is open, and ultimately
stop database activity because archiving cannot continue.
Run the ALTER DATABASE CLEAR LOGFILE SQL statement as shown below:

ALTER DATABASE CLEAR LOGFILE GROUP 3;

If the corrupt redo log file has not been archived, use the statement below.

ALTER DATABASE CLEAR UNARCHIVED LOGFILE GROUP 3;

This statement clears the corrupted redo logs and avoids archiving them. The
cleared redo logs are available for use even though they were not
archived.

=========================
CONTROL FILE MANAGEMENT
=========================

To view control files location


==============================

SQL> sho parameter control_files;

NAME TYPE VALUE


--------------- ----------- ------------------------------
control_files string
/u01/app/oracle/oradata/test/controlfile/control_01.ctl,/u01/app/FRA/test/
controlfile/control_02.ctl

To multiplex control files


==========================
This should be done in no mount stage.

SQL> ALTER SYSTEM SET


CONTROL_FILES='/u01/app/oracle/oradata/test/controlfile/control_01.ctl',
'/u01/app/FRA/test/controlfile/control_02.ctl',
'/u01/app/FRA/test/controlfile/control_03.ctl','/home/oracle/control_04.ctl'
SCOPE=SPFILE;

[oracle@testenv controlfile]$ cp
/u01/app/oracle/oradata/test/controlfile/control_01.ctl /home/oracle/control_04.ctl

SQL> startup;

SQL> sho parameter control_files;

NAME TYPE VALUE


------------------------------------ ----------- ------------------------------
control_files string
/u01/app/oracle/oradata/test/controlfile/control_01.ctl,
/u01/app/FRA/test/controlfile/con
trol_02.ctl,
/u01/app/oracle/oradata/test/controlfile/control_03.ctl,/home/oracle/control_04.ctl

To create a control_file
========================

CREATE CONTROLFILE
SET DATABASE test
LOGFILE GROUP 1 ('/u01/oradata/test/datafile/redo01_01.log',
'/u01/oradata/test/datafile/redo01_02.log'),
GROUP 2 ('/u01/oradata/test/datafile/redo02_01.log',
'/u01/oradata/test/datafile/redo02_01.log'),
GROUP 3 ('/u01/oradata/test/datafile/redo03_01.log',
'/u01/oradata/test/datafile/redo03_01.log')
RESETLOGS
DATAFILE '/u01/oradata/test/datafiles/sysaux01.dbf'
'/u01/oradata/test/datafiles/system01.dbf'
'/u01/oradata/test/datafiles/temp01.dbf'
'/u01/oradata/test/datafiles/undotbs01.dbf'
'/u01/oradata/test/datafiles/users01.dbf'
MAXLOGFILES 50
MAXLOGMEMBERS 3
MAXLOGHISTORY 400
MAXDATAFILES 200
MAXINSTANCES 6
ARCHIVELOG;

P.S: Before modifying or creating new control files, always take a backup of the
control file.

ALTER DATABASE BACKUP CONTROL FILE TO /path/to/backup/location;

OR

ALTER DATABASE BACKUP CONTROL FILE TO trace as /path/to/backup/location/bkp.txt;

P.S.S: Control files can also be restored using rman

[oracle@testenv ~]$ rman target /

Recovery Manager: Release 19.0.0.0.0 - Production on Sat Mar 23 11:39:22 2024


Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.
connected to target database: TEST (DBID=2461684718)

RMAN> restore controlfile from /path/to/backup/loc

Alter database open resetlogs

Commands to id redologs, datafiles and control files


====================================================

SQL> SELECT MEMBER FROM V$LOGFILE;


SQL> SELECT NAME FROM V$DATAFILE;
SQL> SELECT VALUE FROM V$PARAMETER WHERE NAME = 'control_files';

You might also like