Rman cloning when both directory and db name are same.
-
Upload
subhani-shaik -
Category
Technology
-
view
13 -
download
2
Transcript of Rman cloning when both directory and db name are same.
WHEN BOTH DIRECTORY AND DB NAME ARE SAME.
PRE - STEPS
I. DATABASE IN ARCHIVE LOG MODE.
II. CONTROL FILE AUTO BACKUP ON.
STEPS TO BE PERFORMED ON TARGET ( SOURCE ) DATABASE :
DB NAME : TARG
1. TAKE BACKUP OF DATABASE
RMAN > backup database plus archivelog;
2. ONCE BACKUP DONE COPY BACKUP-PIECES TO AUXILIARY (DESTINATION ) DATABASE USING LINUX
COMMAND scp.
RMAN > list backup; (Shows list of back pieces )
RMAN > list backup of controlfile; ( shows control file backup piece loction )
3. COPY PARAMETER FILE (init file) TO AUXILIARY ( DESTINATION ) DATABASE.
$ scp initTARG [email protected].***:$ORACLE_HOME/dbs
4. ISSUE BELOW COMMANDS ON TARGET ( SOURCE ) DATABASE FOR FOR DATAFILES, REDOLOG FILES, CONTROL
FILES LOCATIONS.
SQL> select file_name from dba_data_files;
SQL> select name from v$controlfile;
SQL> select member from v$logfile;
STEPS TO BE PERFORMED ON AUXILIARY (DESTINATION ) DATABASE.:
DB NAME : TARG
5. MAKE DIRECTORY STRUCTURE SAME AS TARGET ( SOURCE ) ON AUXILIARY ( DESTINATION ) SERVER FOR
DATAFILES, REDOLOG FILES, CONTROL FILES.
FOR DIRECTORY STRUCTURE REFER STEP 4.
6. START AUXILIARY ( DESTINATION ) DATABASE IN NOMOUNT MODE
$ export ORACLE_SID=TARG
$ sqlplus '/as sysdba'
[oracle@Dup dbs]$ sqlplus '/as sysdba'
SQL*Plus: Release 11.2.0.3.0 Production on Thu Jan 19 11:27:10 2017
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup nomount
ORACLE instance started.
Total System Global Area 422670336 bytes
Fixed Size 1345380 bytes
Variable Size 264243356 bytes
Database Buffers 150994944 bytes
Redo Buffers 6086656 bytes
SQL> exit
7. CONNECT TO AUXILIARY ( DESTINATION ) DATABASE.
$ rman auxiliary /
8. ISSUE DUPLICATE CONNAMD FROM RMAN PROMPT IN AUXILIARY ( DESTINATION ) DATABASE .
RMAN> duplicate database to TARG backup location '/u01/copied_backups' nofilenamecheck;
Starting Duplicate Db at 19-JAN-17
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 422670336 bytes
Fixed Size 1345380 bytes
Variable Size 268437660 bytes
Database Buffers 146800640 bytes
Redo Buffers 6086656 bytes
contents of Memory Script:
{
sql clone "alter system set db_name =
''TARG'' comment=
''Modified by RMAN duplicate'' scope=spfile";
sql clone "alter system set db_unique_name =
''TARG'' comment=
''Modified by RMAN duplicate'' scope=spfile";
shutdown clone immediate;
startup clone force nomount
restore clone primary controlfile from '/u01/copied_backups/o1_mf_s_933677269_d80lzzcs_.bkp';
alter clone database mount;
}
executing Memory Script
sql statement: alter system set db_name = ''TARG'' comment= ''Modified by RMAN duplicate''
scope=spfile
sql statement: alter system set db_unique_name = ''TARG'' comment= ''Modified by RMAN duplicate''
scope=spfile
Oracle instance shut down
Oracle instance started
Total System Global Area 422670336 bytes
Fixed Size 1345380 bytes
Variable Size 268437660 bytes
Database Buffers 146800640 bytes
Redo Buffers 6086656 bytes
Starting restore at 19-JAN-17
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=18 device type=DISK
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03
output file name=/u01/app/oracle/oradata/TARG/control01.ctl
output file name=/u01/app/oracle/fast_recovery_area/TARG/control02.ctl
Finished restore at 19-JAN-17
database mounted
released channel: ORA_AUX_DISK_1
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=18 device type=DISK
contents of Memory Script:
{
set until scn 834228;
set newname for datafile 1 to
"/u01/app/oracle/oradata/TARG/system01.dbf";
set newname for datafile 2 to
"/u01/app/oracle/oradata/TARG/sysaux01.dbf";
set newname for datafile 3 to
"/u01/app/oracle/oradata/TARG/undotbs01.dbf";
set newname for datafile 4 to
"/u01/app/oracle/oradata/TARG/users01.dbf";
restore
clone database
;
}
executing Memory Script
executing command: SET until clause
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 19-JAN-17
using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: starting datafile backup set restore
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/TARG/system01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/TARG/sysaux01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/TARG/undotbs01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/TARG/users01.dbf
channel ORA_AUX_DISK_1: reading from backup piece
/u01/copied_backups/o1_mf_nnndf_TAG20170119T104443_d80lt42d_.bkp
channel ORA_AUX_DISK_1: piece
handle=/u01/copied_backups/o1_mf_nnndf_TAG20170119T104443_d80lt42d_.bkp tag=TAG20170119T104443
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:03:15
Finished restore at 19-JAN-17
contents of Memory Script:
{
switch clone datafile all;
}
executing Memory Script
datafile 1 switched to datafile copy
input datafile copy RECID=1 STAMP=933680265 file name=/u01/app/oracle/oradata/TARG/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=2 STAMP=933680265 file name=/u01/app/oracle/oradata/TARG/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=3 STAMP=933680265 file
name=/u01/app/oracle/oradata/TARG/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=4 STAMP=933680265 file name=/u01/app/oracle/oradata/TARG/users01.dbf
contents of Memory Script:
{
set until scn 834228;
recover
clone database
delete archivelog
;
}
executing Memory Script
executing command: SET until clause
Starting recover at 19-JAN-17
using channel ORA_AUX_DISK_1
starting media recovery
channel ORA_AUX_DISK_1: starting archived log restore to default destination
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=9
channel ORA_AUX_DISK_1: reading from backup piece
/u01/copied_backups/o1_mf_annnn_TAG20170119T104747_d80lzvrk_.bkp
channel ORA_AUX_DISK_1: piece
handle=/u01/copied_backups/o1_mf_annnn_TAG20170119T104747_d80lzvrk_.bkp tag=TAG20170119T104747
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
archived log file name=/u01/app/oracle/fast_recovery_area/TARG/archivelog/2017_01_19/
o1_mf_1_9_d80oxx8o_.arc thread=1 sequence=9
channel clone_default: deleting archived log(s)
archived log file name=/u01/app/oracle/fast_recovery_area/TARG/archivelog/2017_01_19/
o1_mf_1_9_d80oxx8o_.arc RECID=1 STAMP=933680277
media recovery complete, elapsed time: 00:00:02
Finished recover at 19-JAN-17
Oracle instance started
Total System Global Area 422670336 bytes
Fixed Size 1345380 bytes
Variable Size 268437660 bytes
Database Buffers 146800640 bytes
Redo Buffers 6086656 bytes
contents of Memory Script:
{
sql clone "alter system set db_name =
''TARG'' comment=
''Reset to original value by RMAN'' scope=spfile";
sql clone "alter system reset db_unique_name scope=spfile";
shutdown clone immediate;
startup clone nomount;
}
executing Memory Script
sql statement: alter system set db_name = ''TARG'' comment= ''Reset to original value by RMAN''
scope=spfile
sql statement: alter system reset db_unique_name scope=spfile
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 422670336 bytes
Fixed Size 1345380 bytes
Variable Size 268437660 bytes
Database Buffers 146800640 bytes
Redo Buffers 6086656 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "TARG" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 SIZE 50 M ,
GROUP 2 SIZE 50 M ,
GROUP 3 SIZE 50 M
DATAFILE
'/u01/app/oracle/oradata/TARG/system01.dbf'
CHARACTER SET WE8MSWIN1252
contents of Memory Script:
{
set newname for tempfile 1 to
"/u01/app/oracle/oradata/TARG/temp01.dbf";
switch clone tempfile all;
catalog clone datafilecopy "/u01/app/oracle/oradata/TARG/sysaux01.dbf",
"/u01/app/oracle/oradata/TARG/undotbs01.dbf",
"/u01/app/oracle/oradata/TARG/users01.dbf";
switch clone datafile all;
}
executing Memory Script
executing command: SET NEWNAME
renamed tempfile 1 to /u01/app/oracle/oradata/TARG/temp01.dbf in control file
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/TARG/sysaux01.dbf RECID=1 STAMP=933680360
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/TARG/undotbs01.dbf RECID=2 STAMP=933680360
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/TARG/users01.dbf RECID=3 STAMP=933680361
datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=933680360 file name=/u01/app/oracle/oradata/TARG/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=933680360 file
name=/u01/app/oracle/oradata/TARG/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=933680361 file name=/u01/app/oracle/oradata/TARG/users01.dbf
contents of Memory Script:
{
Alter clone database open resetlogs;
}
executing Memory Script
database opened
Finished Duplicate Db at 19-JAN-17
RMAN>
9. CHECK DATAFILE, CONTROL FILE AND REDOLOG FILE LOCATIONS BY CONNECT TO AUXILIARY ( DESTINATION )
DATABASE FROM SQL PROMPT.
SQL> select file_name from dba_data_files;
SQL> select name from v$controlfile;
SQL> select member from v$logfile;