Tuesday, October 6, 2009

RMAN Cloning(Duplicating a Database using RMAN - (UNIX / Linux))

1. Create Password File for Auxiliary Database
orapwd file=$ORACLE_HOME/dbs/orpwred password=sys entries=5

2. Create the directories for dumps :
$ mkdir /u01/app/oracle/product/10.2.0/admin/red/adump
$mkdir /u01/app/oracle/product/10.2.0/admin/red/bdump
$mkdir /u01/app/oracle/product/10.2.0/admin/red/cdump
$mkdir /u01/app/oracle/product/10.2.0/admin/red/udump

$mkdir /d01/aaa/red

3. Create an Initialization Parameter for the Auxiliary Database:

Copy the initialization parameter from the target database and make the necessary changes for the duplicated database.
red.__db_cache_size=281018368
red.__java_pool_size=4194304
red.__large_pool_size=4194304
red.__shared_pool_size=297795584
red.__streams_pool_size=8388608
*.audit_file_dest='/u01/app/oracle/product/10.2.0/admin/red/adump'
*.background_dump_dest='/u01/app/oracle/product/10.2.0/admin/red/bdump'
*.cluster_database_instances=2
*.compatible='10.2.0.3.0'
*.control_files='/d01/aaa/red/control01.ctl','/d01/aaa/red/control02.ctl','/d01/aaa/red/control03.ctl'
*.core_dump_dest='/u01/app/oracle/product/10.2.0/admin/red/cdump'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='red'
*.db_recovery_file_dest='/d01/aaa'
*.db_recovery_file_dest_size=2147483648
*.dispatchers='(PROTOCOL=TCP) (SERVICE=redXDB)'
*.job_queue_processes=10
*.open_cursors=300
*.pga_aggregate_target=200278016
*.processes=150
*.remote_login_passwordfile='NONE'
*.sga_target=601882624
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/u01/app/oracle/product/10.2.0/admin/red/udump'

3. $ export ORACLE_SID=

$ sqlplus sys as sysdba
SQL> create pfile='/u01/app/oracle/product/10.2.0/db_1/dbs/initred.ora' from spfile;
File created

4. Create / Start the Auxiliary Instance


export ORACLE_SID=RED

sqlplus sys as sysdba
SQL> startup nomount

5. Modify both the listener.ora and tnsnames.ora file to be able to connect to the auxiliary database


listener.ora :

SID_LIST_LISTENER =

(SID_LIST =

(SID_DESC =

(SID_NAME = target_database)

(ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)

(PROGRAM =target_database )

)

(SID_DESC =
(SID_NAME = RED)
(ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
(PROGRAM =RED )
)

...

...

)

in tnsnames.ora , add the following entry:

RED =

(DESCRIPTION =

(ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.122)(PORT = 1521)) )

(CONNECT_DATA = (SERVICE_NAME = RED) ) )

....

6. reload the listener.

7. Mount or Open the Target Database
$ export ORACLE_SID=

$ sqlplus "/ as sysdba"
SQL> startup
8. Ensure You Have the Necessary Backups and Archived Redo Log Files
Login to Target Database:


$ rman target sys/change_on_install@target_database


Recovery Manager: Release 10.2.0.3.0 - Production on Wed May 21 13:30:37 2008


Copyright (c) 1982, 2005, Oracle. All rights reserved.

connected to target database: (DBID=2641020194)




RMAN> backup database;
RMAN> list backup summary;
RMAN>exit;

9. Connect to auxiliary database:

$export ORACLE_SID=red

$ rman target sys/change_on_install@target_database
Recovery Manager: Release 10.2.0.3.0 - Production on Wed May 21 13:30:37 2008
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: (DBID=2641020194)


RMAN> connect auxiliary RED
auxiliary database Password:
connected to auxiliary database: RED (not mounted)

RMAN>
run
{
set newname for datafile 1 to "/d01/aaa/red/system01.dbf";
set newname for datafile 2 to "/d01/aaa/red/undotbs01.dbf";
set newname for datafile 3 to "/d01/aaa/red/sysaux01.dbf";
set newname for datafile 4 to "/d01/aaa/red/users01.dbf";
set newname for datafile 5 to "/d01/aaa/red/rman01.dbf";
set newname for tempfile 1 to "/d01/aaa/red/temp01.dbf";
duplicate target database to "RED"
logfile
group 1 ('/d01/aaa/red/redo01.log') size 20m,
group 2 ('/d01/aaa/red/redo02.log') size 20m,
group 3 ('/d01/aaa/red/redo03.log') size 20m;
}

in the auxiliary database terminal :

SQL> select * from V$database;

SQL> shutdown immediate;

SQL> startup mount;

SQL> alter database archivelog;

SQL> alter database open;

No comments:

Post a Comment