RMAN CLONING



RMAN CLONINGUsing Recovery CatalogRahmath Khan PatanThe document has been prepared by taking into consideration the below mentioned details. Target DBRecovery CatalogAuxiliary DBServer I.P’s192.168.0.11(PC:11)192.168.0.9(PC:9)192.168.0.10(PC:10)DB NameproddbrcdbauxdbListener &TNS namesproddbrcdbauxdbIn this document, we have taken three servers as aboveTarget DB = Database which is to be clonedRecovery Catalog = A database/repository of backup information of all the databases registered with RMANAuxiliary DB = A cloned copy of the Target database.Note: Recovery Catalog DB can be either be created on a separate system (as in real time) or can be created in the target system itself.Follow the below steps to clone a Production DB (proddb) to an Auxiliary DB (auxdb) using a Recovery Catalog DB (rcdb).Step-1:First create a Recovery Catalog DB on 192.168.0.9 server using DBCA with DB_name and SID as ‘rcdb’.Using Netca or manually editing the listener.ora file, configure a Listener by name ‘rcdb’ [oracle@PC:09 ~] $ cd $ORACLE_HOME/network/admin[oracle@PC:09 admin] $ vi listener.ora RCDB = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.9)(PORT = 1521)) ) ) )SID_LIST_RCDB = (SID_LIST = (SID_DESC = (ORACLE_HOME =/u01/oracle/ora10g_home/) (SID_NAME =RCDB) ) )Now, using Netca or manually editing the tnsnames.ora file, configure 3 TNS entries, each for Target DBRecovery CatalogAuxiliary DB with different port numbers. [oracle@PC:09 admin] $ vi tnsnames.ora RCDB = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.9)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME =RCDB) ) ) PRODDB = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.11)(PORT = 1522)) ) (CONNECT_DATA = (SERVICE_NAME =PRODDB) )AUXDB = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.10)(PORT = 1523)) ) (CONNECT_DATA = (SERVICE_NAME =AUXDB) )Then, export the ORACLE_SID and login to sqlplus as sysdba[oracle@PC:09 ~]$ export ORACLE_SID=rcdb[oracle@PC:09 ~]$ sqlplus / as sysdbaSQL> startupCheck and confirm whether you are logged into the Recovery Catalog DBSQL> select instance_name from v$instance;SQL> select name from v$database;Now, create a user for recovery catalog , create and assign a default tablespace and temporary tablespace for that user.First …. let’s create a default tablespace,SQL> create tablespace rctbs datafile ‘/u01/oracle/oradata/rctbs01.dbf’ size 100m;SQL> create user rcuser identified by rc123 default tablespace rctbs temporary tablespace temp quota unlimited on rctbs;Grant the user with connect, resource and recovery catalog ownership privileges.SQL> grant connect, resource, recovery_catalog_owner to rcuser;SQL>exitNow, connect to RMAN using with the new user created above.[oracle@PC:09 ~] $ RMAN catalog rcuser/rc123You will be seeing the RMAN prompt as soon as you hit enter after the above line.RMAN> Create a catalog to store all the backup information of all the databases in it.RMAN> create catalog;Catalog createdRMAN> exitSTEP-2:Goto Target database server 192.168.0.11, (i.e proddb) and using Netca, configure a listener for the prodbd database.[oracle@PC:11 ~] $ cd $ORACLE_HOME/network/admin[oracle@PC:11 admin] $ vi listener.ora PRODDB = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.11)(PORT = 1522)) ) ) ) SID_LIST_PRODDB = (SID_LIST = (SID_DESC = (ORACLE_HOME =/u01/oracle/ora10g_home/) (SID_NAME = PRODDB) ) ) Configure TNS entries for each of the databases given belowTarget DBRecovery CatalogAuxiliary Database[oracle@PC:11 admin] $ vi tnsnames.ora RCDB = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.9)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME =RCDB) ) ) PRODDB = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.11)(PORT = 1522)) ) (CONNECT_DATA = (SERVICE_NAME =PRODDB) )AUXDB = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.10)(PORT = 1523)) ) (CONNECT_DATA = (SERVICE_NAME =AUXDB) ) Now, create a directory in another mount point say ‘/u02’ for storing the backup of the Target Database taken through RMAN [oracle@PC:11 ~]$ cd /u02 [oracle@PC:10 /u02] $ mkdir rmanbkp Note: Create a similar directory on similar mount point in the Auxilary Database server because RMAN uses a centralized location to access the backups of the databases. STEP-3: Goto the Auxiliary DB server 192.168.0.10 (i.e auxdb), create a listener and 3 TNS entries each for the below mentioned databases same like you have created before.Target DBRecovery Catalog DBAuxiliary DBYou can use Oracle’s Netca to configure listener and TNS names for the databases but in this document, i have configured them by editing the listener.ora and tnsnames.ora files and making the entries manually.[oracle@PC:10 ~] $ cd $ORACLE_HOME/network/admin[oracle@PC:10 admin] $ vi listener.ora AUXDB = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.11)(PORT = 1523)) ) ) ) SID_LIST_AUXDB = (SID_LIST = (SID_DESC = (ORACLE_HOME =/u01/oracle/ora10g_home/) (SID_NAME = AUXDB) ) )ConfigureTNS Entries in tnsnames.ora file:[oracle@PC:10 admin]$ vi tnsnames.ora RCDB = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.9)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME =RCDB) ) ) PRODDB = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.11)(PORT = 1522)) ) (CONNECT_DATA = (SERVICE_NAME =PRODDB) )AUXDB = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.10)(PORT = 1523)) ) (CONNECT_DATA = (SERVICE_NAME =AUXDB) )Note: To make it easy for you, just copy the entries in any one of the tnsnames.ora file and paste it into the tnsnames.ora file of other two databases. Then, you are done with configuring the TNS names.The purpose of configuring the LISTENER and TNSNAMES for each and every database is to access the all the three databases from any of the servers using the concept of Networking in ORACLE.Do TNSPING <SID> to all the 3 databases to check the connection is working fine or notSTEP-4:-The next step is to register the Target database with the RMAN for storing the backup information of proddb in a central repository called Recovery Catalog.-As we have configured listeners and tnsnames for all the three databases, we can connect to RMAN from any of the three databases using RMAN commands.-In this document i have chosen to connect to RMAN from the Target DB server.-The below command connects to Target DB as SYS user and Recovery Catalog as ‘rcuser’ using a connecting string rcdb[oracle@PC:11 ~] $ RMAN target / catalog rcuser/rc123@rcdb RMAN>-This command registers the Target Database with RMAN and hence forth any backup taken on Target DB gets registered in the Recovery Catalog RMAN> register database;-Take backup of the Target database (proddb). RMAN> backup format=’/u02/rmanbkp/prodfull_%t.bkp’ database plus archivelog; RMAN> exitGoto Auxiliary database server and create a directory ‘rmanbkp’ on ‘/u02’ mount point of the Auxiliary database.[oracle@PC:10 ~] $ cd /u02[oracle@PC:10 u02] $ mkdir rmanbkpNow…go back to Target database’s RMAN backup storage location i.e /u02/rmanbkp and copy all the backup files to the directory created in previous step on Auxiliary Database.[oracle@PC:11 rmanbkp] $ scp *.bkp oracle@192.168.0.10:/u02/rmanbkp/All the backup files are copied to the rman backup location on Auxiliary database.In the same way, goto $ORACLE_HOME/dbs location on Target database and copy and rename the pfile of proddb (i.e initproddb.ora) to the similar location on Auxiliary database.[PC:11 dbs]$ scp initproddb.ora oracle@192.168.0.10:/$ORACLE_HOME/dbs/initauxdb.ora STEP-5: After copying the pfile, goto the pfile location on Auxiliary database and edit it as below [oracle@PC:10 dbs]$ vi initauxdb.ora Edit and modify the following entries: Change all the occurrences of ‘prodb’ to ‘auxdb’ by using below command in vi editor:%s/proddb/auxdb/g Change the ORACLE_HOME, ORADATA(for datafiles) and dump locations in the pfile to the locations as per the locations in Auxiliary Database Add the below two lines at the end of the pfile*.db_file_name_convert=(‘/u01/oradata/proddb’, ‘/u01/oradata/auxdb)*.log_file_name_convert=(‘/u01/oradata/proddb’, ‘/u01/oradata/auxdb)The above commands are used to convert the filename of a new datafile on the Target database to a filename on the Auxiliary databaseNote: If you have multiplexed copies of redolog files, then make one more entry of ‘log_file_name_convert’ with the multiplexed location of Target Database and Auxiliary database.For Ex: log_file_name_convert=(‘/u02/oradata/proddb’, ‘/u02/oradata/auxdb’) Changes the archives location to the new archives location of the Auxiliary database.Now, create the directories in the Auxiliary database for datafiles, dump files and archives as specified in the pfile. [oracle@PC:10 ~]$ cd $ORACLE_HOME/admin[oracle@PC:10 admin]$ mkdir auxdb[oracle@PC:10 admin]$ cd auxdb---- For dump folders[oracle@PC:10 auxdb]$ mkdir adump bdump cdump udump [oracle@PC:10 admin]$ cd /u01/oradata[oracle@PC:10 oradata]$ mkdir auxdb---- For datafiles[oracle@PC:10 oradata]$ cd /u02[oracle@PC:10 u02]$ mkdir archives----- For Archive log filesAs everything is in place now, we go ahead and login into sqlplus using SYS user and startup the ‘auxdb’ database in nomount phase and then connect to RMAN for duplicating the Target database to Auxiliary database using the RMAN backup stored in ‘/u02/rmanbkkp’ folder.Before that,[oracle@PC:10 ~]$ export ORACLE_SID=auxdb[oracle@PC:10 ~]$ sqlplus / as sysdba SQL> startpup nomountSQL> exitExit from the sqlplus after the database is into nomount phase and then orapwd file for the Auxiliary database[oracle@PC:10 ~]$ cd $ORACLE_HOME/dbs[oracle@PC:10 dbs]$ orapwd file=orapwauxdb password=aux123 entries=5[oracle@PC:10 ~]$Note: Here if you try connecting to RMAN might end up with a error saying“rman: can’t open target”Don’t get annoyed with it…this is due to $PATH variable not been set properly. Just follow below steps and set the PATH variable for a smooth sailing into RMAN[oracle@PC:10 ~]$ echo $PATHWhat ever path displays on the screen, edit it and remove “/usr/X11R6/bin” and set the PATH[oracle@PC:10 ~]$ export <PATH - /usr/X11R6/bin> Now, connect to RMAN using all the 3 database’s Users and Connecting Strings…so that you are connected to Target Database(proddb)Recovery Catalog (rcdb) and Auxiliary Database (auxdb – nomount phase)[oracle@PC:10 ~]$ RMAN target sys/oracle@proddb catalog rcuser/rc123@rcdb auxiliary sys/aux123@auxdbRecovery Manager: Release 10.2.0.1.0 - Production on Sat Apr 14 18:29:27 2012 Copyright (c) 1982, 2005, Oracle. All rights reserved. connected to target database: ORCL (DBID=1308049214) connected to recovery catalog database connected to auxiliary database: AUXDB (not mounted) RMAN> duplicate target database to auxdb;Once the duplication is Finished, exit from RMANRMAN> exitAfter finish, the database is opened with RESETLOGS option by RMAN.Now, Login to sqlplus and check the instance name and database name[oracle@PC:10 ~]$ sqlplus / as sysdbaSQL> select instance_name from v$instance;Instance Name--------------------AUXDBSQL> select name from v$database;Name______AUXDBFinally, you have successfully cloned the proddb database on 192.168.0.11 server to the auxdb database on 192.168.0.10 server using RMAN backup and Recovery Catalog.====================== {@} Congratulations {@} ==========================For Your Information:Once you execute the DUPLICATE database command, RMAN will collect the backup files from ‘/u02/rmanbkp’ location and start cloning the proddb database on to the auxdb database with the file locations and parameters set in the pfile.I’m posting here the complete transcript of the RMAN cloning execution displayed on the screen after executing the DUPLICATE database command[oracle@oracle dbs]$ rman target sys/oracle@orcl catalog rcuser/rc123@rcdb auxiliary sys/aux123Recovery Manager: Release 10.2.0.1.0 - Production on Sat Apr 14 18:29:27 2012Copyright (c) 1982, 2005, Oracle. All rights reserved.connected to target database: ORCL (DBID=1308049214)connected to recovery catalog databaseconnected to auxiliary database: AUXDB (not mounted)RMAN> duplicate target database to auxdb;Starting Duplicate Db at 14-APR-12starting full resync of recovery catalogfull resync completeusing channel ORA_AUX_DISK_1contents of Memory Script:{ set until scn 590638; set newname for datafile 1 to "/u01/oracle/ora10g_home/product/oradata/auxdb/system01.dbf"; set newname for datafile 2 to "/u01/oracle/ora10g_home/product/oradata/auxdb/undotbs01.dbf"; set newname for datafile 3 to "/u01/oracle/ora10g_home/product/oradata/auxdb/sysaux01.dbf"; set newname for datafile 4 to "/u01/oracle/ora10g_home/product/oradata/auxdb/users01.dbf"; set newname for datafile 5 to "/u01/oracle/ora10g_home/product/oradata/auxdb/example01.dbf"; restore check readonly clone database ;}executing Memory Scriptexecuting command: SET until clauseexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEStarting restore at 14-APR-12using channel ORA_AUX_DISK_1channel ORA_AUX_DISK_1: starting datafile backupset restorechannel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup setrestoring datafile 00001 to /u01/oracle/ora10g_home/product/oradata/auxdb/system01.dbfrestoring datafile 00002 to /u01/oracle/ora10g_home/product/oradata/auxdb/undotbs01.dbfrestoring datafile 00003 to /u01/oracle/ora10g_home/product/oradata/auxdb/sysaux01.dbfrestoring datafile 00004 to /u01/oracle/ora10g_home/product/oradata/auxdb/users01.dbfrestoring datafile 00005 to /u01/oracle/ora10g_home/product/oradata/auxdb/example01.dbfchannel ORA_AUX_DISK_1: reading from backup piece /u02/rmanbkp/orclfull_780603436.bkpchannel ORA_AUX_DISK_1: restored backup piece 1piece handle=/u02/rmanbkp/orclfull_780603436.bkp tag=TAG20120414T181716channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:26Finished restore at 14-APR-12sql statement: CREATE CONTROLFILE REUSE SET DATABASE "AUXDB" RESETLOGS ARCHIVELOG MAXLOGFILES 16 MAXLOGMEMBERS 3 MAXDATAFILES 100 MAXINSTANCES 8 MAXLOGHISTORY 292 LOGFILE GROUP 1 ( '/u01/oracle/ora10g_home/product/oradata/auxdb/redo01.log' ) SIZE 50 M REUSE, GROUP 2 ( '/u01/oracle/ora10g_home/product/oradata/auxdb/redo02.log' ) SIZE 50 M REUSE, GROUP 3 ( '/u01/oracle/ora10g_home/product/oradata/auxdb/redo03.log' ) SIZE 50 M REUSE DATAFILE '/u01/oracle/ora10g_home/product/oradata/auxdb/system01.dbf' CHARACTER SET AL32UTF8contents of Memory Script:{ switch clone datafile all;}executing Memory Scriptreleased channel: ORA_AUX_DISK_1datafile 2 switched to datafile copyinput datafile copy recid=1 stamp=780604638 filename=/u01/oracle/ora10g_home/product/oradata/auxdb/undotbs01.dbfdatafile 3 switched to datafile copyinput datafile copy recid=2 stamp=780604638 filename=/u01/oracle/ora10g_home/product/oradata/auxdb/sysaux01.dbfdatafile 4 switched to datafile copyinput datafile copy recid=3 stamp=780604638 filename=/u01/oracle/ora10g_home/product/oradata/auxdb/users01.dbfdatafile 5 switched to datafile copyinput datafile copy recid=4 stamp=780604639 filename=/u01/oracle/ora10g_home/product/oradata/auxdb/example01.dbfcontents of Memory Script:{ set until scn 590638; recover clone database delete archivelog ;}executing Memory Scriptexecuting command: SET until clauseStarting recover at 14-APR-12allocated channel: ORA_AUX_DISK_1channel ORA_AUX_DISK_1: sid=159 devtype=DISKstarting media recoverychannel ORA_AUX_DISK_1: starting archive log restore to default destinationchannel ORA_AUX_DISK_1: restoring archive logarchive log thread=1 sequence=15channel ORA_AUX_DISK_1: reading from backup piece /u02/rmanbkp/orclfull_780603484.bkpchannel ORA_AUX_DISK_1: restored backup piece 1piece handle=/u02/rmanbkp/orclfull_780603484.bkp tag=TAG20120414T181804channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01archive log filename=/u01/oracle/ora10g_home/product/flash_recovery_area/AUXDB/archivelog/2012_04_14/o1_mf_1_15_7rlxnfv3_.arc thread=1 sequence=15channel clone_default: deleting archive log(s)archive log filename=/u01/oracle/ora10g_home/product/flash_recovery_area/AUXDB/archivelog/2012_04_14/o1_mf_1_15_7rlxnfv3_.arc recid=1 stamp=780604645media recovery complete, elapsed time: 00:00:04Finished recover at 14-APR-12contents of Memory Script:{ shutdown clone; startup clone nomount ;}executing Memory Scriptdatabase dismountedOracle instance shut downconnected to auxiliary database (not started)Oracle instance startedTotal System Global Area 285212672 bytesFixed Size 1218992 bytesVariable Size 104859216 bytesDatabase Buffers 176160768 bytesRedo Buffers 2973696 bytessql statement: CREATE CONTROLFILE REUSE SET DATABASE "AUXDB" RESETLOGS ARCHIVELOG MAXLOGFILES 16 MAXLOGMEMBERS 3 MAXDATAFILES 100 MAXINSTANCES 8 MAXLOGHISTORY 292 LOGFILE GROUP 1 ( '/u01/oracle/ora10g_home/product/oradata/auxdb/redo01.log' ) SIZE 50 M REUSE, GROUP 2 ( '/u01/oracle/ora10g_home/product/oradata/auxdb/redo02.log' ) SIZE 50 M REUSE, GROUP 3 ( '/u01/oracle/ora10g_home/product/oradata/auxdb/redo03.log' ) SIZE 50 M REUSE DATAFILE '/u01/oracle/ora10g_home/product/oradata/auxdb/system01.dbf' CHARACTER SET AL32UTF8contents of Memory Script:{ set newname for tempfile 1 to "/u01/oracle/ora10g_home/product/oradata/auxdb/temp01.dbf"; switch clone tempfile all; catalog clone datafilecopy "/u01/oracle/ora10g_home/product/oradata/auxdb/undotbs01.dbf"; catalog clone datafilecopy "/u01/oracle/ora10g_home/product/oradata/auxdb/sysaux01.dbf"; catalog clone datafilecopy "/u01/oracle/ora10g_home/product/oradata/auxdb/users01.dbf"; catalog clone datafilecopy "/u01/oracle/ora10g_home/product/oradata/auxdb/example01.dbf"; switch clone datafile all;}executing Memory Scriptexecuting command: SET NEWNAMErenamed temporary file 1 to /u01/oracle/ora10g_home/product/oradata/auxdb/temp01.dbf in control filecataloged datafile copydatafile copy filename=/u01/oracle/ora10g_home/product/oradata/auxdb/undotbs01.dbf recid=1 stamp=780604665cataloged datafile copydatafile copy filename=/u01/oracle/ora10g_home/product/oradata/auxdb/sysaux01.dbf recid=2 stamp=780604665cataloged datafile copydatafile copy filename=/u01/oracle/ora10g_home/product/oradata/auxdb/users01.dbf recid=3 stamp=780604665cataloged datafile copydatafile copy filename=/u01/oracle/ora10g_home/product/oradata/auxdb/example01.dbf recid=4 stamp=780604666datafile 2 switched to datafile copyinput datafile copy recid=1 stamp=780604665 filename=/u01/oracle/ora10g_home/product/oradata/auxdb/undotbs01.dbfdatafile 3 switched to datafile copyinput datafile copy recid=2 stamp=780604665 filename=/u01/oracle/ora10g_home/product/oradata/auxdb/sysaux01.dbfdatafile 4 switched to datafile copyinput datafile copy recid=3 stamp=780604665 filename=/u01/oracle/ora10g_home/product/oradata/auxdb/users01.dbfdatafile 5 switched to datafile copyinput datafile copy recid=4 stamp=780604666 filename=/u01/oracle/ora10g_home/product/oradata/auxdb/example01.dbfcontents of Memory Script:{ Alter clone database open resetlogs;}executing Memory Scriptdatabase openedFinished Duplicate Db at 14-APR-12 ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download