Vous êtes sur la page 1sur 6

DUPLICATE FROM ACTIVE DATABASE USING

RMAN, A STEP-BY-STEP GUIDE


https://www.pythian.com/blog/duplicate-from-active-database-using-rman-step-by-step/

Duplicate using RMAN


Recently, I had a request from one of our clients to duplicate a single
instance database into a two node RAC database. Both source and
destination databases were 11g Rel 2 on Linux.

I could take the old approach and use RMAN backups or use 11gs new
feature DUPLICATE FROM ACTIVE database, which doesnt need any backup
from target database. I preferred to use the second approach.

Duplicate from ACTIVE database


Duplicating from an active database doesnt require any RMAN backup to be
taken from the source database. Actually, it reads all database structure
from the source database that needs to be mounted or opened during the
duplication. Although this method seems easy as we dont need to backup
source database or make it accessible for auxiliary instance anymore, it has
its own disadvantages as well.

Two big disadvantages of the ACTIVE database duplication method are:

1. Negative performance impact on the source database. This impact applies to


the whole duplication time.
2. High network traffic on the connection between the source and target
databases.

If either of these negative impacts are not acceptable in your environment ,


you will need to switch to the old backup-based approach.
By the way, I think that if you have the latest backup of your source
database available and it can be accessed by auxiliary instance, the best
method for duplication is still the backup-based approach.
Duplicate from active database is an easy task ONLY IF you follow all the
steps accurately. Otherwise, it can be a complicated task, and you can waste
your time troubleshooting.

The following part is simplified step-by-step instructions for DUPLICATE from


ACTIVE database:

Step-by-step instructions
In this guide, assume we are migrating a single instance database HRDEV to a two
node RAC database HRPRD with the following specifications:

Source database:
Database name: HRDEV

Single instance

Version: 11.2.0.3

Hostname: dev-db-01

Filesystem: ASM

Target database:

Database name: HRPRD

RAC 2 nodes

Version: 11.2.0.3

ORACLE_HOME: /apps/oracle/product/11.2.0/db_1

GI_HOME: /apps/grid/11.2.0/

Hostname: prd-db-01/prd-db-02

Filesystem: ASM

Diskgroup: +HR

For target database HRPRD, we assume that an empty database has already been
created with two instances, spfile and controlfiles already exist, and the database is
already a member of clusterware. As a matter of fact, we will use only instances of
this database as auxiliary instance, and all datafiles can be deleted manually before
duplication, as this database is going to be a refreshed from HRDEV database by
our DUPLICATE command.

The diskgroup that will be used for this database is +HR.

1- Prepare auxiliary instance HRPRD1 on prd-db-01:


Stop all instances of your cluster database except one.
In this example, we will use only the HRPRD1 instance, which runs on prd-
db-01. We need to stop the other instance, HRPRD2:
1 srvctl stop instance -d HRPRD -i HRPRD2

Set the following parameters on HRPRD1 instance:


1
. oraenv HRPRD1
2 sqlplus / as sysdba
3

4 alter system set db_name=HRPRD scope=spfile;


5 alter system set cluster_database=false scope=spfile;

6 alter system set db_create_file_dest='+HR';

7 alter system set db_create_online_log_dest_1='+HR';

8
shutdown immediate
9
startup nomount
10

2- Enable status registration for HRPRD1 to run LISTENER:


Add the following entries into listener.ora file in GI_HOME.

Edit /apps/grid/11.2.0/network/admin/listener.ora and add the following lines:


SID_LIST_LISTENER =
1
(SID_LIST =
2
)
3
(SID_DESC =
4
(SID_NAME = HRPRD1)
5 (ORACLE_HOME = /apps/oracle/product/11.2.0/db_1)

6 (GLOBAL_DBNAME = HRPRD)

)
7
)
8

Make sure that ORACLE_HOME in this entry points to correct home, which is
the home from which HRPRD database runs.

3- Add following TNS entries to BOTH auxiliary and target


tnsnames.ora file:
1
HRDEV =
2
(DESCRIPTION =
3
(ADDRESS = (PROTOCOL = TCP)(HOST = dev-db-01)(PORT = 1521))
4
(CONNECT_DATA =
5
(SERVER = DEDICATED)
6 (SERVICE_NAME = HRDEV)
7 )
8 )

10 HRPRD1 =

11 (DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = prd-db-01)(PORT = 1521))


12
(CONNECT_DATA =
13
(SERVER = DEDICATED)
14
(SERVICE_NAME = HRPRD)
15
)
16 )
17
4- Ceate a password file for auxiliary instance HRPRD1 on prd-
db-01:
Connections to both instances will be through listener and TNS, so we need
to use passwords for both auxiliary and target connections.

For HRPRD, since it is a new and empty database, we may need to create a
password file for it as follows:
1 . oraenv
2 HRPRD1

3 cd $ORACLE_HOME/dbs

4 orapwd password=sys file=orapwHRPRD1

I have assumed that the SYS password on the source database HRDEV is sys.

5- Test connectivity to auxiliary and target instances from BOTH


hosts using TNS:
Make sure your connectivity to the source database and to your auxiliary
instance works fine; otherwise, duplicate from active database wont work.
1 sqlplus sys/sys@HRPRD1 as sysdba

2 sqlplus sys/sys@HRDEV as sysdba

Try above commands on both target and auxiliary hosts prd-db-01 and dev-db-
01. Do not continue unless your connectivity is fine.

6- On the auxiliary host, start RMAN and run the DUPLICATE


command:
From host prd-db-01, which runs auxiliary instance hrprd1, start RMAN.
Make sure the auxiliary connection is established through listener and not
through OS authentication.
. oraenv
1
HRPRD1
2
rman target sys/sys@HRDEV auxiliary sys/sys@hrprd1
3
RMAN>run{
4 DUPLICATE TARGET DATABASE TO HRPRD

5 FROM ACTIVE DATABASE;

}
6

7- When step 6 finishes successfully, start HRPRD database


using srvctl. You need to enable the second thread as well:
Change the HRPRD database to be a cluster database again and start both
instances:
1
. oraenv HRPRD1
2
sqlplus / as sysdba
3

4 alter database add logfile thread 2 group 4 size 200m;


5 -- add few more groups
6 create tablespace UNDOTBS2 datafile '+HR' size 1g;

7 alter system set undo_tablespace='UNDOTBS2' sid='HRPRD2';

8 alter database enable public thread 2;

alter system set cluster_database=true scope=spfile;


9
shutdown immediate
10

11
srvctl start db -d HRPRD
12

Thats all. I hope it will work for you!

Vous aimerez peut-être aussi