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.
You can replicate a target (source) database using an RMAN backup when duplicating to an auxiliary (destination) database. The basic idea here is to copy an RMAN backup to an auxiliary server and create the auxiliary database directly from the backup. This is a simple and powerful technique for replicating a database. It is especially applicable where there’s no direct network connection between the target database and the auxiliary.
Here we are having same database name and same directory structure. And target database have read only tablespaces.
Environment details
Target
(source) details:
|
Database Name
|
prod
|
|
Hostname
|
Nsmdev
|
|
Ip Address
|
172.16.110.18
|
|
OS
|
Linux
|
|
Version
|
x86_64
|
|
Datafile Location
|
/data2/prod
|
|
Backup Location
|
/backup/rman_backup
|
Destination details:
|
Database Name
|
prod
|
|
Hostname
|
Nsmqty
|
|
Ip Address
|
172.16.110.16
|
|
OS
|
Linux
|
|
Version
|
x86_64
|
|
Datafile Location
|
/data2/prod
|
|
Backup Location
|
/backup/rman_backup
|
Pre-requisites
- Password file from target database.
- Sqlnet.ora should have correct parameters.
- Target database should be running through spfile.
Steps on target (source) server
1. export Oracle sid.
hostname
ORACLE_SID=prod
2. Login to database and check tablespace details.
tablespace_name,status from dba_tablespaces;
———-
3. Connect to RMAN.
target sys/oracle
11.2.0.1.0 – Production on Wed Apr 15 12:44:17 2015
Oracle and/or its affiliates. All rights
reserved.
database: PROD (DBID=284539893)
4. Issue the following command to initiate backup. Before issue the backup command check the backup location is sat correctly.
parameters for database with db_unique_name PROD are:
TO REDUNDANCY 1; # default
OPTIMIZATION OFF; # default
TYPE TO DISK; # default
AUTOBACKUP ON;
AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO ‘/backup/rman_backup/controlfile_%F’;
PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
COPIES FOR DEVICE TYPE DISK TO 1; # default
COPIES FOR DEVICE TYPE DISK TO 1; # default
TYPE DISK FORMAT
‘/backup/rman_backup/db_arch_%U.bkp’;
UNLIMITED; # default
DATABASE OFF; # default
ALGORITHM ‘AES128’; # default
ALGORITHM ‘BASIC’ AS OF RELEASE ‘DEFAULT’ OPTIMIZE FOR LOAD TRUE ; # default
DELETION POLICY TO NONE; # default
CONTROLFILE NAME TO ‘/data2/app/oracle/product/11.2.0/dbs/snapcf_prod.f’; #
default
plus archivelog;
archived log backup set
specifying archived log(s) in backup set
sequence=161 RECID=157 STAMP=877092331
piece 1 at 15-APR-15
piece 1 at 15-APR-15
tag=TAG20150415T124531 comment=NONE
set complete, elapsed time: 00:00:01
full datafile backup set
specifying datafile(s) in backup set
number=00001 name=/data2/prod/system01.dbf
number=00002 name=/data2/prod/sysaux01.dbf
number=00005 name=/data2/prod/example01.dbf
number=00003 name=/data2/prod/undotbs01.dbf
number=00006 name=/data2/prod/data01.dbf
number=00004 name=/data2/prod/users01.dbf
number=00007 name=/data2/prod/test01.dbf
number=00008 name=/data2/prod/tools01.dbf
piece 1 at 15-APR-15
piece 1 at 15-APR-15
handle=/backup/rman_backup/db_arch_3mq4enfd_1_1.bkp tag=TAG20150415T124533
comment=NONE
set complete, elapsed time: 00:00:55
archived log backup set
specifying archived log(s) in backup set
sequence=162 RECID=158 STAMP=877092389
piece 1 at 15-APR-15
piece 1 at 15-APR-15
handle=/backup/rman_backup/db_arch_3nq4enh6_1_1.bkp tag=TAG20150415T124629
comment=NONE
set complete, elapsed time: 00:00:01
Autobackup at 15-APR-15
handle=/backup/rman_backup/controlfile_c-284539893-20150415-00 comment=NONE
Autobackup at 15-APR-15
5. Create pfile and copy to destination server.
pfile=’/backup/rman_backup/initprod.ora’ from spfile;
scp initprod.ora
oracle@172.16.110.16:/data1/oracle11g/product/dbs/
password:
00:00
create directory structure to accommodate rman backup on destination server and copy the backup pieces.
-p /backup/rman_backup/
6. Copy rman backup to auxiliary database server
scp *.bkp oracle@172.16.110.16://backup/rman_backup/
password:
02:46
01:41
38.0KB/s 00:00
7. Create password file on destination server
file=orapwprod password=ora123
Steps on destination server
8. Create directory structure same as target (source) database.
-p /data2/prod
-p /backup/archive/
9. Start the instance in nomount.
Production on Thu Apr 9 12:14:35 2015
Oracle. All rights reserved.
sysdba
instance.
1152450560 bytes
10. Connect to rman
auxiliary sys/oracle
11.2.0.1.0 – Production on Thu Apr 9 12:19:37 2015
Oracle and/or its affiliates. All rights
reserved.
database: PROD (not mounted)
11. Issue the following command to duplicate database.
duplicate database to prod backup location ‘/backup/rman_backup’
nofilenamecheck;
15-APR-15
memory”;
from memory
database (not started)
Area 1152450560 bytes
scope=spfile”;
scope=spfile”;
‘/backup/rman_backup/controlfile_c-284539893-20150415-00’;
set db_name = ”PROD” comment= ”Modified by RMAN
duplicate” scope=spfile
set db_unique_name = ”PROD” comment= ”Modified by RMAN
duplicate” scope=spfile
Area 1152450560 bytes
15-APR-15
ORA_AUX_DISK_1
SID=63 device type=DISK
restoring control file
restore complete, elapsed time: 00:00:03
name=/data2/prod/control01.ctl
name=/data2/prod/control02.ctl
15-APR-15
ORA_AUX_DISK_1
ORA_AUX_DISK_1
SID=63 device type=DISK
clause
NEWNAME
NEWNAME
NEWNAME
NEWNAME
NEWNAME
NEWNAME
NEWNAME
NEWNAME
15-APR-15
starting datafile backup set restore
specifying datafile(s) to restore from backup set
restoring datafile 00001 to /data2/prod/system01.dbf
restoring datafile 00002 to /data2/prod/sysaux01.dbf
restoring datafile 00003 to /data2/prod/undotbs01.dbf
restoring datafile 00004 to /data2/prod/users01.dbf
restoring datafile 00005 to /data2/prod/example01.dbf
restoring datafile 00006 to /data2/prod/data01.dbf
restoring datafile 00007 to /data2/prod/test01.dbf
restoring datafile 00008 to /data2/prod/tools01.dbf
reading from backup piece /backup/rman_backup/db_arch_3mq4enfd_1_1.bkp
piece handle=/backup/rman_backup/db_arch_3mq4enfd_1_1.bkp tag=TAG20150415T124533
restored backup piece 1
restore complete, elapsed time: 00:00:55
15-APR-15
datafile copy
STAMP=877102442 file name=/data2/prod/system01.dbf
datafile copy
STAMP=877102443 file name=/data2/prod/sysaux01.dbf
datafile copy
STAMP=877102443 file name=/data2/prod/undotbs01.dbf
datafile copy
STAMP=877102444 file name=/data2/prod/users01.dbf
datafile copy
STAMP=877102444 file name=/data2/prod/example01.dbf
datafile copy
STAMP=877102444 file name=/data2/prod/data01.dbf
datafile copy
STAMP=877102445 file name=/data2/prod/test01.dbf
datafile copy
STAMP=877102445 file name=/data2/prod/tools01.dbf
clause
15-APR-15
because file is read-only
because file is read-only
starting archived log restore to default destination
restoring archived log
sequence=162
reading from backup piece /backup/rman_backup/db_arch_3nq4enh6_1_1.bkp
piece handle=/backup/rman_backup/db_arch_3nq4enh6_1_1.bkp
tag=TAG20150415T124629
restored backup piece 1
restore complete, elapsed time: 00:00:01
name=/backup/archive/1_162_872701561.dbf thread=1 sequence=162
deleting archived log(s)
name=/backup/archive/1_162_872701561.dbf RECID=1 STAMP=877102457
elapsed time: 00:00:03
15-APR-15
scope=spfile”;
database (not started)
Area 1152450560 bytes
set db_name = ”PROD” comment= ”Reset to original value by
RMAN” scope=spfile
reset db_unique_name scope=spfile
database (not started)
Area 1152450560 bytes
CONTROLFILE REUSE SET DATABASE “PROD” RESETLOGS ARCHIVELOG
1 ( ‘/data2/prod/redo01.log’ ) SIZE 50 M
REUSE,
2 ( ‘/data2/prod/redo02.log’ ) SIZE 50 M
REUSE,
3 ( ‘/data2/prod/redo03.log’ ) SIZE 50 M
REUSE
NEWNAME
/data2/prod/temp01.dbf in control file
name=/data2/prod/sysaux01.dbf RECID=1 STAMP=877102481
name=/data2/prod/undotbs01.dbf RECID=2 STAMP=877102482
name=/data2/prod/users01.dbf RECID=3 STAMP=877102482
name=/data2/prod/example01.dbf RECID=4 STAMP=877102483
name=/data2/prod/test01.dbf RECID=5 STAMP=877102483
datafile copy
STAMP=877102481 file name=/data2/prod/sysaux01.dbf
datafile copy
STAMP=877102482 file name=/data2/prod/undotbs01.dbf
copy
STAMP=877102482 file name=/data2/prod/users01.dbf
datafile copy
STAMP=877102483 file name=/data2/prod/example01.dbf
datafile copy
STAMP=877102483 file name=/data2/prod/test01.dbf
name=/data2/prod/data01.dbf RECID=6 STAMP=877102546
RECID=7 STAMP=877102547
datafile copy
STAMP=877102546 file name=/data2/prod/data01.dbf
datafile copy
STAMP=877102547 file name=/data2/prod/tools01.dbf
tablespace TOOLS online
tablespace DATA online
15-APR-15
12. Check the tablespaces status once database replicated.
dba_tablespaces;
———-
Conclusion
In the above article, we have learned that backup based duplication using Rman utility with same database name and same directory structure, and target(source) database have Read only tablespaces.
BY
Name: Omer
Designation: Senior Database Engineer
Organization: Netsoftmate IT Solutions.
Email: info@netsoftmate.com
Leave a Reply