Académique Documents
Professionnel Documents
Culture Documents
FILE_NAME
TABLESPACE_NAME
/u01/crms/crms02.dbf
CRMS
/u01/crms/crms01.dbf
CRMS
870
SYSTEM
***
/u02/app/oracle/oradata/crms/system01.dbf
600
SYSAUX
***
/u02/app/oracle/oradata/crms/sysaux01.dbf
1730
UNDOTBS1
***
/u02/app/oracle/oradata/crms/undotbs01.dbf
487
USERS
***
/u02/app/oracle/oradata/crms/users01.dbf
20
CRMS
***
/u01/crms/crms02.dbf
50
CRMS
***
/u01/crms/crms01.dbf
20
HRMS
***
/u01/app/oracle/oradata/crms/hrms02.dbf
50
HRMS
***
/u02/app/oracle/oradata/crms/hrms01.dbf
50
TBS1
***
/u02/app/oracle/oradata/crms/tbs01.dbf
10
500
TBS2
***
/u02/app/oracle/oradata/crms/tbs02.dbf
11
500
TBS3
***
/u02/app/oracle/oradata/crms/tbs03.dbf
20
TEMP
32767
/u02/app/oracle/oradata/crms/temp01.dbf
file
name=/u02/app/oracle/oradata/crms/crms01.dbf
tag=TAG20150520T150020
RECID=243
STAMP=880210820
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 20-MAY-15
file
name=/u02/app/oracle/oradata/crms/crms02.dbf
tag=TAG20150520T150025
STAMP=880210826
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 20-MAY-15
USE RMAN SWITCH TO THE NEWLY CREATED DATAFILES
CRMS
RECID=244
FILE_ID
TABLESPACE_NAME
HRMS
/u01/CRMS/hrms01.dbf
HRMS
50
HRMS
***
/u01/CRMS/hrms01.dbf
file
name=/u02/app/oracle/oradata/crms/hrms01.dbf
tag=TAG20150520T163717
RECID=258
STAMP=880216638
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 20-MAY-15
RMAN> switch datafile 8 to copy;
datafile 8 switched to datafile copy "/u02/app/oracle/oradata/crms/hrms01.dbf"
FILE_ID
TABLESPACE_NAME
HRMS
/u02/app/oracle/oradata/crms/hrms01.dbf
HRMS
FILE_NAME
TABLESPACE_NAME
/u01/crms/datafiles/users01.dbf
USERS
..
...
MAKE THE FILE TO OFFLINE
$ cd /u01/crms/datafiles
$ mv users01.dbf
/u02/app/oracle/oradata/crms/users01.dbf
FILE_NAME
TABLESPACE_NAME
/u01/crms/datafiles/tbs01.dbf
TBS1
/u02/app/oracle/oradata/crms/tbs01.dbf
TYPE
VALUE
string
/u02/app/oracle/product/11.2.0
/dbhome_1/dbs/spfilecrms.ora
TYPE
VALUE
integer
control_files
string
/u02/app/oracle/oradata/crms/c
ontrol01.ctl, /u02/app/oracle/
flash_recovery_area/crms/control02.ctl
As you see currently we have only two control files. In order to add a control we need to update
the CONTROL_FILES parameter with the new location using the ALTER SYSTEM SET CONTROL_FILES command.
SYS> alter system set control_files='/u02/app/oracle/oradata/crms/ctrl/control01.ctl',
'/u01/app/oracle/flash_recovery_area/mltplx/crms/ctrl/control02.ctl',
'/u03/app/oracle/flash_recovery_area/mltplx/crms/ctrl/control03.ctl' scope=spfile;
System altered.
Next we have to shutdown the database and copy one of the existing control files to the newly
added location as per above alter system command.
SHUTDOWN YOUR DATABASE
$ cd /u02/app/oracle/oradata/crms/
$ cp control01.ctl /u02/app/oracle/oradata/crms/ctrl/control01.ctl
$ cd /u02/app/oracle/flash_recovery_area/crms/
$ cp control02.ctl /u01/app/oracle/flash_recovery_area/mltplx/ctrl/control02.ctl
$ cp control02.ctl /u03/app/oracle/flash_recovery_area/mltplx/ctrl/control03.ctl
BRINGUP THE DATABASE
SYS> startup;
ORACLE instance started.
Total System Global Area 1255473152 bytes
Fixed Size
1336232 bytes
Variable Size
989858904 bytes
Database Buffers
251658240 bytes
Redo Buffers
12619776 bytes
Database mounted.
Database opened.
SYS> select name from v$controlfile;
NAME
-------------------------------------------------------------------------------/u02/app/oracle/oradata/crms/ctrl/control01.ctl
/u01/app/oracle/flash_recovery_area/mltplx/crms/ctrl/control02.ctl
/u03/app/oracle/flash_recovery_area/mltplx/crms/ctrl/control03.ctl
Multiplexing the control files is a simple process that provides great benefits in the case of
control file corruption and loss.
MULTIPLEXING CONTROL FILES USING PFILE
QUERY TO FIND INITIALIZATION PARAMETER FILE
TYPE
VALUE
string
TYPE
VALUE
string
/u01/app/oracle/oradata/devdb/control01.ctl
This database is using single control file. Running database with single control file is not a
good choice. So I am going to add two control files. Having multiple control files reduces the
risk of control file loss due to corruption or removal.
$ cd /u01/app/oracle/oradata/devdb
$ cp control01.ctl /u01/app/oracle/oradata/devdb/ctrl/control01.ctl
$ cp control01.ctl /u02/app/oracle/flash_recovery_area/mltplx/devdb/ctrl/control02.ctl
$ cp control01.ctl /u03/app/oracle/flash_recovery_area/mltplx/devdb/ctrl/control03.ctl
MOUNT THE DATABASE USING PFILE
SQL> startup
ORACLE instance started.
Total System Global Area
Fixed Size
901775360 bytes
1276812 bytes
Variable Size
226493556 bytes
Database Buffers
671088640 bytes
Redo Buffers
2916352 bytes
Database mounted.
CREATE THE NEW SPFILE
TYPE
VALUE
string
/u01/app/oracle/product/10.2.0/db_1/dbs/spfiledevdb.ora
This command is to create a duplicate copy of the existing control file in a specified location.
SQL> alter database backup controlfile to '/home/oracle/ctrl.sql';
BACKUP CONTROL FILE IN READABLE FORMAT
Following command produces the SQL script that we can use to recreate the database controlfile in
case all multiplexed binary versions of the controlfiles are lost.
SQL> alter database backup controlfile to trace;
SQL> alter database backup controlfile to trace as '/home/oracle/ctrl.trc';
If you do not mention any location, trace file will be located in UDUMP --> user_dump_dest. To
find user_dump_dest location we can use following query in 10g.
SQL> show parameter user_dump_dest;
In 11g, a new parameter called "diagnostic_dest" determines where files will are created. This
diagnostic_dest replaces background_dump_dest, user_dump_dest, core_dump_dest.
SQL> show parameter diag;
In certain circumstances, we have to recreate our database controlfile. Lets see.
All copies of control files are LOST or CORRUPTED.
If we want to change MAX parameter of the database that was set when the database was created.
Hard limit parameters are MAXDATAFILES , MAXLOGFILES, MAXLOGHISTORY , etc..
If we move our database to another server which is running the same Operating System but files
are present in different location.
Archive Mode
Automatic archival
Enabled
Archive destination
USE_DB_RECOVERY_FILE_DEST
MEMBER
STATUS
/u01/app/oracle/oradata/devdb/redo03.log
ACTIVE
/u01/app/oracle/oradata/devdb/redo02.log
CURRENT
/u01/app/oracle/oradata/devdb/redo01.log
ACTIVE
ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '/u01/app/oracle/oradata/devdb/redo01.log'
SIZE 50M,
GROUP 2 '/u01/app/oracle/oradata/devdb/redo02.log'
SIZE 50M,
GROUP 3 '/u01/app/oracle/oradata/devdb/redo03.log'
SIZE 50M
DATAFILE
'/u01/app/oracle/oradata/devdb/system01.dbf',
'/u01/app/oracle/oradata/devdb/undotbs01.dbf',
'/u01/app/oracle/oradata/devdb/sysaux01.dbf',
'/u01/app/oracle/oradata/devdb/users01.dbf',
'/u01/app/oracle/oradata/devdb/example01.dbf'
CHARACTER SET WE8ISO8859P1
;
RENAMED CONTROL FILE NAMES AT OS LEVEL
$ cd /u01/app/oracle/oradata/devdb/ctrl
$ mv control01.ctl control01.ctl.bkp
$ cd /u02/app/oracle/fash_recovery_area/mltplx/devdb/ctrl
$ mv control02.ctl control02.ctl.bkp
$ cd /u03/app/oracle/fash_recovery_area/mltplx/devdb/ctrl
$ mv control03.ctl control03.ctl.bkp
I have renamed all control files name with .bkp extension.
operating system level such as (removing database file(s), renaming database files) database
cannot understand.
Now we dont have any control files. Lets us connect to the database.
SQL> disc
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> conn / as sysdba
Connected.
SQL> archive log list;
ORA-00210: cannot open the specified control file
ORA-00202: control file: '/u01/app/oracle/oradata/devdb/ctrl/control01.ctl'
ORA-27041: unable to open file
Linux Error: 2: No such file or directory
Additional information: 3
SHUT THE DATABASE & STARTUP
901775360 bytes
1276812 bytes
Variable Size
226493556 bytes
Database Buffers
671088640 bytes
Redo Buffers
2916352 bytes
ORA-00205: error in identifying control file, check alert log for more info
Now we have the only one option need to recreate control files from the ctrl.sql file. Lets try.
SQL> select status from v$instance;
STATUS
-------STARTED
SQL> @/home/oracle/ctrl.sql;
Control file created.
SQL> select status from v$instance;
STATUS
-----------MOUNTED
SQL> select open_resetlogs from v$database;
OPEN_RESETL
----------REQUIRED
MEMBER
STATUS
/u01/app/oracle/oradata/devdb/redo01.log
ACTIVE
/u01/app/oracle/oradata/devdb/redo02.log
ACTIVE
/u01/app/oracle/oradata/devdb/redo03.log
CURRENT
Archive Mode
Automatic archival
Enabled
Archive destination
USE_DB_RECOVERY_FILE_DEST
RESETLOGS
SQL> alter database open resetlogs;
This statement determines the database resets the current redolog sequence number to 1.
Whenever you perform incomplete media recovery (cant use current redolog) or media recovery using
a backup controlfile, above SQL statement is really required. Online redologs sequence will be 1.
OPEN RESETLOGS
operation creates a new incarnation because the database requires a new incarnation
to avoid confusion when two different redo streams have the same SCNs , occurred in different time.
RESETLOGS DOES
Archives the current online redo logs (if they are accessible).
Erases the contents of the online redologs and resets the log sequence number to 1.
If the current online redo logs are sequence 1000 and 1001, when you open with RESETLOGS, then the
database archives the sequence 1000 and 1001 then resets online redologs to sequence to 1 and 2.
Creates the online redo log files if they are NOT exist.
Resets the controlfile metadata about online redologs and redo threads.
Updates all datafiles, online redo log files and all sub sequent archived redo logs with a new
RESETLOGS SCN and TIMESTAMP.
RMAN> list incarnation;
Whenever you open the database with RESETLOGS option, a database incarnation is created. All
previous backups became invalid, so it is important to take a full backup of the database.
An incarnation helps to identify redo streams which have the same SCN, but occurred at different
points in time. This prevents applying the wrong archive log file from a previous incarnation.
Incarnation 1 of the database starts at SCN 1, and continues through SCN 1000 to SCN 2000. At SCN
2000 in incarnation 1, you perform a point-in-time recovery back to SCN 1000, and open the datbase
with a RESETLOGS operation. This creates incarnation 2, which begins at SCN 1000 and contines to
SCN
3000.
At
SCN
3000
in
incarnation
2,
you
perform
another
point-in-time
recovery
NORESETLOGS
Oracle uses NORESTLOGS when doing complete recovery (entire redo stream was applied). Oracle can
use existing log files. The NORESETLOGS option does not clear the redo log files during startup
and the online redo logs to be used for recovery if .
ARCHIVELOG | NOARCHIVELOG
If you Specify ARCHIVRLOG, Oracle archives the contents of redolog files instead of overwritten.
Archive mode helps to recover all committed transactions in the event of system or disk failure.
IT is not recommended to run the database in noarchivelog mode, you are disabling archiving of
redo logs. It cannot help from the media failure.
Once you omit both clause (Archive & Noarchive) by default oracle chooses noarchivelog mode.
REUSE | SET
SET: Use SET DATABASE clause to change name of the database. If you do NOT want to rename the
database, you should NOT use the SET DATABASE clause in the controlfile statement.
REUSE: Specify REUSE to indicate existing controlfile(s) can be reused and overwrite if file(s)
contain any information. If you omit this clause you will get error following below.
ORA-00202: control file: '/u01/app/oracle/oradata/devdb/control01.ctl'
ORA-27038: created file already exists
SAMPLE CREATE CONTROL FILE SCRIPT
The Oracle database requires a minimum of two redo log files to guarantee, one is available for
writing the other is being archived. LGWR writes to redo log files in circular fashion.
When the current redo log file fills, LGWR begins writing to the next available redolog file. When
the last available redolog file is filled, LGWR returns to the first redolog file & writes on it.
MULTIPLEXING REDOLOG FILES
LOGFILE
GROUP 1 '/u01/app/oracle/oradata/devdb/A_LOG1.log' SIZE 50M,
GROUP 1 '/u02/app/oracle/devdb/redolog/B_LOG1.log' SIZE 50M,
GROUP 2 '/u01/app/oracle/oradata/devdb/A_LOG2.log' SIZE 50M,
GROUP 2 '/u02/app/oracle/devdb/redolog/B_LOG2.log' SIZE 50M;
A_LOG1 & B_LOG1 are both members of Group 1, A_LOG2, B_LOG2 are both members of Group 2. Each
member in a group must be exactly the same size. Each member of a log file group is concurrently
active i.e. concurrently written by LGWR - as indicated by the identical log sequence numbers
assigned by LGWR.
At first LGWR writes concurrently to both A_LOG1 & B_LOG1. Then it writes concurrently to both
A_LOG2 and B_LOG2, and so on. LGWR never writes concurrently to members of different groups.
(For ex, A_LOG1 and B_LOG2.
TO CREATE A NEW REDO LOG - GROUP
Now lets take a look to recreate online redolog groups. If a group contains only one logfile
then you cannot drop that member.
Once we drop redolog group/member, the operating system file is NOT deleted from disk. In this
case I have already deleted group 4, but files are existing at Operating System level. So I am
using reuse clause here.
SQL> alter database add logfile group 4
('/u01/app/oracle/oradata/devdb/log4a.log',
'/u02/app/oracle/oradata/redolog/devdb/redo4b.log',
'/u03/app/oracle/oradata/redolog/devdb/redo4c.log') size 50m reuse;
Database altered.
You cannot drop a log group with CURRENT status. We can use ALTER SYSTEM command to make other
group to current status. Check these parameters (group#, members, status from v$log) view.
SQL> alter system switch logfile;
You cannot drop a log group with ACTIVE status. We can use ALTER SYSTEM command to resolve it.
SQL> alter system checkpoint.
We cannot resize the redolog files. We must drop the redolog file and recreate them and also cannot
drop the redolog file if its status is current or active. We have to change the status to inactive
then only we can drop it.
STATUS
----------
----------
INACTIVE
INACTIVE
INACTIVE
CURRENT
STATUS
-----------
INACTIVE
INACTIVE
CURRENT
INACTIVE
ACTIVE
Log is active, but it is NOT current log. Required for instance recovery.
INACTIVE
UNUSED
STALE
DELETED
V$LOG
V$LOGFILE
V$LOG_HISTORY
You can use operating system commands to relocate redo logs. I am using 11g database environment
to relocate redolog files. Lets start the process.
SQL> select group#, member from v$logfile;
GROUP#
----------
MEMBER
--------------------------------------------------
/u02/app/oracle/oradata/crms/redo03.log
/u02/app/oracle/oradata/crms/redo02.log
/u02/app/oracle/oradata/crms/redo01.log
The redo logs cannot be moved/renamed while the database is online. The database must be in
a mount state to move/rename the online redo logs. First shutdown the database and move online
redolog files to their new location.
SQL> shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
$ cd /u02/app/oracle/oradata/crms
$ mv redo01.log
/u01/app/oracle/oradata/redolog/crms/redo01.log
$ mv redo02.log
/u02/app/oracle/oradata/redolog/crms/redo02.log
$ mv redo03.log
/u03/app/oracle/oradata/redolog/crms/redo03.log
Next we bring up the database into mount mode and issue ALTER DATABASE RENAME FILE statements to
update the data dictionary and control files.
SYS> startup mount;
ORACLE instance started.
..
...
Database mounted.
SYS> alter database rename file
'/u02/app/oracle/oradata/crms/redo01.log' to
'/u01/app/oracle/oradata/redolog/crms/redo01.log';
Database altered.
SYS> alter database rename file
'/u02/app/oracle/oradata/crms/redo02.log' to
'/u02/app/oracle/oradata/redolog/crms/redo02.log';
Database altered.
MEMBER
---------- -------------------------------------------------3
/u03/app/oracle/oradata/redolog/crms/redo03.log
/u02/app/oracle/oradata/redolog/crms/redo02.log
/u01/app/oracle/oradata/redolog/crms/redo01.log
REDOLOGS RECOVERY
LOSING ONE MEMBER OF AN ONLINE REDOLOG GROUP
SQL>! mv
/u03/app/oracle/oradata/redolog/devdb/log4c.log
/u03/app/oracle/oradata/redolog/devdb/log4c.log.bkp
SQL> alter system switch logfile;
System altered.
Error message messages appeared in the alert log.
$ tail -f /u01/app/oracle/admin/devdb/bdump/alert_devdb.log
Errors in file /u01/app/oracle/admin/devdb/bdump/devdb_lgwr_20362.trc:
ORA-00313: open failed for members of log group 4 of thread 1
ORA-00312: online log 4 thread 1: '/u03/app/oracle/oradata/redolog/devdb/log4c.log'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
..
...
ORA-00321: log 4 of thread 1, cannot update log file header
MEMBER
STATUS
/u01/app/oracle/oradata/devdb/log4a.log
/u02/app/oracle/oradata/redolog/devdb/log4b.log
/u03/app/oracle/oradata/redolog/devdb/log4c.log
INVALID
Ensure that the online redolog file is not part of the current online log group.
listener.log
$ mv alert.log
alert_061212.log
$ cp alert.log
alert_061212.log
In 11g, the "adrci" tool to purge files from the diag dest - (trace files, core dump etc).
REMOVE OLD TRACE FILES IN 10G
SQL> show parameter background_dump_dest;
SQL> show parameter core_dump_dest;
SQL> show parameter user_dump_dest;
I am removing files 30 days older.
$ cd '/location of bdump/
$ find . -name '*.trc' -mtime +30 -print -exec rm {} \;
$ cd '/location of cdump/
$ find . -name '*.trc' -mtime +30 -print -exec rm {} \;
$ cd '/location of udump/
$ find . -name '*.trc' -mtime +30 -print -exec rm {} \;