How to Duplicate or clone a database from
source database without connecting to source database ?
let source_1 be the source database and target_1 be the target database.
In this process we will be cloning the target database from backup of source database.
Here are the steps to do duplication/cloning of database by without connecting to source database(source_1):
1. Take backup of full database, archive log, snapshot control file ,control file from source
vi rman_fullback.rcv
run {
allocate channel t1 type disk format '/u04/rmanbackup/source_1/full_source_1_%t_%s_%p_%U.bck' maxpiecesize 5120m;
backup AS COMPRESSED BACKUPSET database tag = full_open_backup_disk;
sql 'alter system archive log current';
backup archivelog all;
backup SPFILE format '/u04/rmanbackup/source_1/spfile_source_1.bck';
backup current controlfile format '/u04/rmanbackup/source_1/ctrl_source_1_%t_%s_%p_%U.bck';
release channel t1;
}
rman checksyntax@rman_fullback.rcv
Make sure it comes with no error.
nohup rman target / nocatalog cmdfile=rman_fullback.rcv log=rman_fullback.log &
---------------------------------------------------------------------------------------------------------------
2. scp the files to target
scp pavan_1@avananche.ttd.com:/u04/rmanbackup/source_1/{file1,fil2,fil3} .
----------------------------------------------------------------------------------------------------------------
3. Take backup from target also for safefy with same script
vi rman_fullback.rcv
run {
allocate channel t1 type disk format '/u04/rmanbackup/source_1/full_source_1_%t_%s_%p_%U.bck' maxpiecesize 5120m;
backup AS COMPRESSED BACKUPSET database tag = full_open_backup_disk;
sql 'alter system archive log current';
backup archivelog all;
backup current controlfile format '/u04/rmanbackup/source_1/ctrl_source_1_%t_%s_%p_%U.bck';
release channel t1;
}
rman checksyntax@rman_fullback.rcv
Make sure it comes with no error.
nohup rman target / nocatalog cmdfile=rman_fullback.rcv log=rman_fullback.log &
------------------------------------------------------------------------------------------------------------------
4. Before dropping make sure above steps are completed and note the below
SQL> select name from v$datafile;
/u01/oradata/target_1/system_01.dbf
/u03/oradata/source_1/system_01.dbf
SQL> select member from v$logfile;
/u01/oradata/target_1/redo06a.log
/u03/oradata/source_1/redo06a.log
--------------------------------------------------------------------------------------------------------------------
5. Set the pameter in pfile of target 'source','target'
*.log_file_name_convert='/u03/oradata/source_1', '/u01/oradata/target_1'
*.db_file_name_convert='/u03/oradata/source_1', '/u01/oradata/target_1'
or
ALTER SYSTEM SET DB_FILE_NAME_CONVERT='/u03/oradata/source_1','/u01/oradata/target_1' SCOPE=SPFILE;
ALTER SYSTEM SET LOG_FILE_NAME_CONVERT='/u03/oradata/source_1','/u01/oradata/target_1' SCOPE=SPFILE;
--------------------------------------------------------------------------------------------------------------------
6. Create password file on both sides in $ORACLE_HOME/dbs location
orapwd file=orapwsource_1 password=admin123 force=y ignorecase=y
this step is not mandatory
---------------------------------------------------------------------------------------------------------------------
7. Drop the target database
Shutdown immediate;
Startup mount restrict;
Drop database;
----------------------------------------------------------------------------------------------------------------------
8. on target database side
export $ORACLE_SID=target database name(target_1)
SQL> startup nomount;
SQL>exit
rman auxiliary /
Target database will be connected in not mounted state
------------------------------------------------------------------------------------------------------------------------
9. Now duplicate the database from backup location
Duplicate database to target_1 ------ (target)
spfile
set control_files='/u01/oradata/target_1/ctrl/control01.ctl','/u01/oradata/target_1/ctrl/control02.ctl'
set db_file_name_convert='/u03/oradata/source_1', '/u01/oradata/target_1'
set LOG_FILE_NAME_CONVERT='/u03/oradata/source_1', '/u01/oradata/target_1'
set diagnostic_dest='/u01/app/oracle/admin/target_1/diag'
SET log_archive_dest_1='location=/u01/arch/target_1'
backup location '/u02/rman_backups/target_1_bkp/source_1'
NOFILENAMECHECK;
---------------------------------------------------------------------------------------------------------------------------
let source_1 be the source database and target_1 be the target database.
In this process we will be cloning the target database from backup of source database.
Here are the steps to do duplication/cloning of database by without connecting to source database(source_1):
1. Take backup of full database, archive log, snapshot control file ,control file from source
vi rman_fullback.rcv
run {
allocate channel t1 type disk format '/u04/rmanbackup/source_1/full_source_1_%t_%s_%p_%U.bck' maxpiecesize 5120m;
backup AS COMPRESSED BACKUPSET database tag = full_open_backup_disk;
sql 'alter system archive log current';
backup archivelog all;
backup SPFILE format '/u04/rmanbackup/source_1/spfile_source_1.bck';
backup current controlfile format '/u04/rmanbackup/source_1/ctrl_source_1_%t_%s_%p_%U.bck';
release channel t1;
}
rman checksyntax@rman_fullback.rcv
Make sure it comes with no error.
nohup rman target / nocatalog cmdfile=rman_fullback.rcv log=rman_fullback.log &
---------------------------------------------------------------------------------------------------------------
2. scp the files to target
scp pavan_1@avananche.ttd.com:/u04/rmanbackup/source_1/{file1,fil2,fil3} .
----------------------------------------------------------------------------------------------------------------
3. Take backup from target also for safefy with same script
vi rman_fullback.rcv
run {
allocate channel t1 type disk format '/u04/rmanbackup/source_1/full_source_1_%t_%s_%p_%U.bck' maxpiecesize 5120m;
backup AS COMPRESSED BACKUPSET database tag = full_open_backup_disk;
sql 'alter system archive log current';
backup archivelog all;
backup current controlfile format '/u04/rmanbackup/source_1/ctrl_source_1_%t_%s_%p_%U.bck';
release channel t1;
}
rman checksyntax@rman_fullback.rcv
Make sure it comes with no error.
nohup rman target / nocatalog cmdfile=rman_fullback.rcv log=rman_fullback.log &
------------------------------------------------------------------------------------------------------------------
4. Before dropping make sure above steps are completed and note the below
SQL> select name from v$datafile;
/u01/oradata/target_1/system_01.dbf
/u03/oradata/source_1/system_01.dbf
SQL> select member from v$logfile;
/u01/oradata/target_1/redo06a.log
/u03/oradata/source_1/redo06a.log
--------------------------------------------------------------------------------------------------------------------
5. Set the pameter in pfile of target 'source','target'
*.log_file_name_convert='/u03/oradata/source_1', '/u01/oradata/target_1'
*.db_file_name_convert='/u03/oradata/source_1', '/u01/oradata/target_1'
or
ALTER SYSTEM SET DB_FILE_NAME_CONVERT='/u03/oradata/source_1','/u01/oradata/target_1' SCOPE=SPFILE;
ALTER SYSTEM SET LOG_FILE_NAME_CONVERT='/u03/oradata/source_1','/u01/oradata/target_1' SCOPE=SPFILE;
--------------------------------------------------------------------------------------------------------------------
6. Create password file on both sides in $ORACLE_HOME/dbs location
orapwd file=orapwsource_1 password=admin123 force=y ignorecase=y
this step is not mandatory
---------------------------------------------------------------------------------------------------------------------
7. Drop the target database
Shutdown immediate;
Startup mount restrict;
Drop database;
----------------------------------------------------------------------------------------------------------------------
8. on target database side
export $ORACLE_SID=target database name(target_1)
SQL> startup nomount;
SQL>exit
rman auxiliary /
Target database will be connected in not mounted state
------------------------------------------------------------------------------------------------------------------------
9. Now duplicate the database from backup location
Duplicate database to target_1 ------ (target)
spfile
set control_files='/u01/oradata/target_1/ctrl/control01.ctl','/u01/oradata/target_1/ctrl/control02.ctl'
set db_file_name_convert='/u03/oradata/source_1', '/u01/oradata/target_1'
set LOG_FILE_NAME_CONVERT='/u03/oradata/source_1', '/u01/oradata/target_1'
set diagnostic_dest='/u01/app/oracle/admin/target_1/diag'
SET log_archive_dest_1='location=/u01/arch/target_1'
backup location '/u02/rman_backups/target_1_bkp/source_1'
NOFILENAMECHECK;
---------------------------------------------------------------------------------------------------------------------------
No comments:
Post a Comment