Oracle Recovery Manager (RMAN) provides a comprehensive foundation for efficiently backing up and recovering the Oracle databases, it provides a common interface, via command line and Enterprise Manager, for backup tasks across different host operating systems, automates administration of your backup strategies.
In this scenario we have different database name and different directory structure, and we are using SPFILE clause in Rman duplication command.
Environment details:
Target (source) details:
|
Database Name
|
prod
|
|
Hostname
|
Nsm-source
|
|
Ip Address
|
172.16.110.18
|
|
OS
|
Linux
|
|
Version
|
x86_64
|
|
Datafile Location
|
/data2/prod
|
|
Backup Location
|
/backup/rman_backup
|
Destination details:
|
Database Name
|
dup
|
|
Hostname
|
Nsm-linux
|
|
Ip Address
|
172.16.110.16
|
|
OS
|
Linux
|
|
Version
|
x86_64
|
|
Datafile Location
|
/data2/prod/dup/
|
|
Backup Location
|
/backup/rman_backup
|
Prerequisites:
- Password file from target database.
- Sqlnet.ora should have correct parameters.
- Target database should be running through spfile.
- Auxiliary instance should be start with pfile in nomount stage.
Steps on target (source) server:
2. Connect to RMAN.
[oracle@Nsm-source dbs]$ rman target sys/oracle
Recovery Manager: Release 11.2.0.1.0 – Production on
Thu Apr 9 10:47:41 2015
Copyright (c) 1982, 2009, Oracle and/or its
affiliates. All rights reserved.
connected to target database: PROD (DBID=284539893)
RMAN>
3. Issue the following command to initiate backup. Before issue the backup command check the backup location is sat correctly.
Thu Apr 9 10:47:41 2015
affiliates. All rights reserved.
RMAN> show all;
RMAN configuration parameters for database with
db_unique_name PROD are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE
TYPE DISK TO ‘/backup/rman_backup/controlfile_%F’;
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE
TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK
TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE
DISK TO 1; # default
CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT ‘/backup/rman_backup/db_arch_%U.bkp’;
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM ‘AES128’; # default
CONFIGURE COMPRESSION ALGORITHM ‘BASIC’ AS OF RELEASE
‘DEFAULT’ OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; #
default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO
‘/data2/app/oracle/product/11.2.0/dbs/snapcf_prod.f’; # default
RMAN>
RMAN> list backup;
specification does not match any backup in the
repository
RMAN> backup database plus archivelog;
Starting backup at 10-APR-15
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in
backup set
input archived log thread=1 sequence=90 RECID=86
STAMP=875202890
input archived log thread=1 sequence=91 RECID=87
STAMP=875225400
input archived log thread=1 sequence=92 RECID=88
STAMP=875253619
input archived log thread=1 sequence=93 RECID=89
STAMP=875287426
input archived log thread=1 sequence=94 RECID=90
STAMP=875311887
input archived log thread=1 sequence=95 RECID=91
STAMP=875338210
input archived log thread=1 sequence=96 RECID=92
STAMP=875371700
input archived log thread=1 sequence=97 RECID=93
STAMP=875398375
input archived log thread=1 sequence=98 RECID=94
STAMP=875422534
input archived log thread=1 sequence=99 RECID=95
STAMP=875455916
input archived log thread=1 sequence=100 RECID=96
STAMP=875489442
input archived log thread=1 sequence=101 RECID=97
STAMP=875511892
input archived log thread=1 sequence=102 RECID=98
STAMP=875532973
input archived log thread=1 sequence=103 RECID=99
STAMP=875566589
input archived log thread=1 sequence=104 RECID=100
STAMP=875598381
input archived log thread=1 sequence=105 RECID=101
STAMP=875617253
input archived log thread=1 sequence=106 RECID=102
STAMP=875650222
input archived log thread=1 sequence=107 RECID=103
STAMP=875683804
input archived log thread=1 sequence=108 RECID=104
STAMP=875692844
input archived log thread=1 sequence=109 RECID=105
STAMP=875726521
input archived log thread=1 sequence=110 RECID=106
STAMP=875759423
input archived log thread=1 sequence=111 RECID=107
STAMP=875771364
input archived log thread=1 sequence=112 RECID=108
STAMP=875804400
input archived log thread=1 sequence=113 RECID=109
STAMP=875809288
input archived log thread=1 sequence=114 RECID=110
STAMP=875842252
input archived log thread=1 sequence=115 RECID=111
STAMP=875857844
input archived log thread=1 sequence=116 RECID=112
STAMP=875883160
input archived log thread=1 sequence=117 RECID=113
STAMP=875939543
input archived log thread=1 sequence=118 RECID=114
STAMP=875955632
input archived log thread=1 sequence=119 RECID=115
STAMP=875960595
input archived log thread=1 sequence=120 RECID=116
STAMP=876018651
input archived log thread=1 sequence=121 RECID=117
STAMP=876036137
input archived log thread=1 sequence=122 RECID=118
STAMP=876094207
input archived log thread=1 sequence=123 RECID=119
STAMP=876117455
input archived log thread=1 sequence=124 RECID=120
STAMP=876173429
input archived log thread=1 sequence=125 RECID=121
STAMP=876203937
input archived log thread=1 sequence=126 RECID=122
STAMP=876259857
input archived log thread=1 sequence=127 RECID=123
STAMP=876288622
input archived log thread=1 sequence=128 RECID=124
STAMP=876308432
input archived log thread=1 sequence=129 RECID=125
STAMP=876364250
input archived log thread=1 sequence=130 RECID=126
STAMP=876378605
input archived log thread=1 sequence=131 RECID=127
STAMP=876398550
input archived log thread=1 sequence=132 RECID=128
STAMP=876399532
input archived log thread=1 sequence=133 RECID=129
STAMP=876419413
input archived log thread=1 sequence=134 RECID=130
STAMP=876421079
input archived log thread=1 sequence=135 RECID=131
STAMP=876461598
input archived log thread=1 sequence=136 RECID=132
STAMP=876504610
input archived log thread=1 sequence=137 RECID=133
STAMP=876548085
input archived log thread=1 sequence=138 RECID=134
STAMP=876567056
input archived log thread=1 sequence=139 RECID=135
STAMP=876567230
input archived log thread=1 sequence=140 RECID=136
STAMP=876583581
input archived log thread=1 sequence=141 RECID=137
STAMP=876583754
input archived log thread=1 sequence=142 RECID=138
STAMP=876586722
input archived log thread=1 sequence=143 RECID=139
STAMP=876586874
input archived log thread=1 sequence=144 RECID=140
STAMP=876641790
input archived log thread=1 sequence=145 RECID=141
STAMP=876670700
channel ORA_DISK_1: starting piece 1 at 10-APR-15
channel ORA_DISK_1: finished piece 1 at 10-APR-15
piece handle=/backup/rman_backup/db_arch_2qq41rnc_1_1.bkp
tag=TAG20150410T153820 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed
time: 00:01:35
Finished backup at 10-APR-15
Starting backup at 10-APR-15
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup
set
input datafile file number=00001
name=/data2/prod/system01.dbf
input datafile file number=00002
name=/data2/prod/sysaux01.dbf
input datafile file number=00005
name=/data2/prod/example01.dbf
input datafile file number=00003
name=/data2/prod/undotbs01.dbf
input datafile file number=00006
name=/data2/prod/data01.dbf
input datafile file number=00004
name=/data2/prod/users01.dbf
input datafile file number=00007
name=/data2/prod/test01.dbf
input datafile file number=00008
name=/data2/prod/tools01.dbf
channel ORA_DISK_1: starting piece 1 at 10-APR-15
channel ORA_DISK_1: finished piece 1 at 10-APR-15
piece
handle=/backup/rman_backup/db_arch_2rq41rqd_1_1.bkp tag=TAG20150410T153956
comment=NONE
channel ORA_DISK_1: backup set complete, elapsed
time: 00:01:05
Finished backup at 10-APR-15
Starting backup at 10-APR-15
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in
backup set
input archived log thread=1 sequence=146 RECID=142
STAMP=876670863
channel ORA_DISK_1: starting piece 1 at 10-APR-15
channel ORA_DISK_1: finished piece 1 at 10-APR-15
piece
handle=/backup/rman_backup/db_arch_2sq41rsf_1_1.bkp tag=TAG20150410T154103
comment=NONE
channel ORA_DISK_1: backup set complete, elapsed
time: 00:00:01
Finished backup at 10-APR-15
Starting Control File and SPFILE Autobackup at
10-APR-15
piece
handle=/backup/rman_backup/controlfile_c-284539893-20150410-00 comment=NONE
Finished Control File and SPFILE Autobackup at
10-APR-15
RMAN>
4. Create pfile and copy to destination server.
db_unique_name PROD are:
TYPE DISK TO ‘/backup/rman_backup/controlfile_%F’;
TO BACKUPSET; # default
TO 1; # default
DISK TO 1; # default
‘DEFAULT’ OPTIMIZE FOR LOAD TRUE ; # default
default
‘/data2/app/oracle/product/11.2.0/dbs/snapcf_prod.f’; # default
repository
backup set
STAMP=875202890
STAMP=875225400
STAMP=875253619
STAMP=875287426
STAMP=875311887
STAMP=875338210
STAMP=875371700
STAMP=875398375
STAMP=875422534
STAMP=875455916
STAMP=875489442
STAMP=875511892
STAMP=875532973
STAMP=875566589
STAMP=875598381
STAMP=875617253
STAMP=875650222
STAMP=875683804
STAMP=875692844
STAMP=875726521
STAMP=875759423
STAMP=875771364
STAMP=875804400
STAMP=875809288
STAMP=875842252
STAMP=875857844
STAMP=875883160
STAMP=875939543
STAMP=875955632
STAMP=875960595
STAMP=876018651
STAMP=876036137
STAMP=876094207
STAMP=876117455
STAMP=876173429
STAMP=876203937
STAMP=876259857
STAMP=876288622
STAMP=876308432
STAMP=876364250
STAMP=876378605
STAMP=876398550
STAMP=876399532
STAMP=876419413
STAMP=876421079
STAMP=876461598
STAMP=876504610
STAMP=876548085
STAMP=876567056
STAMP=876567230
STAMP=876583581
STAMP=876583754
STAMP=876586722
STAMP=876586874
STAMP=876641790
STAMP=876670700
tag=TAG20150410T153820 comment=NONE
time: 00:01:35
set
name=/data2/prod/system01.dbf
name=/data2/prod/sysaux01.dbf
name=/data2/prod/example01.dbf
name=/data2/prod/undotbs01.dbf
name=/data2/prod/data01.dbf
name=/data2/prod/users01.dbf
name=/data2/prod/test01.dbf
name=/data2/prod/tools01.dbf
handle=/backup/rman_backup/db_arch_2rq41rqd_1_1.bkp tag=TAG20150410T153956
comment=NONE
time: 00:01:05
backup set
STAMP=876670863
handle=/backup/rman_backup/db_arch_2sq41rsf_1_1.bkp tag=TAG20150410T154103
comment=NONE
time: 00:00:01
10-APR-15
handle=/backup/rman_backup/controlfile_c-284539893-20150410-00 comment=NONE
10-APR-15
pfile=’/backup/rman_backup/initprod.ora’ from spfile;
initprod.ora
oracle@172.16.110.16:/data1/oracle11g/product/dbs/
100%
1169 1.1KB/s 00:00
prior to start scp/ftp to destination server create directory structure to accommodate Rman backup on destination server.
/backup/rman_backup/
db_arch_2qq41rnc_1_1.bkp
controlfile_c-284539893-20150410-00
oracle@172.16.110.16:/backup/rman_backup/
100% 9792KB 9.6MB/s 00:01
1668MB 11.2MB/s 02:29
100%
1135MB 11.2MB/s 01:41
100% 24KB
23.5KB/s 00:00
Steps on destination server:
6. Create new directory structure.
7. Start the instance in nomount stage using pfile.
16:52:53 2015
9383936 bytes
Edition Release 11.2.0.1.0 – 64bit Production
Application Testing options
8. Connect to rman.
Fri Apr 10 16:54:21 2015
affiliates. All rights reserved.
9. Issue the following command to duplicate database with different name and different directory structure.
TARGET DATABASE TO DUP
‘/backup/rman_backup’
‘/data2/prod/dup’
‘/data2/prod/dup’
LOG_FILE_NAME_CONVERT
‘/data2/prod/dup’;2> 3> 4> 5> 6> 7> 8> 9>
clone spfile to ‘/data1/oracle11g/product/dbs/spfiledup.ora’
from
“alter system set spfile=
”/data1/oracle11g/product/dbs/spfiledup.ora””;
AUTOBACKUP /backup/rman_backup/controlfile_c-284539893-20150410-00
AUTOBACKUP complete
”/data1/oracle11g/product/dbs/spfiledup.ora”
“alter system set db_name =
comment=
scope=spfile”;
“alter system set control_files =
”/data2/prod/dup/control02.ctl” comment=
scope=spfile”;
“alter system set
db_file_name_convert =
scope=spfile”;
“alter system set
LOG_FILE_NAME_CONVERT =
scope=spfile”;
clone immediate;
clone nomount;
”DUP” comment= ”duplicate” scope=spfile
”/data2/prod/dup/control02.ctl” comment= ”” scope=spfile
”” scope=spfile
”” scope=spfile
“alter system set db_name =
comment=
RMAN duplicate” scope=spfile”;
“alter system set db_unique_name =
comment=
RMAN duplicate” scope=spfile”;
clone immediate;
clone force nomount
clone primary controlfile from
‘/backup/rman_backup/controlfile_c-284539893-20150410-00’;
database mount;
”PROD” comment= ”Modified by RMAN duplicate” scope=spfile
duplicate” scope=spfile
time: 00:00:01
scn 5022379;
for datafile 1 to
for datafile 2 to
for datafile 3 to
for datafile 4 to
for datafile 5 to
for datafile 6 to
for datafile 7 to
for datafile 8 to
database
restore
restore from backup set
/data2/prod/dup/system01.dbf
/data2/prod/dup/sysaux01.dbf
/data2/prod/dup/undotbs01.dbf
/data2/prod/dup/users01.dbf
/data2/prod/dup/example01.dbf
/data2/prod/dup/data01.dbf
/data2/prod/dup/test01.dbf
/data2/prod/dup/tools01.dbf
/backup/rman_backup/db_arch_2rq41rqd_1_1.bkp
tag=TAG20150410T153956
time: 00:00:35
datafile all;
name=/data2/prod/dup/system01.dbf
name=/data2/prod/dup/undotbs01.dbf
name=/data2/prod/dup/users01.dbf
name=/data2/prod/dup/example01.dbf
name=/data2/prod/dup/data01.dbf
name=/data2/prod/dup/test01.dbf
name=/data2/prod/dup/tools01.dbf
scn 5022379;
database
archivelog
to default destination
/backup/rman_backup/db_arch_2sq41rsf_1_1.bkp
handle=/backup/rman_backup/db_arch_2sq41rsf_1_1.bkp tag=TAG20150410T154103
time: 00:00:01
thread=1 sequence=146
name=/data1/oracle11g/product/dbs/arch1_146_872701561.dbf RECID=1
STAMP=876675584
clone immediate;
clone nomount;
“alter system set db_name =
comment=
original value by RMAN” scope=spfile”;
“alter system reset db_unique_name
scope=spfile”;
clone immediate;
clone nomount;
”DUP” comment= ”Reset to original value by RMAN” scope=spfile
“DUP” RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
M REUSE,
M REUSE,
( ‘/data2/prod/dup/redo03.log’ ) SIZE 50 M
REUSE
‘/data2/prod/dup/system01.dbf’
WE8MSWIN1252
for tempfile 1 to
tempfile all;
clone datafilecopy
“/data2/prod/dup/sysaux01.dbf”,
datafile all;
control file
RECID=1 STAMP=876675609
RECID=2 STAMP=876675609
RECID=3 STAMP=876675609
RECID=4 STAMP=876675609
RECID=5 STAMP=876675610
RECID=6 STAMP=876675610
RECID=7 STAMP=876675611
name=/data2/prod/dup/sysaux01.dbf
name=/data2/prod/dup/undotbs01.dbf
name=/data2/prod/dup/users01.dbf
name=/data2/prod/dup/example01.dbf
name=/data2/prod/dup/data01.dbf
name=/data2/prod/dup/test01.dbf
name=/data2/prod/dup/tools01.dbf
database open resetlogs;
Conclusion
In the above article, we have learned that backup based duplication using Rman utility with different database name and different directory structure, using spfile
BY
Name: Omer
Designation: Senior Database Engineer
Organization: Netsoftmate IT Solutions.
Email: info@netsoftmate.com
Leave a Reply