Oracle Clone Database with Duplicate database

I will explain Oracle Clone Database with Duplicate database in this post.

 

Oracle Clone Database

To Clone any database, you should perform the following steps.

 

 

 

 

Step 1: Backup Full database and Archivelogs via RMAN as follows.

connect target /
run{
ALLOCATE CHANNEL CH1 DEVICE TYPE DISK;
ALLOCATE CHANNEL CH2 DEVICE TYPE DISK;
ALLOCATE CHANNEL CH3 DEVICE TYPE DISK;
ALLOCATE CHANNEL CH4 DEVICE TYPE DISK;
ALLOCATE CHANNEL CH5 DEVICE TYPE DISK;
ALLOCATE CHANNEL CH6 DEVICE TYPE DISK;
ALLOCATE CHANNEL CH7 DEVICE TYPE DISK;
ALLOCATE CHANNEL CH8 DEVICE TYPE DISK;
BACKUP AS COMPRESSED BACKUPSET DATABASE FORMAT '/u01/oracle/backup/FULL_%d_%u_%s_%T.bkp';
BACKUP AS COMPRESSED BACKUPSET ARCHIVELOG ALL not backed up 1 times FORMAT '/u01/oracle/backup/Archivelogs_%d_%u_%s_%T.bkp';
BACKUP CURRENT CONTROLFILE FORMAT '/u01/oracle/backup/CONTROLFILE%d_%u_%s_%T.bkp';
RELEASE CHANNEL CH1;
RELEASE CHANNEL CH2;
RELEASE CHANNEL CH3;
RELEASE CHANNEL CH4;
RELEASE CHANNEL CH5;
RELEASE CHANNEL CH6;
RELEASE CHANNEL CH7;
RELEASE CHANNEL CH8;
}

 

Copy backups from Source to Target

scp *bkp KlonIP:/u01/oracle/backup

 

 

Clone Oracle Home 

Step 2: Copy Oracle database Home from Source to Clone.

scp -pr 12.1.0/ KlonIP:/u01/database

 

If Oracle Home changed in the new Clone environment, relink is run on the Clone database as follows.

$ORACLE_HOME/bin/relink all



OR You can install fresh Oracle software instead of copy Oracle binary using the following post.

Oracle Database 19c on Linux 7.6 and RHEL Step by Step Installation -1

 

 

Step 3: Configure and start Oracle Instance on Clone Side.

Set Oracle Environment on New Target database Server and start Oracle instance with nomount mode.

 

Use following parameters for PFILE and start Oracle instance with this parameter file in nomount mode.

db_name='DEVECI'
db_unique_name='DEVCLONE'
db_file_name_convert=(OLD_PATH,NEW_PATH)
log_file_name_convert=(OLD_PATH,NEW_PATH)

 

 

Create a folder named adump manually at the Clone database. If the database cannot see this file at startup, it gives an error.

 

[oracle@MehmetSalih ~]$ mkdir $ORACLE_BASE/admin/$ORACLE_SID/adump

 

Create a pfile for the Standby database on the Standby server and try to start non-existent database in nomount mode. In the next steps we will duplicate database from Primary.

 

[oracle@MehmetSalih ~]$ vi initDEVCLONE.ora

 

In this step, You can startup oracle database with following 3 parameters in the pfile and add the remaining parameters while executing rman duplicate. I added the following 3 parameters to the pfile and open the Oracle Instance with the nomount mode as follows.

 

*.DB_NAME=DEVECI
*.DB_UNIQUE_NAME=DEVCLONE
*.DB_BLOCK_SIZE=8192

 

After setting bash profile through the server, let’s open Oracle Instance in nomount mode.

 

[oracle@MehmetSalih ~]$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Sat Jun 12 13:09:39 2013
Copyright (c) 1982, 2016, Oracle. All rights reserved.
Connected to an idle instance.


SQL> startup nomount pfile='/home/oracle/pfile.ora';
ORACLE instance started.

Total System Global Area 1140849896 bytes
Fixed Size 8895720 bytes
Variable Size 838860800 bytes
Database Buffers 285212672 bytes
Redo Buffers 7880704 bytes
SQL>

 

 

Duplicate Database in Oracle

 

Step 4:  Finally we start the duplicate with the RMAN tool from Primary database as follows.

 

[oracle@MehmetSalih ~]$ rman target sys/password@DEVECI auxiliary sys/sys@DEVCLONE

 

 

Duplicate & Restore and Recover database and open clone database on Target

Use duplicate command for creating Clone database like following.

 

duplicate target database to "DEVCLONE" BACKUP LOCATION '/u01/oracle/backup';

 

 

 

 

duplicate target database for standby from active database

 

OR

 

If you don’t want to take backup or you don’t have sufficient space for backup, you can use the duplicate target database for standby from active database command as follows.

This command will copy the existing datafiles to the Clone side.

start duplicate with the following script.

 

RMAN> run{
allocate channel prmy1 type disk;
allocate channel prmy2 type disk;
allocate channel prmy3 type disk;
allocate channel prmy4 type disk;
allocate auxiliary channel stby type disk;
duplicate target database for standby from active database
spfile
parameter_value_convert 'DEVECI','DEVCLONE'
set db_unique_name='DEVCLONE'
set db_file_name_convert='/oracle/DATA/DEVECI/DEVECI','/oracle/DATA/DEVCLONE/DEVCLONE'
set log_file_name_convert='/oracle/DATA/DEVECI/DEVECI','/oracle/DATA/DEVCLONE/DEVCLONE'
set control_files='/oracle/DATA/DEVCLONE/DEVCLONE/control01.ctl'
 db_unique_name=DEVECI';
}

 

The above RMAN Duplicate script will generate too much output, so if you want, you can print it into a log file and review each step. In terms of your comparison, I give the output of the last part below, and if the output is not in this way, you probably have made an error or deficiency.

 

                                       .
                                       .
                                       .

datafile 1 switched to datafile copy
input datafile copy RECID=2 STAMP=837509470 file name=/oracle/data/DEVCLONE/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=3 STAMP=837509470 file name=/oracle/data/DEVCLONE/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=4 STAMP=837509470 file name=/oracle/data/DEVCLONE/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=5 STAMP=837509470 file name=/oracle/data/DEVCLONE/users01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=6 STAMP=837509470 file name=/oracle/data/DEVCLONE/example01.dbf
Finished Duplicate Db at 12-JUN-14
RMAN>

 

 

 

 

 

Step 5:  The password file of the primary database is copied to the Clone database side as follows.

 

[oracle@MehmetSalih ~]$ scp orapwDEVECI [email protected]:/oracle/product/12.1.0/db/dbs/orapwDEVCLONE

 

 

Step 6:  Once the Duplicate database is done successfully, you should run the Recover database command as follows.

 

RMAN> recover database;



RMAN> run
{
set until time "to_date('20-03-26:18:00:00', 'yyyy-mm-dd:hh24:mi:ss')";
recover database;
}2> 3> 4> 5> 6> 7>

executing command: SET until clause

Starting restore at 26-MAR-19
using channel ORA_DISK_1

channel ORA_DISK_1: starting archived log restore to default destination
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=3
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=4
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=5
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=6
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=7
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=8
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=9
channel ORA_DISK_1: reading from backup piece /u01/backup/FULL_DEVECI_1ettcqar_46_200326.bkp
channel ORA_DISK_1: errors found reading piece handle=/u01/backup/FULL_DEVECI_1ettcqar_46_200326.bkp
channel ORA_DISK_1: failover to piece handle=/u01/backup/FULL_DEVECI_1ettcqar_46_200326.rman tag=TAG200326T071018
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:26
channel ORA_DISK_1: starting archived log restore to default destination
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=10
channel ORA_DISK_1: reading from backup piece /u01/backup/FULL_DEVECI_1httcqdo_49_200326.bkp
channel ORA_DISK_1: errors found reading piece handle=/u01/backup/FULL_DEVECI_1httcqdo_49_200326.bkp
channel ORA_DISK_1: failover to piece handle=/u01/backup/FULL_DEVECI_1httcqdo_49_200326.rman tag=TAG200326T071152
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 26-MAR-19

Starting recover at 26-MAR-19
using channel ORA_DISK_1

starting media recovery


media recovery complete, elapsed time: 00:05:00

Finished recover at 26-MAR-19

RMAN>

 

 

 

Step 7:  Once the Recover is done successfully, you should open database with resetlogs option as follows.

 

SQL> alter database open resetlogs;



SQL> alter database open resetlogs;

Database altered.

SQL>

 

 

You can read the following post to learn about Oracle dataguard .

Oracle DataGuard Step by Step Installation with RMAN Duplicate Method -2

Oracle DataGuard Physical Standby Installation Step by Step Using RMAN -2

 

 

 

Do you want to learn Oracle Database for Beginners, then read the following articles.

Oracle Tutorial | Oracle Database Tutorials for Beginners ( Junior Oracle DBA )

 

About Mehmet Salih Deveci

I am Founder of SysDBASoft IT and IT Tutorial and Certified Expert about Oracle & SQL Server database, Goldengate, Exadata Machine, Oracle Database Appliance administrator with 10+years experience.I have OCA, OCP, OCE RAC Expert Certificates I have worked 100+ Banking, Insurance, Finance, Telco and etc. clients as a Consultant, Insource or Outsource.I have done 200+ Operations in this clients such as Exadata Installation & PoC & Migration & Upgrade, Oracle & SQL Server Database Upgrade, Oracle RAC Installation, SQL Server AlwaysOn Installation, Database Migration, Disaster Recovery, Backup Restore, Performance Tuning, Periodic Healthchecks.I have done 2000+ Table replication with Goldengate or SQL Server Replication tool for DWH Databases in many clients.If you need Oracle DBA, SQL Server DBA, APPS DBA,  Exadata, Goldengate, EBS Consultancy and Training you can send my email adress [email protected].-                                                                                                                                                                                                                                                 -Oracle DBA, SQL Server DBA, APPS DBA,  Exadata, Goldengate, EBS ve linux Danışmanlık ve Eğitim için  [email protected] a mail atabilirsiniz.

Leave a Reply

Your email address will not be published. Required fields are marked *