SOURCE DATABASE (test):
Step1:-Copy the password file to target database (clone)
[oracle@trichy dbs]$ scp orapwtest oracle@192.168.160.137:$ORACLE_HOME/dbs/orapwclone
oracle@192.168.160.137's password:
orapwtest 100% 3584 3.5KB/s 00:00
[oracle@trichy dbs]$ ls
Step2:-Create pfile from SOURCE database for TARGET(clone) database
SQL> show parameter spfile;
NAME TYPE VALUE
———————————— ———————
spfile string /u01/app/oracle/product/12.2.0.1/db_1/dbs/spfiletest.ora
SQL> create pfile from spfile;
File created.
Step3:-Copy the pfile to the target database
[oracle@trichy dbs]$ scp inittest.ora oracle@192.168.160.137:$ORACLE_HOME/dbs/initclone.ora
oracle@192.168.160.137's password:
inittest.ora 100% 794 0.8KB/s 00:00
[oracle@trichy dbs]$ ls
TARGET DATABASE:
Step 4:-Create required directories in the TARGET location
Create adump,datafiles and logfiles location
mkdir -p /u01/app/oracle/admin/clone/adump
mkdir -p /u01/app/oracle/oradata/clone/
Step 5:-Edit the db_name and necessary directories name in pfile.
· Edit db_name to new database name
· Add the below the entries for datafiles and logfiles creation
*.db_file_name_convert=’/u01/app/oracle/oradata/test’,’/u01/app/oracle/oradata/clone’
*.log_file_name_convert=’/u01/app/oracle/oradata/test’,’/u01/app/oracle/oradata/clone’
vi initclone.ora (PFILE Target Database Clone)
*.audit_file_dest=’/u01/app/oracle/admin/clone/adump’
*.db_file_name_convert=’/u01/app/oracle/oradata/test’,’/u01/app/oracle/oradata/clone’
*.log_file_name_convert=’/u01/app/oracle/oradata/test’,’/u01/app/oracle/oradata/clone’
*.control_files=’/u01/app/oracle/oradata/clone/control01.ctl’,’/u01/app/oracle/oradata/clone/control02.ctl’
*.db_name=’clone’
Step 6:-Set the Environment for CLONE database,
# Oracle Settings
export TMP=/tmp
export TMPDIR=$TMP
export ORACLE_HOSTNAME=trichy.localdomain
export ORACLE_UNQNAME=clone
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/12.2.0.1/db_1
export ORACLE_SID=clone
export PATH=/usr/sbin:/usr/local/bin:$PATH
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
Step 7:-Open the CLONE database in NOMOUNT state using modified pfile,
SQL>startup pfile nomount=’$ORACLE_HOME/dbs/initclone.ora’
ORACLE instance started.
Total System Global Area 1610612736 bytes
Fixed Size 8621232 bytes
Variable Size 1040188240 bytes
Database Buffers 553648128 bytes
Redo Buffers 8155136 bytes
Step 8:-Configure the listener & tnsnames on both server
cd $ORACLE_HOME/network/admin
LISTENER ENTRY(test db):
# listener.ora Network Configuration File: /u01/app/oracle/product/12.2.0.1/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.160.138)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = test)
(ORACLE_HOME = /u01/app/oracle/product/12.2.0.1/db_1)
(SID_NAME = test)
(SERVICE_NAME = test)
)
)
TNSNAMES ENTRY(clone db):
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/12.2.0.1/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
test =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.160.138)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = test)
)
)
RMAN Active Duplication:
NOFILENAMECHECK: If you want the duplicate filenames to be the same as the target filenames, and if the databases are in different hosts, then you must specify NOFILENAMECHECK
db_file_name_convert: This parameter specifies from where to where the datafiles should be cloned.
log_file_name_convert:This parameter specifies from where to where the redo logfiles should be cloned
Connect as auxiliary database to create a new database in TARGET location
[oracle@clone:admin clone] rman target sys/oracle@test auxiliary sys/oracle
Recovery Manager: Release 12.2.0.1.0 – Production on Fri May 25 23:17:41 2018
Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved.
connected to target database: test (DBID=1504791090)
connected to auxiliary database: CLONE (not mounted)
RMAN> duplicate database to ‘clone’ from active database NOFILENAMECHECK;
[oracle@trichy ~]$ . ./clone.env
[oracle@trichy ~]$ rman target sys/oracle@test auxiliary sys/oracle
Recovery Manager: Release 12.2.0.1.0 - Production on Fri Oct 16 02:24:54 2020
Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved.
connected to target database: TEST (DBID=2343286063)
connected to auxiliary database: CLONE (not mounted)
RMAN> duplicate database to 'clone' from active database NOFILENAMECHECK;
Starting Duplicate Db at 16-OCT-20
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=36 device type=DISK
current log archived
contents of Memory Script:
{
sql clone "create spfile from memory";
}
executing Memory Script
sql statement: create spfile from memory
contents of Memory Script:
{
shutdown clone immediate;
startup clone nomount;
}executing Memory Script
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 2046820352 bytes
Fixed Size 8622480 bytes
Variable Size 587206256 bytes
Database Buffers 1442840576 bytes
Redo Buffers 8151040 bytes
contents of Memory Script:
{
sql clone "alter system set db_name =
''TEST'' comment=
''Modified by RMAN duplicate'' scope=spfile";
sql clone "alter system set db_unique_name =
''clone'' comment=
''Modified by RMAN duplicate'' scope=spfile";
shutdown clone immediate;
startup clone force nomount
restore clone from service 'test' primary controlfile;
alter clone database mount;
}
executing Memory Script
sql statement: alter system set db_name = ''TEST'' comment= ''Modified by RMAN duplicate'' scope=spfile
sql statement: alter system set db_unique_name = ''clone'' comment= ''Modified by RMAN duplicate'' scope=spfile
Oracle instance shut down
Oracle instance started
Total System Global Area 2046820352 bytes
Fixed Size 8622480 bytes
Variable Size 587206256 bytes
Database Buffers 1442840576 bytes
Redo Buffers 8151040 bytes
Starting restore at 16-OCT-20
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=34 device type=DISK
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service test
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:04
output file name=/u01/app/oracle/oradata/clone/control01.ctl
output file name=/u01/app/oracle/oradata/clone/control02.ctl
Finished restore at 16-OCT-20
database mounted
contents of Memory Script:
{
sql clone 'alter database flashback off';
set newname for datafile 1 to
"/u01/app/oracle/oradata/clone/system01.dbf";
set newname for datafile 3 to
"/u01/app/oracle/oradata/clone/sysaux01.dbf";
set newname for datafile 4 to
"/u01/app/oracle/oradata/clone/undotbs01.dbf";
set newname for datafile 5 to
"/u01/app/oracle/product/12.2.0.1/apex01.dbf";
set newname for datafile 7 to
"/u01/app/oracle/oradata/clone/users01.dbf";
restore
from nonsparse from service
'test' clone database
; sql 'alter system archive log current';
}executing Memory Script
sql statement: alter database flashback off
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 16-OCT-20
using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service test
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/clone/system01.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:46
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service test
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/clone/sysaux01.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:05
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service test
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/clone/undotbs01.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:07
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service test
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00005 to /u01/app/oracle/product/12.2.0.1/apex01.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:50
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using network backup set from service test
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00007 to /u01/app/oracle/oradata/clone/users01.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 16-OCT-20
sql statement: alter system archive log current
current log archived
contents of Memory Script:
{
restore clone force from service 'test'
archivelog from scn 6423064;
switch clone datafile all;
}
executing Memory Script
Starting restore at 16-OCT-20
using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: starting archived log restore to default destination
channel ORA_AUX_DISK_1: using network backup set from service test
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=8
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
channel ORA_AUX_DISK_1: starting archived log restore to default destination
channel ORA_AUX_DISK_1: using network backup set from service test
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=9
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 16-OCT-20
datafile 1 switched to datafile copy
input datafile copy RECID=5 STAMP=1053916163 file name=/u01/app/oracle/oradata/clone/system01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=6 STAMP=1053916164 file name=/u01/app/oracle/oradata/clone/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=7 STAMP=1053916164 file name=/u01/app/oracle/oradata/clone/undotbs01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=8 STAMP=1053916164 file name=/u01/app/oracle/product/12.2.0.1/apex01.dbf
datafile 7 switched to datafile copy
input datafile copy RECID=9 STAMP=1053916164 file name=/u01/app/oracle/oradata/clone/users01.dbf
contents of Memory Script:
{
set until scn 6423309;
recover
clone database
delete archivelog
;}
executing Memory Script
executing command: SET until clause
Starting recover at 16-OCT-20
using channel ORA_AUX_DISK_1
starting media recovery
archived log for thread 1 with sequence 8 is already on disk as file /u01/arch/CLONE/archivelog/2020_10_16/o1_mf_1_8_hrkg19qr_.arc
archived log for thread 1 with sequence 9 is already on disk as file /u01/arch/CLONE/archivelog/2020_10_16/o1_mf_1_9_hrkg1brw_.arc
archived log file name=/u01/arch/CLONE/archivelog/2020_10_16/o1_mf_1_8_hrkg19qr_.arc thread=1 sequence=8
archived log file name=/u01/arch/CLONE/archivelog/2020_10_16/o1_mf_1_9_hrkg1brw_.arc thread=1 sequence=9
media recovery complete, elapsed time: 00:00:02
Finished recover at 16-OCT-20
Oracle instance started
Total System Global Area 2046820352 bytes
Fixed Size 8622480 bytes
Variable Size 587206256 bytes
Database Buffers 1442840576 bytes
Redo Buffers 8151040 bytes
contents of Memory Script:
{
sql clone "alter system set db_name =
''CLONE'' comment=
''Reset to original value by RMAN'' scope=spfile";
sql clone "alter system reset db_unique_name scope=spfile";
}
executing Memory Script
sql statement: alter system set db_name = ''CLONE'' comment= ''Reset to original value by RMAN'' scope=spfile
sql statement: alter system reset db_unique_name scope=spfile
Oracle instance started
Total System Global Area 2046820352 bytes
Fixed Size 8622480 bytes
Variable Size 587206256 bytes
Database Buffers 1442840576 bytes
Redo Buffers 8151040 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "CLONE" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 ( '/u01/app/oracle/oradata/clone/redo01.log' ) SIZE 200 M REUSE,
GROUP 2 ( '/u01/app/oracle/oradata/clone/redo02.log' ) SIZE 200 M REUSE,
GROUP 3 ( '/u01/app/oracle/oradata/clone/redo03.log' ) SIZE 200 M REUSE
DATAFILE
'/u01/app/oracle/oradata/clone/system01.dbf'
CHARACTER SET AL32UTF8
contents of Memory Script:
{
set newname for tempfile 1 to
"/u01/app/oracle/oradata/clone/temp01.dbf";
switch clone tempfile all;
catalog clone datafilecopy "/u01/app/oracle/oradata/clone/sysaux01.dbf",
"/u01/app/oracle/oradata/clone/undotbs01.dbf",
"/u01/app/oracle/product/12.2.0.1/apex01.dbf",
"/u01/app/oracle/oradata/clone/users01.dbf";
switch clone datafile all;
}
executing Memory Script
executing command: SET NEWNAME
renamed tempfile 1 to /u01/app/oracle/oradata/clone/temp01.dbf in control file
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/clone/sysaux01.dbf RECID=1 STAMP=1053916191
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/clone/undotbs01.dbf RECID=2 STAMP=1053916191
cataloged datafile copy
datafile copy file name=/u01/app/oracle/product/12.2.0.1/apex01.dbf RECID=3 STAMP=1053916191
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/clone/users01.dbf RECID=4 STAMP=1053916191
datafile 3 switched to datafile copy
input datafile copy RECID=1 STAMP=1053916191 file name=/u01/app/oracle/oradata/clone/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=2 STAMP=1053916191 file name=/u01/app/oracle/oradata/clone/undotbs01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=3 STAMP=1053916191 file name=/u01/app/oracle/product/12.2.0.1/apex01.dbf
datafile 7 switched to datafile copy
input datafile copy RECID=4 STAMP=1053916191 file name=/u01/app/oracle/oradata/clone/users01.dbf
Reenabling controlfile options for auxiliary database
Executing: alter database force logging
contents of Memory Script:
{
Alter clone database open resetlogs;
}
executing Memory Script
database opened
Executing: alter database flashback on
Cannot remove created server parameter file
Finished Duplicate Db at 16-OCT-20
RMAN>
Step 9:-Verify the status of TARGET(clone db) database status,
[oracle@trichy ~]$ sqlplus / as sysdba
SQL*Plus: Release 12.2.0.1.0 Production on Fri Oct 16 02:22:40 2020
Copyright (c) 1982, 2016, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup nomount
ORACLE instance started.
Total System Global Area 2046820352 bytes
Fixed Size 8622480 bytes
Variable Size 587206256 bytes
Database Buffers 1442840576 bytes
Redo Buffers 8151040 bytes
SQL>
SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
[oracle@trichy ~]$ sqlplus / as sysdba
SQL*Plus: Release 12.2.0.1.0 Production on Fri Oct 16 02:33:15 2020
Copyright (c) 1982, 2016, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
SQL> select name,open_mode from v$database;
NAME OPEN_MODE
--------- --------------------
CLONE READ WRITE
SQL>
Screen shots
No comments:
Post a Comment