Search This Blog

Friday, April 10, 2015

Control File

alter database backup controlfile to trace;

alter database backup controlfile to trace as '/u01/bkp/mycf.sql';

We need at least one control file to up and run the database.  It's suggested from oracle to have at least 3 control files, which are all same.  They can be kept on 3 different places or disks.  If any one file get corrupted we can recreate it by just copying it from another place.

If we lost all the 3 files we can recreate them using the below command. When we send the control file to trace it will have the following command.  Which contains both the commands for resetlogs or noresetlogs.  Control file is also a binary file which we cannot see in a word editor.  But once we send it to a trace file it can be editable and viewable in editors.

STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "ORCL" NORESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '/u01/prod/REDO01.LOG' SIZE 50M,
GROUP 2 '/u01/prod/REDO02.LOG' SIZE 50M,
GROUP 3 '/u01/prod/REDO03.LOG' SIZE 50M
-- STANDBY LOGFILE
DATAFILE
'/u01/prod/SYSTEM01.DBF',
'/u01/prod/SYSAUX01.DBF',
'/u01/prod/USERS01.DBF',
'/u01/prod/UNDOTBS01.DBF'
CHARACTER SET AR8MSWIN1256
;

This command creates 3 control files.  Even we lost our exact control file also we can find the information of our CRD files and put them in this command to recreate the current control file.

To add a control file or multiplex a control file:

1.
col name for a40
select name from v$controlfile order by name;
/u01/prod/control01.ctl
/u01/prod/control02.ctl

suppose we have 2 files only and we want to add a 3rd control file

alter system set control_files='/u01/prod/control01.ctl','/u01/prod/control02.ctl','/u01/prod/control03.ctl'
scope=spfile;

shutdown immediate;

2. 
$cp /u01/prod/control02.ctl /u01/prod/control03.ctl

3.
startup

4.
select name from v$controlfile order by name;

No comments:

Post a Comment