RMAN Cloning from prod to test server

Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
Breadcrumb Abstract Shape
  • User AvatarKiran Dalvi
  • 12 Dec, 2021
  • 0 Comments
  • 2 Mins Read

RMAN Cloning from prod to test server

How to duplicate 19c database on remote server 

Using RMAN’s Active Duplicate feature?


Task: 

Task is to clone a database called TESTDB to CLONEDB using RMAN’s Active Duplicate feature.


Source and Destination is as follows:

Subject

Source

Destination

IP Address:

192.168.0.197

192.168.0.198

Database Name:

TESTDB

CLONEDB

Database Status

OPEN

Not Available yet

Database Version:

19.0.0

19.0.0

ORACLE_BASE:

data/app/oracle

/data/app/oracle

ORACLE_HOME:

/data/app/oracle/product/19C/dbhome_3



/data/app/oracle/product/19C/dbhome


Listener Name:

LISTENER

LISTENER

Listener Port:

1521

1521

Listener Status

Up

Up


On Source Database Server:

No

Description

Command / Details / Screenshots

1

Login to Source Database Srver and set oracle environment. 

. oraenv → TESTDB

2

Create passwordfile if not already created.

orapwd file=$ORACLE_HOME/dbs/orapw$ORACLE_SID password=”abc123″ format=12 force=y



ls -1 $ORACLE_HOME/dbs/orapw$ORACLE_SID


3

Send Passwordfile to destination server.

scp orapwTESTDB [email protected]:/data/app/oracle/product/19C/dbhome/dbs/orapwTESTDB

 

4

Update tnsnames.ora file with both source and database connection string

cd $ORACLE_HOME/network/admin


vi tnsnames.ora


TESTDB =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.197)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = TESTDB)

    )

  )


CLONEDB =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.198)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = CLONEDB)

    )

  )



5

Verify connection string

tail -4 tnsnames.ora

tnsping TESTDB

tnsping CLONEDB


On Destination Server:

6

Putty to Destination server with credentials


7

Add CLONEDB database entry in oratab

cat >> /etc/oratab << EOF

CLONEDB:/data/app/oracle/product/19C/dbhome:N

EOF



# Verify ORACLE_SID is available in /etc/oratab file

grep $ORACLE_SID /etc/oratab

8

Add Static server in listener.ora file

cd $ORACLE_HOME/network/admin

vi listener.ora


SID_LIST_LISTENER =

  (SID_LIST =

    (SID_DESC=

      (GLOBAL_DBNAME = CLONEDB)

      (ORACLE_HOME = /data/app/oracle/product/19C/dbhome)

      (SID_NAME = CLONEDB)

    )


  )



9

Reload listener

lsnrctl reload listener


# Verify Service is registered

lsnrctl status listener |grep $ORACLE_SID

10

Set oracle environment to destination database.

. oraenv → CLONEDB

11

Update tnsnames.ora file with both source and database connection string


cd $ORACLE_HOME/network/admin


vi tnsnames.ora


TESTDB =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.197)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = TESTDB)

    )

  )


CLONEDB =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.198)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = CLONEDB)

    )

  )



12

Verify connection string

tail -4 tnsnames.ora

tnsping TESTDB

tnsping CLONEDB

13

Make changes in init.ora to reflect new database name.Replace TESTDB to CLONEDB

cd $ORACLE_HOME/dbs

vi init$ORACLE_SID.ora

DB_NAME=CLONEDB

ESC

:wq!

14

Create all database directories for .

[oracle@stand dbs]$ mkdir -p /data/app/oracle/admin/CLONEDB/adump

[oracle@stand dbs]$ mkdir-p/data/app/oracle/oradata/CLONEDB

[oracle@stand dbs]$ mkdir -p /data/app/oracle/oradata/CLONEDB

[oracle@stand dbs]$ mkdir -p /data/app/oracle/oradata/CLONEDB

[oracle@stand dbs]$ mkdir -p /data/app/oracle

[oracle@stand dbs]$ mkdir -p /data/app/oracle/product/19C/dbhome/dbs/arch



15

Startup database in nomount mode

sqlplus / as sysdba

startup nomount;

exit;

16

Connect to auxiliary instance with rman and start duplicating database


rman target sys/abc123@TESTDB auxiliary sys/abc123@CLONEDB

duplicate target  database to CLONEDB

from active database

SPFILE

parameter_value_convert (‘TESTDB’,’CLONEDB’)

set log_archive_dest_1=’location=/data/app/oracle/product/19C/dbhome/dbs/arch’

NOFILENAMECHECK;

exit;







17

Verify database is up and running

. oraenv → CLONEDB

sqlplus / as sysdba

col db_unique_name format a14

col created format a20

Select name, dbid, db_unique_name, to_char(created,’DD-MON-YY HH24:MI:SS’) as created  from v$database;


Select instance_name, status from v$instance;


exit;