PRODUCTION : MACHINE DB31
CLONE : MACHINE DB32
MACHINE DB32 CLONE:
——————
1) Create Directory CLONE
————————-
[oracle@db32 ~]$ cd /u01 [oracle@db32 u01]$ ls [oracle@db32 u01]$ mkdir clone
2) Create Pfile for Clone:
————————–
[oracle@db32 ~]$ cd $ORACLE_HOME/dbs [oracle@db32 dbs]$ vi initclone.ora *.db_name=CLONE *.control_files='/u01/app/oracle/oradata/CLONE/control01.ctl','/u01/app/oracle/flash_recovery_area/clone/control02.ctl' *.db_recovery_file_dest_size=4g *.db_recovery_file_dest='/u01/app/oracle/flash_recovery_area' *.db_file_name_convert='/u01/app/oracle/oradata/test','/u01/app/oracle/oradata/CLONE/' *.log_file_name_convert='/u01/app/oracle/oradata/test','/u01/app/oracle/oradata/CLONE/'
3) Create password file Clone:
——————————
[oracle@db32 dbs]$ orapwd file=orapwclone password=manager force=y
4) create directory which is mentioned in your pfile:
—————————————————–
/u01/app/oracle/flash_recovery_area/clone (create clone directory)
MACHINE DB32 CLONE:
——————
5) create listener and tns by NETCA Clone Side:
———————————————-
i) Listener Name: list_col ii) Tns Name: toclone
6) register created listener by NETMGR
————————————–
MACHINE DB31 PRODUCTION:
————————
7) create listener and tns by NETCA
i) Listner Name: list ii) Tns Name: toprod
8) register created listener by NETMGR
MACHINE DB31 PRODUCTION:
————————
9) copy paste listener and tns for each other : prod & clone
/u01/app/oracle/product/11.2.0/dbhome_1/network/admin [oracle@db31 admin]$ vi listener.ora [oracle@db31 admin]$ vi tnsnames.ora
MACHINE DB32 CLONE:
——————
10) copy paste listener and tns for each other : prod & clone
cd /u01/app/oracle/product/11.2.0/dbhome_1/network/admin [oracle@db32 admin]$ vi listener.ora [oracle@db32 admin]$ vi tnsnames.ora
11) Check Connectivity:
ping tns (tnspingtoclone) (tnspingtoprod) rman target sys/manager@toclone rman target sys/manager@toprod
MACHINE DB31 PRODUCTION:
———————–
12) Check connectivity:
ping tns (tnspingtoclone) (tnspingtoprod) Rman>rman target sys/manager@toclone Rman>rman target sys/manager@toprod
13) Enable archive log:
———————–
SQL> alter database archivelog; Database altered. SQL> alter database open; Database altered. SQL> alter system switch logfile; System altered. SQL> archive log list; Database log mode Archive Mode Automatic archival Enabled Archive destination USE_DB_RECOVERY_FILE_DEST Oldest online log sequence 13 Next log sequence to archive 15 Current log sequence 15
14) Connect RMAN :
—————–
[oracle@db31 ~]$ rman target/ RMAN> show all; RMAN> configure controlfile autobackup on;
15) take database backup through RMAN :
—————————————
RMAN> backup database include current controlfile plus archivelog; Starting backup at 23-JAN-19 current log archived allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=27 device type=DISK channel ORA_DISK_1: starting archived log backup set channel ORA_DISK_1: specifying archived log(s) in backup set input archived log thread=1 sequence=4 RECID=1 STAMP=952712839 channel ORA_DISK_1: starting piece 1 at 23-JAN-19 channel ORA_DISK_1: finished piece 1 at 23-JAN-19 piece handle=/u01/app/oracle/flash_recovery_area/PROD/backupset/2019_01_21/o1_mf_annnn_TAG20170822T182720_dsrbkjxj_.bkp tag=TAG20170822T182720 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01 Finished backup at 23-JAN-19 Starting backup at 23-JAN-19 using channel ORA_DISK_1 channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set input datafile file number=00001 name=/u01/app/oracle/oradata/prod/system01.dbf input datafile file number=00002 name=/u01/app/oracle/oradata/prod/sysaux01.dbf input datafile file number=00003 name=/u01/app/oracle/oradata/prod/undotbs01.dbf input datafile file number=00004 name=/u01/app/oracle/oradata/prod/users01.dbf channel ORA_DISK_1: starting piece 1 at 23-JAN-19 channel ORA_DISK_1: finished piece 1 at 23-JAN-19 piece handle=/u01/app/oracle/flash_recovery_area/PROD/backupset/2019_01_21/o1_mf_nnndf_TAG20170822T182722_dsrbkzmj_.bkp tag=TAG20170822T182722 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:08:28 channel ORA_DISK_1: starting full datafile backup set channel ORA_DISK_1: specifying datafile(s) in backup set including current control file in backup set channel ORA_DISK_1: starting piece 1 at 23-JAN-19 channel ORA_DISK_1: finished piece 1 at 23-JAN-19 piece handle=/u01/app/oracle/flash_recovery_area/PROD/backupset/2019_01_21/o1_mf_ncnnf_TAG20170822T182722_dsrc1mfn_.bkp tag=TAG20170822T182722 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01 Finished backup at 23-JAN-19 Starting backup at 23-JAN-19 current log archived using channel ORA_DISK_1 channel ORA_DISK_1: starting archived log backup set channel ORA_DISK_1: specifying archived log(s) in backup set input archived log thread=1 sequence=5 RECID=2 STAMP=952713357 channel ORA_DISK_1: starting piece 1 at 23-JAN-19 channel ORA_DISK_1: finished piece 1 at 23-JAN-19 piece handle=/u01/app/oracle/flash_recovery_area/PROD/backupset/2019_01_21/o1_mf_annnn_TAG20170822T183557_dsrc1p1c_.bkp tag=TAG20170822T183557 comment=NONE channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01 Finished backup at 23-JAN-19 Starting Control File and SPFILE Autobackup at 23-JAN-19 piece handle=/u01/app/oracle/flash_recovery_area/PROD/autobackup/2019_01_21/o1_mf_s_952713359_dsrc1qyr_.bkp comment=NONE Finished Control File and SPFILE Autobackup at 23-JAN-19
16) Go flash_recover_area
————————–
[oracle@db31 ~]$ cd /u01/app/oracle/flash_recovery_area/ [oracle@db31 flash_recovery_area]$ scp -r PROD oracle@192.168.139.32:/u01/app/oracle/flash_recovery_area/ oracle@192.168.139.32's password: o1_mf_annnn_TAG20170822T183557_dsrc1p1c_.bkp 100% 143KB 142.5KB/s 00:00 o1_mf_ncnnf_TAG20170822T182722_dsrc1mfn_.bkp 100% 9568KB 9.3MB/s 00:01 o1_mf_nnndf_TAG20170822T182722_dsrbkzmj_.bkp 100% 1060MB 2.6MB/s 06:42 o1_mf_annnn_TAG20170822T182720_dsrbkjxj_.bkp 100% 4222KB 4.1MB/s 00:01 o1_mf_1_5_dsrc1o50_.arc 100% 141KB 141.0KB/s 00:00 o1_mf_1_4_dsrbkhmp_.arc 100% 4220KB 602.9KB/s 00:07 o1_mf_s_952713359_dsrc1qyr_.bkp 100% 9600KB 4.7MB/s 00:02
MACHINE DB32 CLONE:
[oracle@db32 ~]$ export ORACLE_SID=clone [oracle@db32 ~]$ sqlplus / as sysdba SQL> startup nomount RMAN> rman target sys/manager@toprod auxiliary sys/manager@toclone connected to target database: PROD (DBID=364534697) connected to auxiliary database: CLONE (not mounted) RMAN> duplicate target database to 'CLONE' Nofilenamecheck; Starting Duplicate Db at 23-JAN-19 using channel ORA_AUX_DISK_1 contents of Memory Script: { sql clone "alter system set db_name = ''CLONE'' comment= ''Modified by RMAN duplicate'' scope=spfile"; sql clone "alter system set db_unique_name = ''CLONE'' comment= ''Modified by RMAN duplicate'' scope=spfile"; shutdown clone immediate; startup clone force nomount restore clone primary controlfile; alter clone database mount; } executing Memory Script sql statement: alter system set db_name = ''CLONE'' comment= ''Modified by RMAN duplicate'' scope=spfile sql statement: alter system set db_unique_name = ''CLONE'' comment= ''Modified by RMAN duplicate'' scope=spfile Oracle instance shut down Oracle instance started Total System Global Area 631914496 bytes Fixed Size 1338364 bytes Variable Size 377488388 bytes Database Buffers 247463936 bytes Redo Buffers 5623808 bytes Starting restore at 23-JAN-19 allocated channel: ORA_AUX_DISK_1 channel ORA_AUX_DISK_1: SID=18 device type=DISK channel ORA_AUX_DISK_1: starting datafile backup set restore channel ORA_AUX_DISK_1: restoring control file channel ORA_AUX_DISK_1: reading from backup piece /u01/app/oracle/flash_recovery_area/CLONE/autobackup/2013_01_27/o1_mf_s_805812962_8j9onctk_.bkp channel ORA_AUX_DISK_1: piece handle=/u01/app/oracle/flash_recovery_area/CLONE/autobackup/2013_01_27/o1_mf_s_805812962_8j9onctk_.bkp tag=TAG20130127T125602 channel ORA_AUX_DISK_1: restored backup piece 1 channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03 output file name=/u01/app/oracle/oradata/CLONE/control01.ctl output file name=/u01/app/oracle/flash_recovery_area/CLONE/control02.ctl Finished restore at 23-JAN-19 database mounted contents of Memory Script: { set until scn 763666; set newname for datafile 1 to "/u01/app/oracle/oradata/CLONE/system01.dbf"; set newname for datafile 2 to "/u01/app/oracle/oradata/CLONE/sysaux01.dbf"; set newname for datafile 3 to "/u01/app/oracle/oradata/CLONE/undotbs01.dbf"; set newname for datafile 4 to "/u01/app/oracle/oradata/CLONE/users01.dbf"; restore clone database ; } executing Memory Script executing command: SET until clause executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME Starting restore at 23-JAN-19 using channel ORA_AUX_DISK_1 channel ORA_AUX_DISK_1: starting datafile backup set restore channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set channel ORA_AUX_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/CLONE/system01.dbf channel ORA_AUX_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/CLONE/sysaux01.dbf channel ORA_AUX_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/CLONE/undotbs01.dbf channel ORA_AUX_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/CLONE/users01.dbf channel ORA_AUX_DISK_1: reading from backup piece /u01/app/oracle/flash_recovery_area/CLONE/backupset/2013_01_27/o1_mf_nnndf_TAG20130127T125432_8j9okjyl_.bkp channel ORA_AUX_DISK_1: piece handle=/u01/app/oracle/flash_recovery_area/CLONE/backupset/2013_01_27/o1_mf_nnndf_TAG20130127T125432_8j9okjyl_.bkp tag=TAG20130127T125432 channel ORA_AUX_DISK_1: restored backup piece 1 channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:22 Finished restore at 23-JAN-19 contents of Memory Script: { switch clone datafile all; } executing Memory Script datafile 1 switched to datafile copy input datafile copy RECID=1 STAMP=805814774 file name=/u01/app/oracle/oradata/CLONE/system01.dbf datafile 2 switched to datafile copy input datafile copy RECID=2 STAMP=805814774 file name=/u01/app/oracle/oradata/CLONE/sysaux01.dbf datafile 3 switched to datafile copy input datafile copy RECID=3 STAMP=805814774 file name=/u01/app/oracle/oradata/CLONE/undotbs01.dbf datafile 4 switched to datafile copy input datafile copy RECID=4 STAMP=805814774 file name=/u01/app/oracle/oradata/CLONE/users01.dbf contents of Memory Script: { set until scn 763666; recover clone database delete archivelog ; } executing Memory Script executing command: SET until clause Starting recover at 23-JAN-19 using channel ORA_AUX_DISK_1 starting media recovery archived log for thread 1 with sequence 4 is already on disk as file /u01/app/oracle/flash_recovery_area/CLONE/archivelog/2013_01_27/o1_mf_1_4_8j9on8j1_.arc archived log file name=/u01/app/oracle/flash_recovery_area/CLONE/archivelog/2013_01_27/o1_mf_1_4_8j9on8j1_.arc thread=1 sequence=4 media recovery complete, elapsed time: 00:00:00 Finished recover at 23-JAN-19 contents of Memory Script: { shutdown clone immediate; startup clone nomount; sql clone "alter system set db_name = ''CLONE'' comment= ''Reset to original value by RMAN'' scope=spfile"; sql clone "alter system reset db_unique_name scope=spfile"; shutdown clone immediate; startup clone nomount; } executing Memory Script database dismounted Oracle instance shut down connected to auxiliary database (not started) Oracle instance started Total System Global Area 631914496 bytes Fixed Size 1338364 bytes Variable Size 377488388 bytes Database Buffers 247463936 bytes Redo Buffers 5623808 bytes sql statement: alter system set db_name = ''CLONE'' comment= ''Reset to original value by RMAN'' scope=spfile sql statement: alter system reset db_unique_name scope=spfile Oracle instance shut down connected to auxiliary database (not started) Oracle instance started Total System Global Area 631914496 bytes Fixed Size 1338364 bytes Variable Size 377488388 bytes Database Buffers 247463936 bytes Redo Buffers 5623808 bytes sql statement: CREATE CONTROLFILE REUSE SET DATABASE "CLONE" RESETLOGS ARCHIVELOG MAXLOGFILES 16 MAXLOGMEMBERS 3 MAXDATAFILES 100 MAXINSTANCES 8 MAXLOGHISTORY 292 LOGFILE GROUP 1 SIZE 50 M , GROUP 2 SIZE 50 M , GROUP 3 SIZE 50 M DATAFILE '/u01/app/oracle/oradata/CLONE/system01.dbf' CHARACTER SET WE8MSWIN1252 contents of Memory Script: { set newname for tempfile 1 to "/u01/app/oracle/oradata/CLONE/temp01.dbf"; switch clone tempfile all; catalog clone datafilecopy "/u01/app/oracle/oradata/CLONE/sysaux01.dbf", "/u01/app/oracle/oradata/CLONE/undotbs01.dbf", "/u01/app/oracle/oradata/CLONE/users01.dbf"; switch clone datafile all; } executing Memory Script executing command: SET NEWNAME renamed tempfile 1 to /u01/app/oracle/oradata/CLONE/temp01.dbf in control file cataloged datafile copy datafile copy file name=/u01/app/oracle/oradata/CLONE/sysaux01.dbf RECID=1 STAMP=805814812 cataloged datafile copy datafile copy file name=/u01/app/oracle/oradata/CLONE/undotbs01.dbf RECID=2 STAMP=805814812 cataloged datafile copy datafile copy file name=/u01/app/oracle/oradata/CLONE/users01.dbf RECID=3 STAMP=805814812 datafile 2 switched to datafile copy input datafile copy RECID=1 STAMP=805814812 file name=/u01/app/oracle/oradata/CLONE/sysaux01.dbf datafile 3 switched to datafile copy input datafile copy RECID=2 STAMP=805814812 file name=/u01/app/oracle/oradata/CLONE/undotbs01.dbf datafile 4 switched to datafile copy input datafile copy RECID=3 STAMP=805814812 file name=/u01/app/oracle/oradata/CLONE/users01.dbf contents of Memory Script: { Alter clone database open resetlogs; } executing Memory Script database opened Finished Duplicate Db at 23-JAN-19
RMAN performed the following steps automatically to duplicate the database :
- Allocates automatic auxiliary channel
- Creates a controlfile for the clone database
- Performs an incomplete recovery of the clone database using incremental backups and archived redo log files up to the last backed up archived redo log file.
- Shutdowns the database and opens it using RESETLOGS option.
- Generates a new unique DBID for the clone database.
All file locations were the same as in the production database. However, in case we need to change clone database’s directory structure.
Catch Me On:- Hariprasath Rajaram Telegram:https://t.me/joinchat/I_f4DkeGfZuxgMIoJSpQZg LinkedIn:https://www.linkedin.com/in/hariprasathdba Facebook:https://www.facebook.com/HariPrasathdba FB Group:https://www.facebook.com/groups/894402327369506/ FB Page: https://www.facebook.com/dbahariprasath/? Twitter: https://twitter.com/hariprasathdba