Você está na página 1de 10

HOW TO RECREATE THE CONTROLFILE

ON A RAC ENVIRONMENT
Alejandro Vargas
Oracle Support Israel
Principal Support Consultant

Table of Contents
Case Description.................................................................................................................................................................................................... 2
Recreate Controlfile on a RAC environment, list of steps ....................................................................................................................................2
Step by Step Execution ......................................................................................................................................................................................... 3
1. Generate a create controlfile script on the source database and edit it ........................................................................................................3
2. Generate a pfile from the source database and edit it ...................................................................................................................................4
3. Startup nomount the database with the pfile ................................................................................................................................................ 5
4. Execute the create controlfile script ............................................................................................................................................................ 6
5. Check the name of the new controlfile .........................................................................................................................................................7
6. Shutdown immediate ....................................................................................................................................................................................7
7. Edit the pfile with the new controlfile name enable cluster ........................................................................................................................ 7
8. Startup nomount with the pfile .....................................................................................................................................................................8
9. Create an spfile from the pfile and set a pfile on both servers pointing to it ............................................................................................... 8
10. Shutdown immediate ..................................................................................................................................................................................8
11. Register the database with CRS ................................................................................................................................................................. 9
12. Startup the Database Using srvctl .............................................................................................................................................................. 9
End of the procedure ...................................................................................................................................................................................... 10

Case Description
An ASM disk group containing a 10g R2 RAC database has been cloned using storage tools.
The cloned ASM disk group has been mounted on a 2 node cluster where there are located other clones of the same
source RAC database.
To be able to open the cloned database we need to rename it, we achieve this generating a new controlfile.
The create controlfile purpose will be to rename the database, so that several copies of the same database can coexist
on the same server.

Recreate Controlfile on a RAC environment, list of steps


1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.

Generate a create controlfile script on the source database and edit it


Generate a pfile from the source database and edit it to set database name, cluster false and controlfile destination
Startup nomount the database with the pfile
Execute the create controlfile script
Check the name of the new controlfile
Shutdown immediate
Edit the pfile with the new controlfile name, enable cluster
Startup nomount with the pfile
Create an spfile from the pfile and set a pfile on both servers pointing to it
Shutdown immediate
Register the database with CRS
Startup the database using srvctl

Step by Step Execution


1. Generate a create controlfile script on the source database and edit it
Execute on the source database:
Alter database backup controlfile to trace;
Find on the user_dump_destination the last trace and edit it, you may get something similar to this:
STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "RACDBTST" NORESETLOGS ARCHIVELOG
MAXLOGFILES 192
MAXLOGMEMBERS 3
MAXDATAFILES 1024
MAXINSTANCES 32
MAXLOGHISTORY 292
LOGFILE
GROUP 1 '+DATADG/racdbtst/onlinelog/group_1.283.621521871' SIZE 50M,
GROUP 2 '+DATADG/racdbtst/onlinelog/group_2.273.621521875' SIZE 50M,
GROUP 3 '+DATADG/racdbtst/onlinelog/group_3.286.621521877' SIZE 50M,
GROUP 4 '+DATADG/racdbtst/onlinelog/group_4.280.621521881' SIZE 50M,
GROUP 5 '+DATADG/racdbtst/onlinelog/group_5.275.621521885' SIZE 50M,
GROUP 6 '+DATADG/racdbtst/onlinelog/group_6.289.621521891' SIZE 50M
-- STANDBY LOGFILE
DATAFILE
'+DATADG/racdbtst/datafile/system.256.621519033',
'+DATADG/racdbtst/datafile/undotbs1.257.621519099',
'+DATADG/racdbtst/datafile/sysaux.258.621519347',
'+DATADG/racdbtst/datafile/undotbs2.265.621519461',
'+DATADG/racdbtst/datafile/users.266.621519497',
'+DATADG/racdbtst/datafile/recop1.261.621519675',
'+DATADG/racdbtst/datafile/tbs_manual.287.621519689',

'+DATADG/racdbtst/datafile/tbs_auto.272.621519707',
'+DATADG/racdbtst/datafile/on_asm.288.621519721'
CHARACTER SET AL32UTF8
;

On this file you will need to change the syntax to set the new name of the database.
If the clone was done using begin/end backup you will need to do recovery and resetlogs also:
Change from:
CREATE CONTROLFILE REUSE DATABASE "RACDBTST" NORESETLOGS ARCHIVELOG
to
CREATE CONTROLFILE REUSE SET DATABASE "RACDBNEW" RESETLOGS ARCHIVELOG
On the lines containing the old diskgroup name you will need to setup the new diskgroup name, ie: Change from:
'+DATADG/racdbtst/datafile/on_asm.288.621519721'
to
'+DATADGNEW/racdbtst/datafile/on_asm.288.621519721'

2. Generate a pfile from the source database and edit it


On the source database create a pfile
create pfile='/tmp/initracdb.ora' from spfile;
Edit the pfile, change the parameters that do require new values.
Set cluster_database to false for this stage, set control_files to the name of the disk group only.:
*.db_name='racdbnew'
*.cluster_database=FALSE
*.control_files='+DATADGNEW'
*.db_create_file_dest='+DATADGNEW'

*.log_archive_dest_1='LOCATION=+ARCHDGNEW/RACDBTST/ARCHIVED_LOGS/'
*.audit_file_dest='/oradisk/app01/oracle/admin/racdbnew/adump'
*.background_dump_dest='/oradisk/app01/oracle/admin/racdbnew/bdump'
*.core_dump_dest='/oradisk/app01/oracle/admin/racdbnew/cdump'
*.user_dump_dest='/oradisk/app01/oracle/admin/racdbnew/udump'
*.db_recovery_file_dest='+ARCHDGNEW'
racdbtst1.instance_number=1
racdbtst2.instance_number=2
*.log_archive_dest_1='LOCATION=+ARCHDGNEW/RACDBTST/ARCHIVED_LOGS/'
*.remote_listener='LISTENERS_RACDBNEW'
racdbnew1.instance_number=1
racdbnew2.instance_number=2
racdbnew1.thread=1
racdbnew1.undo_tablespace='UNDOTBS1'
racdbnew2.undo_tablespace='UNDOTBS2'

3. Startup nomount the database with the pfile


SQL> startup nomount pfile='/tmp/initracdb.ora';
ORACLE instance started.
Total System Global Area 314572800 bytes
Fixed Size
1219184 bytes
Variable Size
96470416 bytes
Database Buffers
213909504 bytes
Redo Buffers
2973696 bytes
SQL> show parameters cluster
NAME TYPE VALUE
------------------------------------ ----------- -----------------------------cluster_database boolean FALSE
cluster_database_instances integer 1

cluster_interconnects string
SQL> show parameters control
NAME TYPE VALUE
------------------------------------ ----------- -----------------------------control_file_record_keep_time integer 7
control_files string +DATADG

4. Execute the create controlfile script


SQL> @CRCTL
SQL> CREATE CONTROLFILE REUSE SET DATABASE "RACDBNEW" RESETLOGS ARCHIVELOG
2 MAXLOGFILES 192
3 MAXLOGMEMBERS 3
4 MAXDATAFILES 1024
5 MAXINSTANCES 32
6 MAXLOGHISTORY 292
7 LOGFILE
8 GROUP 1 '+DATADGNEW/racdbtst/onlinelog/group_1.283.621521871' SIZE 50M,
9 GROUP 2 '+DATADGNEW/racdbtst/onlinelog/group_2.273.621521875' SIZE 50M,
10 GROUP 3 '+DATADGNEW/racdbtst/onlinelog/group_3.286.621521877' SIZE 50M,
11 GROUP 4 '+DATADGNEW/racdbtst/onlinelog/group_4.280.621521881' SIZE 50M,
12 GROUP 5 '+DATADGNEW/racdbtst/onlinelog/group_5.275.621521885' SIZE 100M,
13 GROUP 6 '+DATADGNEW/racdbtst/onlinelog/group_6.289.621521891' SIZE 100M
14 -- STANDBY LOGFILE
15 DATAFILE
16 '+DATADGNEW/racdbtst/datafile/system.256.621519033',
17 '+DATADGNEW/racdbtst/datafile/undotbs1.257.621519099',
18 '+DATADGNEW/racdbtst/datafile/sysaux.258.621519347',
19 '+DATADGNEW/racdbtst/datafile/undotbs2.265.621519461',
20 '+DATADGNEW/racdbtst/datafile/users.266.621519497',
21 '+DATADGNEW/racdbtst/datafile/recop1.261.621519675',

22 '+DATADGNEW/racdbtst/datafile/tbs_manual.287.621519689',
23 '+DATADGNEW/racdbtst/datafile/tbs_auto.272.621519707',
24 '+DATADGNEW/racdbtst/datafile/on_asm.288.621519721'
25 CHARACTER SET AL32UTF8
26 ;
Control file created.

5. Check the name of the new controlfile


You can see that the control_files parameter was updated to the current value
SQL> SHOW PARAMETERS CONTROL
NAME TYPE VALUE
------------------------------------ ----------- -----------------------------control_file_record_keep_time integer 7
control_files string +DATADGNEW/racdbtst/controlfile/current.282.642363877

6. Shutdown immediate
Shutdown immediate, next you will need to edit the pfile with the new controlfile name
SQL> SHUTDOWN IMMEDIATE;
ORA-01109: database not open
Database dismounted.

7. Edit the pfile with the new controlfile name, enable cluster
Set the controlfile name and enable cluster
control_files='+DATADGNEW/racdbtst/controlfile/current.282.642363877'
cluster_database=TRUE

8. Startup nomount with the pfile


SQL> startup nomount pfile='/tmp/initracdb.ora'
ORACLE instance started.
Total System Global Area
314572800 bytes
Fixed Size
1219184 bytes
Variable Size
96470416 bytes
Database Buffers
213909504 bytes
Redo Buffers
2973696 bytes

9. Create an spfile from the pfile and set a pfile on both servers pointing to it
Now we need to generate an spfile and the pfiles for both instances that will point to it.
SQL> create spfile='+DATADGNEW/spfileracdbnew.ora' from pfile='/tmp/initracdb.ora';
File created.
Go to $ORACLE_HOME/dbs on node 1 and setup an init.ora pointing to the new spfile
echo "SPFILE='+DATADGNEW/spfileracdbnew.ora'" >initracdbnew1.ora
Go to $ORACLE_HOME/dbs on node 2 and setup an init.ora pointing to the new spfile
echo "SPFILE='+DATADGNEW/spfileracdbnew.ora'" >initracdbnew2.ora

10. Shutdown immediate


Shutdown immediate, next you will be able to startup the database with the spfile
SQL> SHUTDOWN IMMEDIATE;
ORA-01109: database not open

11. Register the database with CRS


The last step will be to register the cluster database with CRS
srvctl add database -d racdbnew -o /oradisk/app01/oracle/product/10gDB -p +DATADGNEW/spfileracdbnew.ora
srvctl add instance -d racdbnew -i racdbnew1 -n vmractest1
srvctl add instance -d racdbnew -i racdbnew2 -n vmractest2
srvctl add service -d racdbnew -s dbtest1 -r racdbnew1,racdbnew2
Check CRS with crs_stat -t
{oracle} /tmp [vmractest1] > chkcrs |grep racdbnew
ora.racdbnew.db
ora.racdbnew.dbtest1.cs
ora.racdbnew.dbtest1.racdbnew1.srv
ora.racdbnew.dbtest1.racdbnew2.srv
ora.racdbnew.racdbnew1.inst
ora.racdbnew.racdbnew2.inst

OFFLINE OFFLINE
OFFLINE OFFLINE
OFFLINE OFFLINE
OFFLINE OFFLINE
OFFLINE OFFLINE
OFFLINE OFFLINE

12. Startup the Database Using srvctl


At this moment we are ready to bring the cluster database up using srvctl.
> srvctl start database d racdbnew
> srvctl start service d racdbnew
{oracle} /tmp [vmractest1] > chkcrs |grep racdbnew
ora.racdbnew.db
ora.racdbnew.dbtest1.cs
ora.racdbnew.dbtest1.racdbnew1.srv
ora.racdbnew.dbtest1.racdbnew2.srv
ora.racdbnew.racdbnew1.inst
ora.racdbnew.racdbnew2.inst

ONLINE ONLINE
ONLINE ONLINE
ONLINE ONLINE
ONLINE ONLINE
ONLINE ONLINE
ONLINE ONLINE

{oracle} /tmp [vmractest1] > sqlplus / as sysdba


SQL> show parameters cluster
NAME TYPE VALUE
------------------------------------ ----------- -----------------------------cluster_database boolean TRUE
cluster_database_instances integer 2
cluster_interconnects string
SQL> show parameters control
NAME TYPE VALUE
------------------------------------ ----------- -----------------------------control_file_record_keep_time integer 7
control_files string +DATADGNEW/racdbtst/controlfile/current.282.642363877

End of the procedure

Você também pode gostar