In this article, we will clone a RAC environment by extracting the backup of the source database from the Recovery Appliance. The clone will be created with a single-node environment and then converted to a cluster, as per the original environment.
Below are some details in the table:
| Source Database | ORDB |
| Source Node 1 | oraordb01 |
| Source Node 2 | oraordb02 |
| Destination Database | ORCL |
| Destination Node 1 | oraorcl01 |
| Destination Node 2 | oraorcl02 |
With the strings already configured in the tnsnames.ora files on the destination environment nodes, we will begin the procedure by creating an init (pfile) from the source environment, so that all parameters can be the same on both the source and the destination, with only a few specific parameters being changed at the end of the process.
In the source environment, connect to sqlplus and then create the init file:
sqlplus "/as sysdba"
create pfile='/tmp/initorcl01.ora' from spfile;
Then, move the file to the $ORACLE_HOME/dbs directory of the destination RAC.
scp /tmp/initorcl01.ora oraorcl01:/u01/app/oracle/product/19.0.0.0/dbs/initorcl01.ora
We will modify the necessary parameters in the init file to perform the duplicate in single-node mode:
- Replace all entries referring to node 1 (ordb01) with * (asterisk).
- Remove all entries for node 2 (ordb02).
- Remove all entries starting with the following parameters:
cluster
instance_number
thread
As shown in the examples below:
Delete or comment out:
*.cluster_database_instances=2
*.cluster_database=true
ordb01.cluster_interconnects='10.0.0.1'
ordb02.cluster_interconnects='10.0.0.2'
ordb01.instance_number=1
ordb02.instance_number=2
*.remote_listener='racordb-scan:2569'
ordb02.thread=2
ordb01.thread=1
Modify:
audit_file_dest='/u01/app/oracle/admin/ordb/adump'
to
audit_file_dest='/u01/app/oracle/admin/orcl/adump'
*.db_name='ORDB'
to
*.db_name='ORCL'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=ORDBXDB)'
to
*.dispatchers='(PROTOCOL=TCP) (SERVICE=ORCLXDB)'
*.control_files='+DATA/ordb/controlfile/current.123456789','+RECO/ordb/controlfile/current.123456789'
to
*.control_files='+DATA/orcl/controlfile/controlorcl01.ora','+RECO/orcl/controlfile/controlorcl02.ora'
*.wallet_root='/u01/app/oracle/WALLETS/ORCL'
*.db_create_file_dest='+DATA'
*.db_create_online_log_dest_1='+DATA'
ordb01.undo_tablespace='UNDOTBS1'
to
*.undo_tablespace='UNDOTBS1'
Note: Make sure to verify the exact names of the UNDOs from the source environment to modify this parameter, as errors may occur at the end of the duplicate process.
To check, run the following select on the source database:
sqlplus "/as sysdba"
select tablespace_name from dba_tablespaces
where tablespace_name like '%UNDO%';
Add the following parameters to move the data files from one location to another:
Use the parameter log_file_name_convert in the init file. If not specified, RMAN will create the files with the same name as the target (which should be on a different host), but NOFILENAMECHECK must be used.
The parameter is structured as follows: ‘SOURCE’, ‘DESTINATION’, ‘SOURCE’, ‘DESTINATION’
*.log_file_name_convert='+DATA/ORDB/','+DATA/ORCL/','+RECO/ORDB/','+RECO/ORCL/'
For the datafiles, use the set newname and set auxname commands in the duplicate command. However, you must use the pfile instead of the spfile during the duplicate, or you will encounter an error.
Instead of using the set commands, you can use the db_file_name_convert parameter in the init file. If not specified, RMAN will use the same name as the target, requiring NOFILENAMECHECK, and it must be on a different host.
The parameter is structured as follows: ‘SOURCE’, ‘DESTINATION’, ‘SOURCE’, ‘DESTINATION’
*.db_file_name_convert='+DATA/ORDB/','+DATA/ORCL/'
We will create the directories on the source, preparing both nodes of the destination RAC to receive the new database.
For both nodes, create the following dump directories:
cd /u01/app/oracle/admin/
mkdir orcl
cd orcl
mkdir adump dpdump hdump
Create the wallet directories for TDE, as well as for ZDL:
- TDE
cd /u01/app/oracle/WALLETS/
mkdir -p ORCL/tde
cd ORCL/tde
scp -p oraordb01:/u01/app/oracle/WALLETS/ORCL/tde/*.* .
scp -p oraordb02:/u01/app/oracle/WALLETS/ORCL/tde/*.* .
- ZDL
cd /u01/app/oracle/WALLETS/
mkdir -p ORCL/geral
cd ORCL/geral
scp -p oraordb01:/u01/app/oracle/WALLETS/ORCL/geral/*.* .
scp -p oraordb02:/u01/app/oracle/WALLETS/ORCL/geral/*.* .
Create the cluster services on each destination node:
srvctl add database -d orcl -o /u01/app/oracle/product/19.0.0.0
srvctl add instance -d orcl -i orcl01 -n oraorcl01
srvctl add instance -d orcl -i orcl02 -n oraorcl02
Note: Do not add a slash at the end of ORACLE_HOME, as this will prevent connection errors at the end of the process.
Create the orapw file inside ASM and enter the password when prompted:
asmcmd
pwcreate --dbuniquename ORCL +DATA/orapworcl
We will connect to the database using sqlplus, then start the database with the init file we created earlier, and finally create an spfile:
sqlplus "/as sysdba"
startup force nomount pfile=/u01/app/oracle/product/19.0.0.0/dbs/initorcl01.ora
create spfile from pfile;
shutdown immediate;
Send the spfile outside of ASM to avoid an error where the spfile is used when RMAN modifies parameters in the file during the clone process.
First, we need to check the alert log of the destination database to determine where the spfile was created:
cd $ORACLE_BASE/diag/rdbms/orcl/orcl01/trace
vi alert_orcl01.log
Inside the vi editor for the file, search for the spfile created inside ASM.
After this, use asmcmd to copy the file outside:
asmcmd
cp +DATA/spfileorcl01.ora /u01/app/oracle/product/19.0.0.0/dbs/spfileorcl01.ora
Modify the database configuration to use the spfile that was moved outside of ASM:
srvctl modify database -d orcl -spfile /u01/app/oracle/product/19.0.0.0/dbs/spfileorcl01.ora
Start the database in nomount mode:
sqlplus "/as sysdba"
startup force nomount;
Set environment variables:
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
export NLS_DATE_FORMAT='DD/MM/YYYY HH24:MI:SS'
export ORACLE_SID=orcl01
Connect to the ZDL catalog and the auxiliary database of the ORCL database, then start the duplicate process.
Review the SBT_LIBRARY parameter for the correct ZDL library paths, as well as for the wallet and credential.
rman catalog /@zdlra01 auxiliary / log=/tmp/duplicate.log
run {
allocate AUXILIARY channel x1 DEVICE TYPE 'SBT_TAPE' PARMS "SBT_LIBRARY=/u01/app/oracle/product/19.0.0.0/lib/libra.so, ENV=(RA_WALLET='location=file:/u01/app/oracle/WALLETS/ORCL/geral credential_alias=dr_ra01')";
allocate AUXILIARY channel x2 DEVICE TYPE 'SBT_TAPE' PARMS "SBT_LIBRARY=/u01/app/oracle/product/19.0.0.0/lib/libra.so, ENV=(RA_WALLET='location=file:/u01/app/oracle/WALLETS/ORCL/geral credential_alias=dr_ra01')";
allocate AUXILIARY channel x3 DEVICE TYPE 'SBT_TAPE' PARMS "SBT_LIBRARY=/u01/app/oracle/product/19.0.0.0/lib/libra.so, ENV=(RA_WALLET='location=file:/u01/app/oracle/WALLETS/ORCL/geral credential_alias=dr_ra01')";
allocate AUXILIARY channel x4 DEVICE TYPE 'SBT_TAPE' PARMS "SBT_LIBRARY=/u01/app/oracle/product/19.0.0.0/lib/libra.so, ENV=(RA_WALLET='location=file:/u01/app/oracle/WALLETS/ORCL/geral credential_alias=dr_ra01')";
allocate AUXILIARY channel x5 DEVICE TYPE 'SBT_TAPE' PARMS "SBT_LIBRARY=/u01/app/oracle/product/19.0.0.0/lib/libra.so, ENV=(RA_WALLET='location=file:/u01/app/oracle/WALLETS/ORCL/geral credential_alias=dr_ra01')";
allocate AUXILIARY channel x6 DEVICE TYPE 'SBT_TAPE' PARMS "SBT_LIBRARY=/u01/app/oracle/product/19.0.0.0/lib/libra.so, ENV=(RA_WALLET='location=file:/u01/app/oracle/WALLETS/ORCL/geral credential_alias=dr_ra01')";
allocate AUXILIARY channel x7 DEVICE TYPE 'SBT_TAPE' PARMS "SBT_LIBRARY=/u01/app/oracle/product/19.0.0.0/lib/libra.so, ENV=(RA_WALLET='location=file:/u01/app/oracle/WALLETS/ORCL/geral credential_alias=dr_ra01')";
allocate AUXILIARY channel x8 DEVICE TYPE 'SBT_TAPE' PARMS "SBT_LIBRARY=/u01/app/oracle/product/19.0.0.0/lib/libra.so, ENV=(RA_WALLET='location=file:/u01/app/oracle/WALLETS/ORCL/geral credential_alias=dr_ra01')";
duplicate database ORDB to ORCL
NOFILENAMECHECK;
}
Finally, we will configure the environment for a 2-node cluster.
Connected to sqlplus in the source environment, change the following parameters:
sqlplus "/as sysdba"
alter system set cluster_database_instances=2 scope=spfile sid='*';
alter system set cluster_database=true scope=spfile sid='*';
Configure the parameters that were previously removed or commented out, for the cluster configurations:
alter system set cluster_interconnects='10.0.0.1' scope=spfile sid='orcl01';
alter system set cluster_interconnects='10.0.0.2' scope=spfile sid='orcl02';
alter system set instance_number=1 scope=spfile sid='orcl01';
alter system set instance_number=2 scope=spfile sid='orcl02';
alter system set thread=1 scope=spfile sid='orcl01';
alter system set thread=2 scope=spfile sid='orcl02';
alter system set undo_tablespace='UNDOTBS2' scope=spfile sid='orcl02';
Note: Make sure to verify the exact name of the UNDO in the source environment to modify this parameter, as mentioned at the beginning of this article.
At the operating system prompt:
srvctl stop database -d orcl
Connect to asmcmd and move the spfile parameter file back into ASM, then modify the cluster’s initialization configuration. Finally, start the database:
asmcmd
cp /u01/app/oracle/product/19.0.0.0/dbs/spfileorcl01.ora +DGAUX/spfileorcl01.ora
Then
srvctl modify database -d orcl -spfile +DATA/spfileorcl01.ora
srvctl start database -d orcl
Adjust block change tracking if necessary.