Tuesday, January 17, 2017

Oracle RMAN duplicate

8:28 PM Posted by Dilli Raj Maharjan No comments

Environment: 

Source DB: orcl
Destination DB: dilli
Source/Destination Host: OEL1.localdomain

We are using same host to duplicate source database orcl to destination database dilli. If  we need to duplicate on different host we need to install oracle software only on the destination host.


Create password file for the new database on destination host.
cd $ORACLE_HOME/dbs
orapwd file=${ORACLE_HOME}/dbs/orapwdilli password=oracle_4U entries=10










Create tnsname entry for new database. Add these entry on the source database or on the database from where we are using RMAN to connect to target(Source) database and auxiliary(Destination) database.
dilli = 
(DESCRIPTION = 
(ADDRESS_LIST = 
(ADDRESS = (PROTOCOL=TCP)(PORT=1521)(HOST=OEL1.localdomain))
)
(CONNECT_DATA =
(SERVER=DEDICATED)
(ORACLE_SID=dilli)
)
)
tnsping dilli



Add following settings on the listener file on source database. Following configuration make the static service listening on the listener.
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = dilli)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
      (SID_NAME = dilli)
    )
  )


























List all the datafile and the logfile location. These location should be converted to new location in the case of the same host. In case of different host and using the exactly same path we do not need to use DB_FILE_NAME_CONVERT and LOG_FILE_NAME_CONVERT parameter. In the case below we are using new paths for all the datafile and logfiles.

























Create pfile with following entry. Please use new address for all the datafiles and logfiles. In our we will use +DATA/dilli/datafile/ instead of +DATA/orcl/datafile/, /u01/app/oracle/oradata/dilli/ instead of /u01/app/oracle/oradata/orcl and so on.

cat > /home/oracle/pfile_dilli
DB_NAME=dilli

DB_FILE_NAME_CONVERT='+DATA/orcl/datafile/','+DATA/dilli/datafile/','/u01/app/oracle/oradata/orcl/','/u01/app/oracle/oradata/dilli/','/home/oracle/BACKUP/','/home/oracle/BACKUP_1/'
LOG_FILE_NAME_CONVERT='+DATA/orcl/onlinelog/','+DATA/dilli/onlinelog/','+FRA/orcl/onlinelog/','+FRA/dilli/onlinelog/'


Make sure new file already exists and have rw permission to the oracle owner. If they do not exists create them.
[oracle@OEL1 labs]$ . oraenv
ORACLE_SID = [+ASM] ? 
The Oracle base remains unchanged with value /u01/app/oracle
[oracle@OEL1 labs]$ asmcmd
ASMCMD> cd data
ASMCMD> mkdir dilli
ASMCMD> cd dilli
ASMCMD> mkdir datafile 
ASMCMD> cd datafile
ASMCMD> pwd
+data/dilli/datafile
ASMCMD> cd ../../../fra 
ASMCMD> mkdir dilli
ASMCMD> cd dilli
ASMCMD> mkdir onlinelog
ASMCMD> cd onlinelog
ASMCMD> pwd
+fra/dilli/onlinelog
ASMCMD> 
ASMCMD> cd ../../../data/dilli
ASMCMD> mkdir onlinelog
ASMCMD> cd onlinelog
ASMCMD> ls
ASMCMD> pwd
+data/dilli/onlinelog
ASMCMD> 
[oracle@OEL1 labs]$ mkdir -p /u01/app/oracle/oradata/dilli/
[oracle@OEL1 labs]$ mkdir -p /home/oracle/BACKUP_1/





























Start destination database on the nomount mode with the newly created pfile.
[oracle@OEL1 admin]$ sqlplus /nolog

SQL*Plus: Release 11.2.0.3.0 Production on Thu Dec 1 10:27:13 2016

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

SQL> connect sys/oracle_4U@dilli as sysdba
SQL> startup nomount pfile='/home/oracle/pfile_dilli'
SQL> create spfile from pfile='/home/oracle/pfile_dilli';


Connect target and auxiliary database from RMAN
[oracle@OEL1 admin]$ . oraenv
ORACLE_SID = [orcl] ? 
The Oracle base remains unchanged with value /u01/app/oracle
[oracle@OEL1 admin]$ rman target sys/oracle_4U@orcl auxiliary sys/oracle_4U@dilli nocatalog















Execute RMAN duplicate command  that will start duplicating active database.
RMAN> DUPLICATE DATABASE TO dilli 
FROM ACTIVE DATABASE
NOFILENAMECHECK;



Add following entry on oratab file on etc directory.
cat >> /etc/oratab
dilli:/u01/app/oracle/product/11.2.0/db_1:N


Start connecting to the newly created duplicate database.



0 comments:

Post a Comment