Rman Cloning Db

download Rman Cloning Db

of 4

description

Cloning DB using RMAN Oracle 10g

Transcript of Rman Cloning Db

  • Here is the solution

    ========================

    Applies to: Oracle Server - Enterprise Edition - Version: 10.2.0.0.0Information in this document applies to any platform.

    GoalRestoring a database using rman on a different node with different backup directory structures and different database directory structures .

    - You have a database backed up on NODE 1- You need to restore the database on NODE 2 - The directory structure is different on NODE 2- You need to put the backups in a new directory structure in NODE 2 unlike as they were in NODE 1- You need to restore the database files into a new directory structure in NODE 2 unlike as they were in NODE 1 SolutionBelow is the procedure with an example:

    1) Connect to the target database using rman and backup the database ---> NODE 1

    $ rman target /Recovery Manager: Release 10.2.0.1.0 - Production on Tue Feb 13 00:29:332007Copyright (c) 1982, 2005, Oracle. All rights reserved.connected to target database: ORA10G (DBID=3932056136)RMAN>backup database plus archivelog;Starting backup at 13-FEB-07current log archivedusing channel ORA_DISK_1channelORA_DISK_1: starting archive log backupsetchannel ORA_DISK_1: specifying archive log(s) in backup setinput archive log thread=1sequence=143 recid=109 stamp=614392105channel ORA_DISK_1: starting piece 1 at 13-FEB-07channel ORA_DISK_1: finished piece1 at 13-FEB-07piece handle=/u01/oracle/product/oradata/ora10g/fra/ORA10G/backupset/2007_02_13/o1_mf_annnn_TAG20070213T002825_2x21kbds_.bkptag=TAG20070213T002825 comment=NONEchannel ORA_DISK_1: backup set complete, elapsed time: 00:00:02Finished backup at 13-FEB-07Startingbackup at 13-FEB-07using channel ORA_DISK_1channel ORA_DISK_1: starting full datafile backupsetchannel ORA_DISK_1: specifyingdatafile(s) in backupsetinput datafile fno=00003 name=/u01/oracle/product/oradata/ora10g/data/sysaux01.dbfinput datafilefno=00001 name=/u01/oracle/product/oradata/ora10g/data/system01.dbfinput datafile fno=00002 name=/u01/oracle/product/oradata/ora10g/data/undotbs01.dbfinputdatafile fno=00004 name=/u01/oracle/product/oradata/ora10g/data/users01.dbfinput datafile fno=00005 name=/home/oracle/1.dbfinputdatafile fno=00006 name=/u01/oracle/product/oradata/ora10g/data/sysaux02.dbfinput datafile fno=00007 name=/u01/oracle/product/oradata/ora10g/data/undotbs02.dbfchannelORA_DISK_1: starting piece 1 at 13-FEB-07channel ORA_DISK_1: finished piece 1 at 13-FEB-07piece handle=/u01/oracle/product/oradata/ora10g/fra/ORA10G/backupset/2007_02_13/o1_mf_nnndf_TAG20070213T002827_2x21kd12_.bkp

  • tag=TAG20070213T002827 comment=NONEchannel ORA_DISK_1: backup set complete, elapsed time: 00:00:55Finished backup at 13-FEB-07Startingbackup at 13-FEB-07current log archivedusing channel ORA_DISK_1channel ORA_DISK_1: starting archive log backupsetchannelORA_DISK_1: specifying archive log(s) in backup setinput archive log thread=1 sequence=144 recid=110 stamp=614392165channelORA_DISK_1: starting piece 1 at 13-FEB-07channel ORA_DISK_1: finished piece 1 at 13-FEB-07piece handle=/u01/oracle/product/oradata/ora10g/fra/ORA10G/backupset/2007_02_13/o1_mf_annnn_TAG20070213T002925_2x21m6ty_.bkptag=TAG20070213T002925 comment=NONEchannel ORA_DISK_1: backup set complete, elapsed time: 00:00:02Finished backup at 13-FEB-07StartingControl File and SPFILE Autobackup at 13-FEB-07piece handle=/u01/oracle/product/ora10g/dbs/c-3932056136-20070213-02 comment=NONEFinished Control File and SPFILE Autobackup at 13-FEB-07RMAN> exit

    2) Move the following files to the NODE 2 :

    + The database backup pieces+ Controlfile backup piece+ The parameter file i.e init.ora file

    3) Edit the PFILE on NODE 2 to change the environment specific parameters like .

    user_dump_dest = background_dump_dest = control_files =4) Once the PFILE is suitably modified invoke Rman on the NODE 2 after setting the Oracle environment variables and start the database in nomount mode:

    [oracle@test-br test]$ export ORACLE_HOME=/u01/oracle/product/ora10g [oracle@test-br test]$ export ORACLE_SID=ora10g [oracle@test-br test]$ export PATH=$ORACLE_HOME/bin:$PATH [oracle@test-br test]$ rman target / Recovery Manager: Release 10.2.0.1.0 - Production on Tue Feb 13 00:36:55 2007 Copyright (c) 1982, 2005, Oracle. All rights reserved. connected to target database (not started) RMAN> startup nomount Oracle instance started Total System Global Area 205520896 bytes Fixed Size 1218508 bytes Variable Size 75499572 bytes Database Buffers 121634816 bytes Redo Buffers 7168000 bytes

    5) Restore the controlfile from the backup piece .

  • RMAN> restore controlfile from '/u01/oracle/product/ora10g/dbs/c-3932056136-20070213-02'; Starting restore at 13-FEB-07 using target database control file instead of recovery catalog allocated channel: ORA_DISK_1 channel ORA_DISK_1: sid=155 devtype=DISK channel ORA_DISK_1: restoring control file channel ORA_DISK_1: restore complete, elapsed time: 00:00:02 output filename=/u01/oracle/product/oradata/ora10g/cntrl/control01.ctl Finished restore at 13-FEB-07

    6) Mount the database

    RMAN> alter database mount ;

    7) Now catalog the backup pieces that were shipped from NODE 1

    RMAN> catalog backuppiece '/home/oracle/test/backup/o1_mf_annnn_TAG20070213T002925_2x21m6ty_.bkp';Startingimplicit crosscheck backup at 13-FEB-07allocated channel: ORA_DISK_1channel ORA_DISK_1: sid=155 devtype=DISKCrosschecked3 objectsFinished implicit crosscheck backup at 13-FEB-07Starting implicit crosscheck copy at 13-FEB-07using channelORA_DISK_1Finished implicit crosscheck copy at 13-FEB-07searching for all files in the recovery areacataloging files...nofiles catalogedcataloged backuppiecebackup piece handle=/home/oracle/test/backup/o1_mf_annnn_TAG20070213T002925_2x21m6ty_.bkprecid=41 stamp=614393265RMAN> catalog backuppiece '/home/oracle/test/backup/o1_mf_annnn_TAG20070213T002825_2x21kbds_.bkp';catalogedbackuppiecebackup piece handle=/home/oracle/test/backup/o1_mf_annnn_TAG20070213T002825_2x21kbds_.bkp recid=42 stamp=614393292RMAN>catalog backuppiece '/home/oracle/test/backup/o1_mf_nnndf_TAG20070213T002827_2x21kd12_.bkp';cataloged backuppiecebackuppiece handle=/home/oracle/test/backup/o1_mf_nnndf_TAG20070213T002827_2x21kd12_.bkp recid=43 stamp=614393310

    Get to know the last sequence available in the archivelog backup using the following command

    RMAN > list backup of archivelog all;

    9) Rename the Redologfiles,so that they can be created in new locations when opened the database is opened in resetlogs

    SQL> alter database rename file '/u01/oracle/product/oradata/ora10g/log/redo01.l

  • og' to '/home/oracle/test/log/redo01.log';..................

    10) Now restore the datafiles to new locations and recover

    RMAN> run { set until sequence set newname for datafile 1 to '/home/oracle/test/data/sys01.dbf';set newname for datafile 2 to '/home/oracle/test/data/undotbs01.dbf'; set newname for datafile 3 to '/home/oracle/test/data/sysaux01.dbf';set newname for datafile 4 to '/home/oracle/test/data/users01.dbf'; set newname for datafile 5 to '/home/oracle/test/data/1.dbf';set newname for datafile 6 to '/home/oracle/test/data/sysaux02.dbf'; set newname for datafile 7 to '/home/oracle/test/data/undotbs02.dbf';restore database; switch datafile all; recover database; alter database open resetlogs; }

    ============================================