Sunteți pe pagina 1din 11

RMAN CLONING IN SAME SERVER | ORACLE 10g

RMAN CLONING IN SAME SERVER


The process of duplicating the entire database is called CLONING. RMAN provides the DUPLICATE
command, which uses the backups of the database to create the clone database.

Source

database name

Auxiliary database name

: sham
: rose

Source database path=/u01/app/oracle/oradata/sham/


Auxiliary database path=/u01/app/oracle/oradata/rose/

CREATING DIRECTORY STRUCTURE FOR AUXILIARY DATABASE


$ mkdir -p /u01/app/oracle/oradata/rose/
$ mkdir -p /u01/app/oracle/admin/rose/adump/
$ mkdir -p /u01/app/oracle/admin/rose/bdump/
$ mkdir -p /u01/app/oracle/admin/rose/cdump/
$ mkdir -p /u01/app/oracle/admin/rose/udump/

CONNECTING SOURCE DATABASE


SYS>select name, dbid from v$database;
NAME
DBID
--------- ---------SHAM
926116387
SYS>show parameter db_domain;
NAME
TYPE
VALUE
------------------------------------ ----------- -----------------------------db_domain
string
server1.com
SYS>show parameter service_names;
NAME
TYPE
VALUE
------------------------------------ ----------- ---------------------service_names
string
sham.server1.com
PARAMETER FILE BACKUP FOR AUXILIARY DATABASE
SYS> show parameter pfile;
NAME
------spfile

TYPE
VALUE
--------- -----------------------------------------------------string
/u01/app/oracle/product/10.2.0/db_1/dbs/spfilesham.ora

SYS> create pfile from spfile;


File created.
$ cd $ORACLE_HOME/dbs
$ mv initsham.ora initrose.ora

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

RMAN CLONING IN SAME SERVER | ORACLE 10g

CREATING PASSWORD FILE FOR AUXILIARY DATABASE


$ export ORACLE_SID=rose
$ cd

$ORACLE_HOME/dbs/

$ orapwd file=orapwrose password=dba force=y entries=3


$ ls -l orapw*
-rw-r----- 1 oracle oinstall 1536 Nov

6 15:38 orapwrose

-rw-r----- 1 oracle oinstall 1536 Nov

5 16:11 orapwsham

TARGET DATABASE PFILE


sham.__db_cache_size=260046848
sham.__java_pool_size=4194304
sham.__large_pool_size=4194304
sham.__shared_pool_size=100663296
sham.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/sham/adump'
*.background_dump_dest='/u01/app/oracle/admin/sham/bdump'
*.compatible='10.2.0.5.0'
*.control_files='/u01/app/oracle/oradata/sham/control01.ctl',
'/u01/app/oracle/oradata/sham/control02.ctl','
/u01/app/oracle/oradata/sham/control03.ctl'
*.core_dump_dest='/u01/app/oracle/admin/sham/cdump'
*.db_block_size=8192
*.db_domain='server1.com'
*.db_file_multiblock_read_count=16
*.db_name='sham'
*.db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'
*.db_recovery_file_dest_size=4194304000
*.dispatchers='(PROTOCOL=TCP) (SERVICE=shamXDB)'
*.job_queue_processes=10
*.log_archive_format='%t_%s_%r.dbf'
*.open_cursors=300
*.pga_aggregate_target=123731968
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=372244480
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/u01/app/oracle/admin/sham/udump'

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

RMAN CLONING IN SAME SERVER | ORACLE 10g

AUXILIARY DATABAE PFILE

rose.__db_cache_size=260046848
rose.__java_pool_size=4194304
rose.__large_pool_size=4194304
rose.__shared_pool_size=100663296
rose.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/rose/adump'
*.background_dump_dest='/u01/app/oracle/admin/rose/bdump'
*.compatible='10.2.0.5.0'
*.control_files='/u01/app/oracle/oradata/rose/control01.ctl',
/u01/app/oracle/oradata/rose/control02.ctl',
'/u01/app/oracle/oradata/rose/control03.ctl'
*.core_dump_dest='/u01/app/oracle/admin/rose/cdump'
*.db_block_size=8192
*.db_domain='server2.com'
*.db_file_multiblock_read_count=16
*.db_name='rose'
*.db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'
*.db_recovery_file_dest_size=4194304000
*.dispatchers='(PROTOCOL=TCP) (SERVICE=roseXDB)'
*.job_queue_processes=10
*.log_archive_format='%t_%s_%r.dbf'
*.open_cursors=300
*.pga_aggregate_target=123731968
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=372244480
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/u01/app/oracle/admin/rose/udump'
# Below parameters are used for from where to where the DATAFILES & LOGFILES will be cloned
db_file_name_convert=('/u01/app/oracle/oradata/sham/', '/u01/app/oracle/oradata/rose')
log_file_name_convert=('/u01/app/oracle/oradata/sham/', '/u01/app/oracle/oradata/rose')

POINTS TO NOTE
If the source database directory structure & clone database directory structure differs, then only
you need to use db_file_name_convert & log_file_name_convert parameters.

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

RMAN CLONING IN SAME SERVER | ORACLE 10g

LISTETENER.ORA FILE CONFIGURATION

# listener.ora Network Configuration File: /u01/app/oracle/product/10.2.0/db_1/network/admin/listener.ora


# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME=sham)
(ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1)
(GLOBAL_DBNAME=sham)
)
(SID_DESC =
(SID_NAME=rose)
(ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1)
(GLOBAL_DBNAME=rose)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL=TCP)(HOST=192.168.241.131)(PORT=1521))
)

TNSNAMES.ORA FILE CONFIGURATION

# tnsnames.ora Network Configuration File: /u01/app/oracle/product/10.2.0/db_1/network/admin/tnsnames.ora


# Generated by Oracle configuration tools.
TO_ROSEDB =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL=TCP)(HOST=192.168.241.131)(PORT=1521))
)
(CONNECT_DATA =
(SERVER=DEDICATED)
(SERVICE_NAME=rose)
)
)

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

RMAN CLONING IN SAME SERVER | ORACLE 10g

TO_SHAMDB =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.241.131)(PORT=1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = sham.server1-oel5.com)
)
)
$ export ORACLE_SID=sham
$ rman target /
Recovery Manager: Release 10.2.0.5.0 - Production on Thu Nov 6 15:52:44 2014
Copyright (c) 1982, 2007, Oracle.

All rights reserved.

connected to target database: SHAM (DBID= 926116387)


RMAN>backup database plus archivelog;
Starting backup at 06-NOV-14
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archive log backupset
channel ORA_DISK_1: specifying archive log(s) in backup set
input archive log thread=1 sequence=1 recid=1 stamp=862951987
input archive log thread=1 sequence=2 recid=2 stamp=862959556
input archive log thread=1 sequence=3 recid=3 stamp=862959577
input archive log thread=1 sequence=4 recid=4 stamp=862960143
input archive log thread=1 sequence=5 recid=5 stamp=862960214
input archive log thread=1 sequence=6 recid=6 stamp=862960255
input archive log thread=1 sequence=7 recid=7 stamp=862960312
input archive log thread=1 sequence=8 recid=8 stamp=862960352
channel ORA_DISK_1: starting piece 1 at 06-NOV-14
channel ORA_DISK_1: finished piece 1 at 06-NOV-14
piece
handle=/u01/app/oracle/flash_recovery_area/SHAM/backupset/2014_11_06/o1_mf_annnn_TAG20141106T231
232_b5qdr9q4_.bkp tag=TAG20141106T231232 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:16
Finished backup at 06-NOV-14
Starting backup at 06-NOV-14
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/u01/app/oracle/oradata/sham/system01.dbf
input datafile fno=00003 name=/u01/app/oracle/oradata/sham/sysaux01.dbf

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

RMAN CLONING IN SAME SERVER | ORACLE 10g

input datafile fno=00002 name=/u01/app/oracle/oradata/sham/undotbs01.dbf


input datafile fno=00004 name=/u01/app/oracle/oradata/sham/users01.dbf
channel ORA_DISK_1: starting piece 1 at 06-NOV-14
channel ORA_DISK_1: finished piece 1 at 06-NOV-14
piece
handle=/u01/app/oracle/flash_recovery_area/SHAM/backupset/2014_11_06/o1_mf_nnndf_TAG20141106T231
248_b5qdrs8v_.bkp tag=TAG20141106T231248 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 06-NOV-14
channel ORA_DISK_1: finished piece 1 at 06-NOV-14
piece
handle=/u01/app/oracle/flash_recovery_area/SHAM/backupset/2014_11_06/o1_mf_ncsnf_TAG20141106T231
248_b5qdsy48_.bkp tag=TAG20141106T231248 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 06-NOV-14
Starting backup at 06-NOV-14
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archive log backupset
channel ORA_DISK_1: specifying archive log(s) in backup set
input archive log thread=1 sequence=9 recid=9 stamp=862960408
channel ORA_DISK_1: starting piece 1 at 06-NOV-14
channel ORA_DISK_1: finished piece 1 at 06-NOV-14
piece
handle=/u01/app/oracle/flash_recovery_area/SHAM/backupset/2014_11_06/o1_mf_annnn_TAG20141106T231
328_b5qdt1qc_.bkp tag=TAG20141106T231328 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 06-NOV-14
STARTUP AUXILIARY DATABASE AT NOMOUNT STAGE & EXIT
$ export ORACLE_SID=rose
$ sqlplus "/as sysdba"
SQL*Plus: Release 10.2.0.5.0 - Production on Thu Nov 6 23:29:29 2014
Copyright (c) 1982, 2010, Oracle.

All Rights Reserved.

Connected to an idle instance.


SYS>startup nomount;
ORACLE instance started.
.
..
...
[Trimmed]

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

RMAN CLONING IN SAME SERVER | ORACLE 10g

ISSUE THE RMAN DUPLICATE COMMAND TO START THE CLONING PROCESS


Start RMAN, make SHAM as target and ROSE as auxiliary.
$ export ORACLE_SID = sham
$ rman target / auxiliary sys/dba@to_rosedb
Recovery Manager: Release 10.2.0.5.0 - Production on Thu Nov 6 23:41:36 2014
Copyright (c) 1982, 2007, Oracle.

All rights reserved.

connected to target database: SHAM (DBID=926116387)


connected to auxiliary database: ROSE (not mounted)
RMAN> duplicate target database to 'rose';
Starting Duplicate Db at 07-NOV-14
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=156 devtype=DISK
contents of Memory Script:
{
set until scn

420627;

set newname for datafile

1 to

"/u01/app/oracle/oradata/rose/system01.dbf";
set newname for datafile

2 to

"/u01/app/oracle/oradata/rose/undotbs01.dbf";
set newname for datafile

3 to

"/u01/app/oracle/oradata/rose/sysaux01.dbf";
set newname for datafile

4 to

"/u01/app/oracle/oradata/rose/users01.dbf";
restore
check readonly
clone database
;
}
executing Memory Script
executing command: SET until clause
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 07-NOV-14
using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: starting datafile backupset restore

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

RMAN CLONING IN SAME SERVER | ORACLE 10g

channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set


restoring datafile 00001 to /u01/app/oracle/oradata/rose/system01.dbf
restoring datafile 00002 to /u01/app/oracle/oradata/rose/undotbs01.dbf
restoring datafile 00003 to /u01/app/oracle/oradata/rose/sysaux01.dbf
restoring datafile 00004 to /u01/app/oracle/oradata/rose/users01.dbf
channel ORA_AUX_DISK_1: reading from backup piece
/u01/app/oracle/flash_recovery_area/SHAM/backupset/2014_11_06/o1_mf_nnndf_TAG20141106T231248_b5q
drs8v_.bkp
channel ORA_AUX_DISK_1: restored backup piece 1
piece
handle=/u01/app/oracle/flash_recovery_area/SHAM/backupset/2014_11_06/o1_mf_nnndf_TAG20141106T231
248_b5qdrs8v_.bkp tag=TAG20141106T231248
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:36
Finished restore at 07-NOV-14
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "ROSE" RESETLOGS ARCHIVELOG
MAXLOGFILES
MAXLOGMEMBERS

16
3

MAXDATAFILES

100

MAXINSTANCES

MAXLOGHISTORY

292

LOGFILE
GROUP

1 ( '/u01/app/oracle/oradata/rose/redo01.log' ) SIZE 50 M

REUSE,

GROUP

2 ( '/u01/app/oracle/oradata/rose/redo02.log' ) SIZE 50 M

REUSE,

GROUP

3 ( '/u01/app/oracle/oradata/rose/redo03.log' ) SIZE 50 M

REUSE

DATAFILE
'/u01/app/oracle/oradata/rose/system01.dbf'
CHARACTER SET WE8ISO8859P1
contents of Memory Script:
{
switch clone datafile all;
}
executing Memory Script
datafile 2 switched to datafile copy
input datafile copy recid=1 stamp=862965521 filename=/u01/app/oracle/oradata/rose/undotbs01.dbf
datafile 3 switched to datafile copy
input datafile copy recid=2 stamp=862965521 filename=/u01/app/oracle/oradata/rose/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy recid=3 stamp=862965521 filename=/u01/app/oracle/oradata/rose/users01.dbf
contents of Memory Script:
{
set until scn

420627;

recover

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

RMAN CLONING IN SAME SERVER | ORACLE 10g

clone database
delete archivelog
;
}
executing Memory Script
executing command: SET until clause
Starting recover at 07-NOV-14
using channel ORA_AUX_DISK_1
starting media recovery
archive log thread 1 sequence 9 is already on disk as file
/u01/app/oracle/flash_recovery_area/SHAM/archivelog/2014_11_06/o1_mf_1_9_b5qdt0fv_.arc
archive log
filename=/u01/app/oracle/flash_recovery_area/SHAM/archivelog/2014_11_06/o1_mf_1_9_b5qdt0fv_.arc
thread=1 sequence=9
media recovery complete, elapsed time: 00:00:02
Finished recover at 07-NOV-14
contents of Memory Script:
{
shutdown clone;
startup clone nomount ;
}
executing Memory Script
database dismounted
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area
.
..
...

373293056 bytes

[Trimmed]
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "ROSE" RESETLOGS ARCHIVELOG
MAXLOGFILES
MAXLOGMEMBERS

16
3

MAXDATAFILES

100

MAXINSTANCES

MAXLOGHISTORY

292

LOGFILE
GROUP

1 ( '/u01/app/oracle/oradata/rose/redo01.log' ) SIZE 50 M

REUSE,

GROUP

2 ( '/u01/app/oracle/oradata/rose/redo02.log' ) SIZE 50 M

REUSE,

GROUP

3 ( '/u01/app/oracle/oradata/rose/redo03.log' ) SIZE 50 M

REUSE

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

RMAN CLONING IN SAME SERVER | ORACLE 10g

DATAFILE
'/u01/app/oracle/oradata/rose/system01.dbf'
CHARACTER SET WE8ISO8859P1
contents of Memory Script:
{
set newname for tempfile

1 to

"/u01/app/oracle/oradata/rose/temp01.dbf";
switch clone tempfile all;
catalog clone datafilecopy

"/u01/app/oracle/oradata/rose/undotbs01.dbf";

catalog clone datafilecopy

"/u01/app/oracle/oradata/rose/sysaux01.dbf";

catalog clone datafilecopy

"/u01/app/oracle/oradata/rose/users01.dbf";

switch clone datafile all;


}
executing Memory Script
executing command: SET NEWNAME
renamed temporary file 1 to /u01/app/oracle/oradata/rose/temp01.dbf in control file
cataloged datafile copy
datafile copy filename=/u01/app/oracle/oradata/rose/undotbs01.dbf recid=1 stamp=862965536
cataloged datafile copy
datafile copy filename=/u01/app/oracle/oradata/rose/sysaux01.dbf recid=2 stamp=862965537
cataloged datafile copy
datafile copy filename=/u01/app/oracle/oradata/rose/users01.dbf recid=3 stamp=862965537
datafile 2 switched to datafile copy
input datafile copy recid=1 stamp=862965536 filename=/u01/app/oracle/oradata/rose/undotbs01.dbf
datafile 3 switched to datafile copy
input datafile copy recid=2 stamp=862965537 filename=/u01/app/oracle/oradata/rose/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy recid=3 stamp=862965537 filename=/u01/app/oracle/oradata/rose/users01.dbf
contents of Memory Script:
{
Alter clone database open resetlogs;
}
executing Memory Script
database opened
Finished Duplicate Db at 07-NOV-14
$ ps -ef | grep pmon
oracle

7520

0 Nov06 ?

00:00:00 ora_pmon_sham

oracle

12772

0 00:38 ?

00:00:00 ora_pmon_rose

oracle

13231

5723

0 00:58 pts/2

00:00:00 grep pmon

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

RMAN CLONING IN SAME SERVER | ORACLE 10g

CONNECTING AUXILIARY DATABASE


$ export ORACLE_SID=rose
$ sqlplus "/as sysdba"
SQL*Plus: Release 10.2.0.5.0 - Production on Fri Nov 7 00:49:52 2014
Copyright (c) 1982, 2010, Oracle.

All Rights Reserved.

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SYS>select name, log mode, dbid, created from v$database;
NAME

LOG_MODE

DBID

CREATED

--------- ------------ ---------- --------ROSE

ARCHIVELOG

1411007070 07-NOV-14

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

S-ar putea să vă placă și