My friend Øyvind Isene suggested that I store a DUPLICATE RMAN script that works in a safe place in this tweet.
@yvelik Me too, then I store the script in a safe place :-) Duplicate jobs reminds me how important it is to practice restore.
— Øyvind Isene (@OyvindIsene) July 1, 2013
I couldn’t find a safer place for the script than the Pythian blog :). Here goes the DUPLICATE DATABASE … from an ACTIVE DATABASE script that works for me beautifully.
I like the fact that we don’t need to worry about any time-consuming tasks anymore. For example, you don’t need the init.ora parameter on the destination side. Oracle creates it all for us. If you want to change any parameters (e.g. reduce memory footprint), you just specify it within the DUPLICATE command (e.g. set sga_target=4G).
Version = 184.108.40.206 on both sides
Source db = prod
Destination db = test
On the source (prod):
— tns aliases to be created to point to prod and test databases
On the destination (test):
— the same version of Oracle SW installed
— directory structure created
— copy $ORACLE_HOME/dbs/orapwprod (from prod) to $ORACLE_HOME/dbs/orapwtest
— configure static listener configuration (allow you to connect as sysdba from prod)
— start an empty test instance “export ORACLE_HOME=….; export ORACLE_SID=….; sqlplus => statup nomount;”
– No SPFILE is needed. It will be taken case of while running DUPLICATE.
– Prod db files are located under /u01/oradata/prod.
– Test db files to be located under /u02/oradata/test.
– It doesn’t matter from where you execute the command (prod or test).
cat run_active_duplicate_prod_test_01.sh . prod.env echo $ORACLE_HOME $ORACLE_SID $TNS_ADMIN export NLS_DATE_FORMAT="YYYY/MM/DD HH24:MI:SS" rman TARGET sys/[email protected] AUXILIARY sys/[email protected] DUPLICATE DATABASE TO test FROM ACTIVE DATABASE SPFILE parameter_value_convert 'prod','test' set db_file_name_convert='u01/oradata/prod','u02/oradata/test' set log_file_name_convert='u01/oradata/prod','u02/oradata/test' set control_files='/u02/oradata/test/cntrl01.dbf'; EOF
nohup ./run_active_duplicate_prod_test_01.sh 2>&1 \ 1>./run_active_duplicate_prod_test_01.`date +%Y%m%d_%H%M%S`.log & ls -lptr ./run_active_duplicate_prod_test_01.`date +%Y%m%d_%H%M%S`.log
tail -f ./run_active_duplicate_prod_test_01.*.log
contents of Memory Script:
Alter clone database open resetlogs;
executing Memory Script
Finished Duplicate Db at 2013/07/01 05:42:30
Recovery Manager complete.
Great post Yury, the only thing that I would make an emphasis on whoever uses this method and is in a RAC environment, make sure to shutdown the static listener after and just use this for the DUPLICATE. I’ve seen in the past conflicts with this, as people leave the static listener and share the tns entry of the static listener, making connections to this , instead of the scan listener.
Agree. RAC is slightly more complex case and need to bit more care.
Cool stuff Yury! Do we need leading ‘/’ here u01/oradata/prod ?
Nope. There is no mistake. As both prod and test have leading “/” in the path we don’t need to specify it in convert parameters. it is enough to specify the patterns to be replaced only (different parts of the string).
Thank you Yury, i got enlightenment by read your post.
Oh.. another thing is when you get RMAN-05001 don’t panic. its not error, oracle RMAN just want to show you that your path for convert is wrong path for the source. follow path on message cause its the true path.
Thank you Yury, it does spent me a day for process duplication.