How to clone a single instance database to a RAC database

This blog post shows how to clone a single instance database using file system for datafiles to a RAC database using ASM. I am going to use a 11.2 RMAN feature named backup-based duplication that allows to run RMAN DUPLICATE without connecting to target database: in some environments this may be not possible for security reasons or you have just been given RMAN backup sets without physical network connection to target database.

Oracle version used is 11.2.0.3.

Backup source database

Backup source database to file system with RMAN:

backup database format '/backup/%U' plus archivelog format '/backup/%U';

Copy backup sets to RAC node

$ scp /backup/* vmoe1:/backup

PFILE creation on single node database

You need to create a PFILE for the target database because backup-based duplication does not work with SPFILE.

SQL> show parameter spfile

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      /u01/oracle/db11203/dbs/spfile
                                                 FS0.ora
SQL> create pfile='/backup/initFS0.ora' from spfile;

File created.

Copy PFILE to RAC node database Oracle Home

$ scp ol6elsa0:/backup/initFS0.ora $ORACLE_HOME/dbs/initRAC0.ora

Note that the new PFILE name that matches the new database because we want to rename database.

Modify PFILE on RAC node

We want to rename database to RAC0: DB_NAME should be modified to RAC0. Source database is using Fast Recovery Area: we need to change it to the right ASM disk group. You need to remove CONTROL_FILES parameter and to define DB_CREATE_FILE_DEST to the right ASM diskgroup:

*.db_name=RAC0
*.db_recovery_file_dest='+RECO'
*.db_create_file_dest='+DATA'
 

You may also need to adapt DIAGNOSTIC_DEST setting or AUDIT_FILE_DEST if directory name differ.

Modify ORACLE_SID on RAC node

You need to modify ORACLE_SID and to set it to new database name. At this stage database is still single instance database so you must not use a RAC instance name with a instance number suffix.

$ export ORACLE_SID=RAC0

Start the instance in NOMOUNT mode

SQL> startup nomount;

Duplicate target database

First connect only to auxiliary instance with RMAN on RAC node:

$ rman auxiliary /

Then launch following RMAN statement to ask RMAN:

– to store datafiles and tempfiles in ‘+DATA’ disk group

– to use backup sets located in /backup directory

– to create 2 redo logs groups:

run {
set newname for database to '+DATA';
duplicate target database to RAC0
backup location '/backup/'
logfile
group 1 ('+DATA','+RECO') size 50M,
group 2 ('+DATA','+RECO') size 50M;
}

Check that RMAN DUPLICATE statements does not report any error and ends with:

contents of Memory Script:
{
   Alter clone database open resetlogs;
}
executing Memory Script

database opened
Finished Duplicate Db at DD-MMM-YY

Modify CONTROL_FILES

Retrieve CONTROL_FILES that have been generated by RMAN: you can retrieve them in RMAN DUPLICATE output when RMAN has restored the control files or simply use SQL*Plus statement:

show parameter control_files

Modify CONTROL_FILES parameter in PFILE with the right value.

Check that you can restart the database instance with the modified PFILE:

shutdown immediate
startup

Configure database for RAC

For each new instance on RAC cluster, you need to:

– add an undo tablespace

– add groups of online redo logs (ORL)

– enable these ORL groups (redo log thread).

In our case we have a 2-node RAC cluster: we only need to add 1 undo tablespace and 1 additional set of ORL:

create undo tablespace UNDOTBS2 datafile '+DATA';
alter database add logfile thread 2 group 3 ('+DATA','+RECO') size 50M;
alter database add logfile thread 2 group 4 ('+DATA','+RECO') size 50M;
alter database enable public thread 2;

Add initialization parameters in PFILE for RAC cluster on first node. You need to prefix instance specific parameters with the right instance name (the existing undo tablespace parameter must be prefixed with node 1 instance name):

*.cluster_database_instances=2
*.cluster_database=true
RAC01.instance_number=1
RAC02.instance_number=2
RAC01.thread=1
RAC02.thread=2
RAC01.undo_tablespace='UNDOTBS1'
RAC02.undo_tablespace='UNDOTBS2'

Rename the PFILE on node1 with instance name:

$ mv initRAC0.ora initRAC01.ora

Copy the PFILE from node 1 to node 2 and rename it with right instance name:

$ scp initRAC01.ora vmoe2:$ORACLE_HOME/dbs/initRAC02.ora

Check that you can start manually instances on each cluster node.
First you need to stop current instance on node 1 with current ORACLE_SID setting:

$ sqlplus / as sysdba
shutdown immediate

On node 1 with new RAC ORACLE_SID:

$ export ORACLE_SID=RAC01
$ sqlplus / as sysdba
startup
shutdown immediate

On node 2 with RAC ORACLE_SID:

$ export ORACLE_SID=RAC02
$ sqlplus / as sysdba
startup
shutdown immediate

Create SPFILE in ASM

$ sqlplus / as sysdba
create spfile='+DATA/RAC0/spfile' from pfile;

Modify PFILE to use ASM SPFILE on both nodes:

$ cat $ORACLE_HOME/dbs/initRAC01.ora
SPFILE='+DATA/RAC0/spfile'
$ scp $ORACLE_HOME/dbs/initRAC01.ora vmoe2:$ORACLE_HOME/dbs/initRAC02.ora

Add database and database instances to cluster configuration

$ srvctl add database -d RAC0 -o $ORACLE_HOME  -p +DATA/RAC0/spfile
$ srvctl add instance -d RAC0 -i RAC01 -n vmoe1
$ srvctl add instance -d RAC0 -i RAC02 -n vmoe2

Check that you can start database with srvctl:

$ srvctl start database -d RAC0
$ srvctl status database -d RAC0

You also need to fix /etc/oratab to replace DB_NAME by ORACLE_SID on both nodes.

You may also need to update tnsnames.ora and to create a password file on both nodes for this new RAC database.

Follow

Get every new post delivered to your Inbox.