Oracle DBA, How To, Error, Cause and Action

Backup Control File

Use the ALTER DATABASE BACKUP CONTROLFILE statement to back up your control files. You have two options:

- Produce SQL statements that can later be used to re-create your control file:

ALTER DATABASE BACKUP CONTROLFILE TO TRACE;

This command writes a SQL script to a trace file where it
can be captured and edited to reproduce the control file. View the
alert log to determine the name and location of the trace file.

To create backup controlfile to trace, first we need to find out where and what is our trace file, we can find out from alert log file or can use following SQL command to find out the trace file from v$diag_info view.

SELECT value FROM v$diag_info WHERE name = 'Default Trace File';

Now we issue the command backup control file to trace

ALTER DATABASE BACKUP CONTROLFILE TO TRACE;


The recreate controlfile script is created in the trace file.

If you go view the file which for my example is /u01/app/oracle/diag/rdbms/edba01/edba01/trace/edba01_ora_13255.trc

There will be 2 set of scripts.

1. Create Controlfile script with No Resetlogs
2. Create Controlfile script with Resetlogs

Above scripts can be use to rebuild back controlfile.

-- Set #1. NORESETLOGS case
--
-- The following commands will create a new control file and use it
-- to open the database.
-- Data used by Recovery Manager will be lost.
-- Additional logs may be required for media recovery of offline
-- Use this only if the current versions of all online logs are
-- available.
-- After mounting the created controlfile, the following SQL
-- statement will place the database in the appropriate
-- protection mode:
-- ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PERFORMANCE
STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "EDBA01" NORESETLOGS NOARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '/datafiles/edba01/edba01/redo01.log' SIZE 50M,
GROUP 2 '/datafiles/edba01/edba01/redo02.log' SIZE 50M,
GROUP 3 '/datafiles/edba01/edba01/redo03.log' SIZE 50M
-- STANDBY LOGFILE
DATAFILE
'/datafiles/edba01/edba01/system01.dbf',
'/datafiles/edba01/edba01/sysaux01.dbf',
'/datafiles/edba01/edba01/undotbs01.dbf',
'/datafiles/edba01/edba01/users01.dbf',
'/datafiles/edba01/edba01/my_first_tbs_01.dbf',
'/datafiles/edba01/edba01/my_tbs_01.dbf',
'/datafiles/edba01/edba01/my_tbs_02.dbf',
'/datafiles/edba01/edba01/my_tbs_03.dbf'
CHARACTER SET WE8MSWIN1252
;


-- Set #2. RESETLOGS case
--
-- The following commands will create a new control file and use it
-- to open the database.
-- Data used by Recovery Manager will be lost.
-- The contents of online logs will be lost and all backups will
-- be invalidated. Use this only if online logs are damaged.
-- After mounting the created controlfile, the following SQL
-- statement will place the database in the appropriate
-- protection mode:
-- ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PERFORMANCE
STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "EDBA01" RESETLOGS NOARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '/datafiles/edba01/edba01/redo01.log' SIZE 50M,
GROUP 2 '/datafiles/edba01/edba01/redo02.log' SIZE 50M,
GROUP 3 '/datafiles/edba01/edba01/redo03.log' SIZE 50M
-- STANDBY LOGFILE
DATAFILE
'/datafiles/edba01/edba01/system01.dbf',
'/datafiles/edba01/edba01/sysaux01.dbf',
'/datafiles/edba01/edba01/undotbs01.dbf',
'/datafiles/edba01/edba01/users01.dbf',
'/datafiles/edba01/edba01/my_first_tbs_01.dbf',
'/datafiles/edba01/edba01/my_tbs_01.dbf',
'/datafiles/edba01/edba01/my_tbs_02.dbf',
'/datafiles/edba01/edba01/my_tbs_03.dbf'
CHARACTER SET WE8MSWIN1252
;


After execute one of above script

-- Commands to re-create incarnation table
-- Below log names MUST be changed to existing filenames on
-- disk. Any one log file from each branch can be used to
-- re-create incarnation records.
-- ALTER DATABASE REGISTER LOGFILE '/datafiles/edba01/flash_recovery_area/EDBA01/archivelog/2009_01_20/o1_mf_1_
1_%u_.arc';
-- Recovery is required if any of the datafiles are restored backups,
-- or if the last shutdown was not normal or immediate.
RECOVER DATABASE USING BACKUP CONTROLFILE
-- Database can now be opened zeroing the online logs.
ALTER DATABASE OPEN RESETLOGS;
-- Commands to add tempfiles to temporary tablespaces.
-- Online tempfiles have complete space information.
-- Other tempfiles may require adjustment.
ALTER TABLESPACE TEMP ADD TEMPFILE '/datafiles/edba01/edba01/temp01.dbf'
SIZE 40894464 REUSE AUTOEXTEND ON NEXT 655360 MAXSIZE 32767M;
-- End of tempfile additions.
--


Note Oracle will overwrite this file if you issue the command ALTER DATABASE BACKUP CONTROLFILE TO TRACE again. Unlike the previous Oracle version new trace file will be created each time you issue the command.


2. Back up the control file to a binary file (duplicate of existing control file) using the following statement:

ALTER DATABASE BACKUP CONTROLFILE TO '/tmp/mycontrolfile.ctl';

You can issue the filename with fullpath where you have permission to create the binary version of controlfile.



The new file created, I am checking the file and it say it is datafile, while the trace file it said it is ASCII English text file

No comments:

Post a Comment

Thanks for your comment.