You can create a duplicate database using the RMAN duplicate
command. The duplicate database has a different DBID from the source database
and functions entirely independently. Starting from 11g you can do duplicate
database in 2 ways.
1. Active database duplication
2. Backup-based duplication
2. Backup-based duplication
Active database duplication copies the live target database
over the network to the auxiliary destination and then creates the duplicate
database. Only difference is that you don't need to have the pre-existing RMAN
backups and copies. The duplication work is performed by an auxiliary
channel. This channel corresponds to a server session on the auxiliary
instance on the auxiliary host.
As part of the duplicating operation, RMAN automates the
following steps:
1. Creates a control file for the duplicate database
2. Restarts the auxiliary instance and mounts the duplicate control file
3. Creates the duplicate datafiles and recovers them with incremental backups and archived redo logs.
4. Opens the duplicate database with the RESETLOGS option
1. Creates a control file for the duplicate database
2. Restarts the auxiliary instance and mounts the duplicate control file
3. Creates the duplicate datafiles and recovers them with incremental backups and archived redo logs.
4. Opens the duplicate database with the RESETLOGS option
For the active
database duplication, RMAN does one extra step .i.e. copy the target database
datafiles over the network to the auxiliary instance
Source(TARGET)
instance information:
Instance name=DLINK
hostname=mydbt4db2
datafile
location=/u03/oradata/DLINK, /u02/oradata/DLINK
Redolog file
location=/u03/oradata/DLINK
Archive log file
location=/u02/oradata/arch
Auxiliary instance
information:
Instance name=TLINK
hostname=mydbt4db4
datafile
location=/u03/oradata/TLINK, /u02/oradata/TLINK
Redolog file
location=/u03/oradata/TLINK
Archive log file
location=/u02/oradata/arch_TLINK
Note: Before proceeding with active duplication ,rman should
be fully configured on
Source side with or without catalog database.
1 )Define ORACLE_SID
and other required settings for auxiliary instnace
[oracle@mydbt4db4 ~]$
vi .bash_profile
[oracle@mydbt4db4 ~]$
. .bash_profile
[oracle@mydbt4db4 ~]$
echo $ORACLE_HOME
/u01/app/oracle/product/11.2.0/dbhome_1
[oracle@mydbt4db4 ~]$
echo $ORACLE_SID
TLINK
[oracle@mydbt4db4 ~]$
echo $TNS_ADMIN
/u01/app/oracle/product/11.2.0/dbhome_1/network/admin
[oracle@mydbt4db4 ~]$
1.b)Create required directory structure at auxiliary
side
[oracle@mydbt4db4 admin]$ mkdir -p /u02/oradata/TLINK
[oracle@mydbt4db4 admin]$ mkdir -p /u03/oradata/TLINK
[oracle@mydbt4db4 admin]$ mkdir -p
/u02/oradata/arch_TLINK
2) Creating initialization Parameter file for the
Auxiliary instance(TLINK)
[oracle@mydbt4db4
dbs]$ cd $ORACLE_HOME/dbs
[oracle@mydbt4db4
dbs]$ vi initTLINK.ora
[oracle@mydbt4db4
dbs]$ more initTLINK.ora
db_name='TLINK'
memory_target=200M
db_block_size=8192
control_files
='/u02/oradata/TLINK/control1.ctl','/u03/oradata/TLINK/control2.ctl'
compatible ='11.2.0'
log_archive_dest=/u02/oradata/arch_TLINK
log_file_name_convert='/u03/oradata/DLINK','/u03/oradata/TLINK'
db_file_name_convert='/u03/oradata/DLINK','/u03/oradata/TLINK','/u02/oradata/DLINK','/u02/oradata/TLINK'
3) Create password
file at auxiliary side(TLINK)
[oracle@mydbt4db4
~]$ cd $ORACLE_HOME/dbs
[oracle@mydbt4db4
dbs]$ orapwd file=orapw$ORACLE_SID password=sys force=y
[oracle@mydbt4db4
dbs]$ ls -ltr orapw*
-rw-r-----
1 oracle oinstall 1536 Nov 26 13:44 orapwTLINK
4)
Start auxiliary instance
[oracle@mydbt4db4 dbs]$ sqlplus '/as sysdba'
SQL*Plus:
Release 11.2.0.1.0 Production on Mon Nov 26 13:50:00 2012
Copyright
(c) 1982, 2009, Oracle. All rights
reserved.
Connected
to an idle instance.
SQL>
startup nomount;
ORACLE
instance started.
5)
Configure listener at auxiliary side
[oracle@mydbt4db4
dbs]$ cd $TNS_ADMIN
[oracle@mydbt4db4
admin]$ vi listener.ora
[oracle@mydbt4db4
admin]$ more listener.ora
TLINK =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = mydbt4db4.redLINKtech.com)(PORT
= 1526))
)
)
SID_LIST_TLINK
=
(SID_LIST =
(SID_DESC =
(ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME = TLINK)
)
)
[oracle@mydbt4db4
admin]$ lsnrctl start TLINK
6)
Configure listener at TARGET(source) side
[oracle@mydbt4db2
admin]$ cd $TNS_ADMIN
[oracle@mydbt4db2
admin]$ vi listener.ora
[oracle@mydbt4db2
admin]$ more listener.ora
DLINK =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = mydbt4db2.redLINKtech.com)(PORT
= 1525))
)
)
SID_LIST_DLINK
=
(SID_LIST =
(SID_DESC =
(ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME = DLINK)
)
)
[oracle@mydbt4db2
admin]$ lsnrctl start DLINK
7)Create
password file at TARGET(DLINK) side
[oracle@mydbt4db2
admin]$ cd $ORACLE_HOME/dbs
[oracle@mydbt4db2
dbs]$ orapwd file=orapw$ORACLE_SID password=sys force=y
[oracle@mydbt4db2
dbs]$ ls -ltr orapw*
-rw-r-----
1 oracle oinstall 1536 Nov 26 02:29 orapwDLINK
[oracle@mydbt4db2
dbs]$
8)
Configure tns alias at auxiliary(TLINK) to connect TARGET database(DLINK).
[oracle@mydbt4db4
admin]$ cd $TNS_ADMIN
[oracle@mydbt4db4
admin]$ vi tnsnames.ora
[oracle@mydbt4db4
admin]$ more tnsnames.ora
to_dLINK=
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=mydbt4db2.redLINKtech.com)(PORT=1525))
(CONNECT_DATA=
(SID=DLINK)
)
)
to_tLINK=
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=mydbt4db4.redLINKtech.com)(PORT=1526))
(CONNECT_DATA=
(SID=TLINK)
)
)
[oracle@mydbt4db4
admin]$ tnsping to_dLINK
TNS
Ping Utility for Linux: Version 11.2.0.1.0 - Production on 26-NOV-2012 14:15:40
Copyright
(c) 1997, 2009, Oracle. All rights
reserved.
Used
parameter files:
Used
TNSNAMES adapter to resolve the alias
Attempting
to contact (DESCRIPTION= (ADDRESS=(PROTOCOL=tcp)(HOST=mydbt4db2.redLINKtech.com)(PORT=1525))
(CONNECT_DATA= (SID=DLINK)))
OK (70
msec)
[oracle@mydbt4db4
admin]$ tnsping to_tLINK
TNS
Ping Utility for Linux: Version 11.2.0.1.0 - Production on 26-NOV-2012 14:15:51
Copyright
(c) 1997, 2009, Oracle. All rights
reserved.
Used
parameter files:
Used
TNSNAMES adapter to resolve the alias
Attempting
to contact (DESCRIPTION= (ADDRESS=(PROTOCOL=tcp)(HOST=mydbt4db4.redLINKtech.com)(PORT=1526))
(CONNECT_DATA= (SID=TLINK)))
OK (50
msec)
9)
Configure tns alias at Target(DLINK) to connect auxiliary instance (TLINK).
[oracle@mydbt4db2
admin]$ cd $TNS_ADMIN
[oracle@mydbt4db2
admin]$
[oracle@mydbt4db2
admin]$ vi tnsnames.ora
[oracle@mydbt4db2
admin]$ more tnsnames.ora
to_tLINK=
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=mydbt4db4.redLINKtech.com)(PORT=1526))
(CONNECT_DATA=
(SID=TLINK)
)
)
[oracle@mydbt4db2
admin]$ tnsping to_tLINK
TNS Ping
Utility for Linux: Version 11.2.0.1.0 - Production on 26-NOV-2012 02:27:09
Copyright
(c) 1997, 2009, Oracle. All rights
reserved.
Used
parameter files:
Used
TNSNAMES adapter to resolve the alias
Attempting
to contact (DESCRIPTION= (ADDRESS=(PROTOCOL=tcp)(HOST=mydbt4db4.redLINKtech.com)(PORT=1526))
(CONNECT_DATA= (SID=TLINK)))
OK (180
msec)
[oracle@mydbt4db2
admin]$
10. Start RMAN and Connect to the Database Instances
Start RMAN and connect to the source database as TARGET,
the duplicate database instance as AUXILIARY, and, if applicable, the recovery
catalog database. You can start the RMAN client on any host so long as it can
connect to all of the database instances. If the auxiliary instance requires a
text-based initialization parameter file, then this file must exist on the same
host that runs the RMAN client application.
In this bulletin we are doing duplicate database from the
auxiliary server. Look at the example :
[oracle@mydbt4db4 admin]$ rman
Recovery Manager: Release 11.2.0.1.0 - Production on Mon
Nov 26 14:53:24 2012
Copyright (c) 1982, 2009, Oracle and/or its
affiliates. All rights reserved.
RMAN> connect target sys/sys@to_dLINK
connected to target database: DLINK (DBID=2903807241)
RMAN> connect auxiliary sys/sys@to_tLINK
connected to auxiliary database: TLINK (not mounted)
11) Run the DUPLICATE database command
The simplest case is to use active
database duplication to duplicate the database to a different host and use the different directory
structure. Look at the example :
RMAN> DUPLICATE TARGET DATABASE
2> to 'TLINK'
3> FROM ACTIVE DATABASE;
Starting Duplicate Db at 26-NOV-12
using target database control file instead of recovery
catalog
configuration for DISK channel 2 is ignored
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=96 device type=DISK
contents of Memory Script:
{
sql clone
"create spfile from memory";
}
executing Memory Script
.
.
.
.
contents of Memory Script:
{
Alter clone database
open resetlogs;
}
executing Memory Script
database opened
Finished Duplicate Db at 26-NOV-12
RMAN>
No comments:
Post a Comment