Thursday 6 June 2013

11gr2 cloning with RMAN DUPLICATE command, backup based without connecting to source database

Cloning with RMAN using duplication command without connecting to target database

1) In clone server:

Install 11gr2 software only

In source server:

2) Get the file path information using below query

SQL> Select name from v$datafile;
SQL> select member from v$logfile;
SQL> select name from v$controlfile;


3) Take backup of the database.

RMAN> Configure controlfile autobackup on;
RMAN> backup database plus archivelog;

4)create pfile from spfile

SQL>create pfile from spfile;

5)Copy the pfile, password file, backupsets to auxilliary server.
 
$scp initorcl.ora orapworcl oracle@192.168.187.132:/u01/backup
$scp backupsets autobackups archivelogs oracle@192.168.187.132:/u01/backup

in clone server:

6)copy pfile and password files to ORACLE_HOME/dbs location

$ cp initorcl.ora $ORACLE_HOME/dbs/initclone.ora
$ cp orapworcl   $ORACLE_HOME/dbs/orapwclone

7) modify pfile for duplicate database.

-      Replace orcl with clone
-      add following two parameters

db_file_name_convert=’/u01/app/oracle/oradata/orcl’,’/u01/app/oracle/oradata/clone’
log_file_name_convert=’/u01/app/oracle/oradata/orcl’,’/u01/app/oracle/oradata/clone’

8)create required directories
  
in this example I am using same location for datafiles and redolog files

$mkdir –p /u01/app/oracle/oradata/clone
$mkdir –p /u01/app/oracle/flash_recovery_area/clone  (for control file 2)
$mkdir –p /u01/app/oracle/admin/clone/adump

9)Start auxilliary instance

$ export ORACLE_SID=clone

$ sqlplus "/ as sysdba"

SQL> startup nomount;

SQL>exit

Start listener

Configure tnsnames.ora

Check connectivity by connect using service name.

 $sqlplus

 Enter username: sys/*****@clone as sysdba

If you get any error like ‘blocking connections’, 
RMAN-04006: error from auxiliary database: ORA-12528: TNS:listener: all appropriate instances are blocking new connections
try to shut down the database, using command shut immediate and startup again, add (UR=A) to the tnsnames.ora file just bellow the service_id

Ex:

CLONE=
 (DESCRIPTION=
  (ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521))
    (CONNECT_DATA=
   (SERVICE_NAME=clone)
  (UR=A)
)
)

While restoring auxiliary database by using RMAN DUPLICATE command RMAN will shut down the database and startup again, so some time in nomount stage in 11gr2 it will not allow to shut down the database, check it is shutting down using shut immediate command
if you are not able to shut down database and you are getting error in alert log file like ‘active connection preventing shut down database’, kill -9 all oracle background processes and startup nomount and

10) Start rman and connect to auxiliary instance

$rman auxiliary /

RMAN> duplicate database to 'CLONE' backup location '/u01/backup';

11)Check database name

$sqlplus ‘/as sysdba’

Sql> select open_mode,name from v$database;

OPEN_MODE            NAME
---------           ------   
READ WRITE           Clone


Done

1 comment: