Duplicating A Controlfile Into ASM When Original Controlfile Is Stored On A File System
On the database instance:
1.Identify the location of the current controlfile:
SQL> select name from v$controfile;
NAME
--------------------------------------------------------------------------------
/oradata2/102b/oradata/P10R2/control01.ctl'
2. Shutdown the database and start the instance:
SQL> shutdown normal
SQL> startup nomount
3. Use RMAN to duplicate the controlfile:
$ rman nocatalog
RMAN>connect target
RMAN>restore controlfile to '' from '';
RMAN> restore controlfile to '+DG1' from '/oradata2/102b/oradata/P10R2/control01.ctl';
Starting restore at 23-DEC-05
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
channel ORA_DISK_1: copied control file copy
Finished restore at 23-DEC-05
We are only specifying the name of the diskgroup, so Oracle will create an OMF (Oracle Managed File). Use ASMCMD or sqlplus to identify the name assigned to the controlfile
4.On the ASM instance, identify the name of the controlfile:
Using ASMCMD:
$ asmcmd
ASMCMD> cd
ASMCMD> find -t controlfile . *
Changing the current directory to the diskgroup where the controlfile was created will speed the search.
Output:
ASMCMD> find -t controlfile . *
+DG1/P10R2/CONTROLFILE/backup.308.577785757
ASMCMD>
Note the name assigned to the controlfile. Although the name starts with the backup word, that does not indicate is a backup of the file. This just the name assigned for the identical copy of the current controlfile.
5.On the database side:
Modify init.ora or spfile, adding the new path to parameter control_files.
if using init.ora, just modify the control_files parameter and restart the database.
If using spfile,
1)startup nomount the database instance
2)alter system set control_files='+DG1/P10R2/CONTROLFILE/backup.308.577785757','/oradata2/102b/oradata/P10R2/control01.ctl' scope=spfile;
For RAC instance:
alter system set control_files='+DG1/P10R2/CONTROLFILE/backup.308.577785757','/oradata2/102b/oradata/P10R2/control01.ctl' scope=spfile sid='*';
3)shutdown immediate
start the instance.
Verify that new control file has been recognized. If the new controlfile was not used, the complete procedure needs to be repeated.
Duplicating a controlfile into ASM using a specific name
It is also possible to duplicate the controlfile using a specific name for the new controlfile. In the following example, the controlfile is duplicated into a new diskgroup where controlfiles have not been created before.
On the ASM instance:
A.Create the directory to store the new controlfile.
SQL> alter diskgroup add directory '+//CONTROLFILE';
Note that ASM uses directories to store the files and those are created automatically when using OMF files. (just specifying the diskgroup name). Asumming that other OMF files were created on the diskgroup, the first directory (DB_NAME) already exist, so it is only required to create the directory for the controlfile.
SQL> alter diskgroup DG1 add directory '+DG1/P10R2/CONTROLFILE';
ASMCMD can also be used
ASMCMD>cd dg1
ASMCMD>mkdir controlfile
On the database instance:
B.Edit init.ora or spifile and modify parameter control_file:
control_files='+DG1/P10R2/CONTROLFILE/control02.ctl','/oradata2/102b/oradata/P10R2/control01.ctl'
C.Identify the location of the current controlfile:
SQL> select name from v$controfile;
NAME
--------------------------------------------------------------
/oradata2/102b/oradata/P10R2/control01.ctl'
D.Shutdown the database and start the instance:
SQL> shutdown normal
SQL> startup nomount
E.Use RMAN to duplicate the controlfile:
$ rman nocatalog
RMAN>connect target
RMAN>restore controlfile to '' from '';
RMAN> restore controlfile to '+DG1/PROD/controlfile/control02.ctl' from '/oradata2/102b/oradata/P10R2/control01.ctl';
Starting restore at 23-DEC-05
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
channel ORA_DISK_1: copied control file copy
Finished restore at 23-DEC-05
F.Start the database:
SQL> alter database mount;
SQL> alter database open;
Now, using ASMCMD to search for information for the controlfiles, the find -t contrlfile command will return two records. That does not indicate there were created two controlfiles. The name specified is an alias name and is only an entry in the ASM metadata (V$ASM_ALIAS). Oracle will create the alias and the OMF entry when user specifies the file name.
Duplicating a controlfile into ASM when original controlfile is stored on ASM
If using spfile to start the instance:
1.Modify the spfile specifically the parameter control_files. In this example, a second controlfile
is going to be created on same diskgroup DATA1.
sql> alter system set control_files='+DATA1/v102/controlfile/current.261.637923577','+DATA1'
scope=spfile sid='*';
2.Start the instance in NOMOUNT mode.
3.From rman, duplicate the controlfile
$ rman nocatalog
RMAN>connect target
RMAN> restore controlfile from '+DATA1/v102/controlfile/current.261.637923577';
The output for the execution is like:
Starting restore at 08-NOV-07
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=147 instance=V1021 devtype=DISK
channel ORA_DISK_1: copied control file copy
output filename=+DATA1/v102/controlfile/current.261.637923577
output filename=+DATA1/v102/controlfile/current.269.638120375
Finished restore at 08-NOV-07
Note that the command prints the name of the new created file: +DATA1/v102/controlfile/current.269.638120375
4.Mount and Open the database
RMAN> sql 'alter database mount';
RMAN> sql 'alter database open;
5.Validate both controlfiles are present
SQL> select name from v$controlfile;
NAME
--------------------------------------------------------------------------------
+DATA1/v102/controlfile/current.261.637923577
+DATA1/v102/controlfile/current.269.638120375
6.Modify the control_file parameter with the complete path of the new file:
sql> alter system set control_files='+DATA1/v102/controlfile/current.261.637923577','+DATA1/v102/controlfile/current.269.638120375'
scope=spfile sid='*';
Next time instance are restarted, will pick both files.
When using init.ora file:
1) Edit init.ora and add new disk group name or same disk group name for mirroring controlfiles.
Example:
control_files=('+GROUP1','+GROUP2')
(2) Start the instance in NOMOUNT mode.
(3) Execute restore command, to duplicate the controlfile using the original location. Presuming, your current controlfile location DISK path is '+data/V10G/controlfile/Current.260.605208993' , execute:
RMAN> restore controlfile from '+data/V10G/controlfile/Current.260.605208993';
Starting restore at 29-APR-05
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=317 devtype=DISK
channel ORA_DISK_1: copied controlfile copy
output filename=+GROUP2/v10g/controlfile/backup.268.7
output filename=+GROUP2/v10g/controlfile/backup.260.5
Finished restore at 29-APR-05
(4) Mount and open the database:
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1
RMAN> alter database open;
database opened
RMAN> exit
(5)Verify new mirrored controlfiles via sqlplus
SQL> show parameter control_files
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
control_files string +GROUP2/v10g/controlfile/backup.268.7, +GROUP2/v10g/controlfile/backup.260.5
On the database instance:
1.Identify the location of the current controlfile:
SQL> select name from v$controfile;
NAME
--------------------------------------------------------------------------------
/oradata2/102b/oradata/P10R2/control01.ctl'
2. Shutdown the database and start the instance:
SQL> shutdown normal
SQL> startup nomount
3. Use RMAN to duplicate the controlfile:
$ rman nocatalog
RMAN>connect target
RMAN>restore controlfile to '' from '';
RMAN> restore controlfile to '+DG1' from '/oradata2/102b/oradata/P10R2/control01.ctl';
Starting restore at 23-DEC-05
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
channel ORA_DISK_1: copied control file copy
Finished restore at 23-DEC-05
We are only specifying the name of the diskgroup, so Oracle will create an OMF (Oracle Managed File). Use ASMCMD or sqlplus to identify the name assigned to the controlfile
4.On the ASM instance, identify the name of the controlfile:
Using ASMCMD:
$ asmcmd
ASMCMD> cd
ASMCMD> find -t controlfile . *
Changing the current directory to the diskgroup where the controlfile was created will speed the search.
Output:
ASMCMD> find -t controlfile . *
+DG1/P10R2/CONTROLFILE/backup.308.577785757
ASMCMD>
Note the name assigned to the controlfile. Although the name starts with the backup word, that does not indicate is a backup of the file. This just the name assigned for the identical copy of the current controlfile.
5.On the database side:
Modify init.ora or spfile, adding the new path to parameter control_files.
if using init.ora, just modify the control_files parameter and restart the database.
If using spfile,
1)startup nomount the database instance
2)alter system set control_files='+DG1/P10R2/CONTROLFILE/backup.308.577785757','/oradata2/102b/oradata/P10R2/control01.ctl' scope=spfile;
For RAC instance:
alter system set control_files='+DG1/P10R2/CONTROLFILE/backup.308.577785757','/oradata2/102b/oradata/P10R2/control01.ctl' scope=spfile sid='*';
3)shutdown immediate
start the instance.
Verify that new control file has been recognized. If the new controlfile was not used, the complete procedure needs to be repeated.
Duplicating a controlfile into ASM using a specific name
It is also possible to duplicate the controlfile using a specific name for the new controlfile. In the following example, the controlfile is duplicated into a new diskgroup where controlfiles have not been created before.
On the ASM instance:
A.Create the directory to store the new controlfile.
SQL> alter diskgroup add directory '+//CONTROLFILE';
Note that ASM uses directories to store the files and those are created automatically when using OMF files. (just specifying the diskgroup name). Asumming that other OMF files were created on the diskgroup, the first directory (DB_NAME) already exist, so it is only required to create the directory for the controlfile.
SQL> alter diskgroup DG1 add directory '+DG1/P10R2/CONTROLFILE';
ASMCMD can also be used
ASMCMD>cd dg1
ASMCMD>mkdir controlfile
On the database instance:
B.Edit init.ora or spifile and modify parameter control_file:
control_files='+DG1/P10R2/CONTROLFILE/control02.ctl','/oradata2/102b/oradata/P10R2/control01.ctl'
C.Identify the location of the current controlfile:
SQL> select name from v$controfile;
NAME
--------------------------------------------------------------
/oradata2/102b/oradata/P10R2/control01.ctl'
D.Shutdown the database and start the instance:
SQL> shutdown normal
SQL> startup nomount
E.Use RMAN to duplicate the controlfile:
$ rman nocatalog
RMAN>connect target
RMAN>restore controlfile to '' from '';
RMAN> restore controlfile to '+DG1/PROD/controlfile/control02.ctl' from '/oradata2/102b/oradata/P10R2/control01.ctl';
Starting restore at 23-DEC-05
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
channel ORA_DISK_1: copied control file copy
Finished restore at 23-DEC-05
F.Start the database:
SQL> alter database mount;
SQL> alter database open;
Now, using ASMCMD to search for information for the controlfiles, the find -t contrlfile command will return two records. That does not indicate there were created two controlfiles. The name specified is an alias name and is only an entry in the ASM metadata (V$ASM_ALIAS). Oracle will create the alias and the OMF entry when user specifies the file name.
Duplicating a controlfile into ASM when original controlfile is stored on ASM
If using spfile to start the instance:
1.Modify the spfile specifically the parameter control_files. In this example, a second controlfile
is going to be created on same diskgroup DATA1.
sql> alter system set control_files='+DATA1/v102/controlfile/current.261.637923577','+DATA1'
scope=spfile sid='*';
2.Start the instance in NOMOUNT mode.
3.From rman, duplicate the controlfile
$ rman nocatalog
RMAN>connect target
RMAN> restore controlfile from '+DATA1/v102/controlfile/current.261.637923577';
The output for the execution is like:
Starting restore at 08-NOV-07
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=147 instance=V1021 devtype=DISK
channel ORA_DISK_1: copied control file copy
output filename=+DATA1/v102/controlfile/current.261.637923577
output filename=+DATA1/v102/controlfile/current.269.638120375
Finished restore at 08-NOV-07
Note that the command prints the name of the new created file: +DATA1/v102/controlfile/current.269.638120375
4.Mount and Open the database
RMAN> sql 'alter database mount';
RMAN> sql 'alter database open;
5.Validate both controlfiles are present
SQL> select name from v$controlfile;
NAME
--------------------------------------------------------------------------------
+DATA1/v102/controlfile/current.261.637923577
+DATA1/v102/controlfile/current.269.638120375
6.Modify the control_file parameter with the complete path of the new file:
sql> alter system set control_files='+DATA1/v102/controlfile/current.261.637923577','+DATA1/v102/controlfile/current.269.638120375'
scope=spfile sid='*';
Next time instance are restarted, will pick both files.
When using init.ora file:
1) Edit init.ora and add new disk group name or same disk group name for mirroring controlfiles.
Example:
control_files=('+GROUP1','+GROUP2')
(2) Start the instance in NOMOUNT mode.
(3) Execute restore command, to duplicate the controlfile using the original location. Presuming, your current controlfile location DISK path is '+data/V10G/controlfile/Current.260.605208993' , execute:
RMAN> restore controlfile from '+data/V10G/controlfile/Current.260.605208993';
Starting restore at 29-APR-05
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=317 devtype=DISK
channel ORA_DISK_1: copied controlfile copy
output filename=+GROUP2/v10g/controlfile/backup.268.7
output filename=+GROUP2/v10g/controlfile/backup.260.5
Finished restore at 29-APR-05
(4) Mount and open the database:
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1
RMAN> alter database open;
database opened
RMAN> exit
(5)Verify new mirrored controlfiles via sqlplus
SQL> show parameter control_files
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
control_files string +GROUP2/v10g/controlfile/backup.268.7, +GROUP2/v10g/controlfile/backup.260.5
No comments:
Post a Comment