Vous êtes sur la page 1sur 13

DUPLICATING ORACLE DATABASE USING RMAN

| ORACLE 10g

DUPLICATE ORACLE DATABASE ( SAME DIR STRUCTURE )


The process of duplicating the entire database is called CLONING. I am using same SID for source
and clone database as sham for duplication the oracle database from one server to another server.

Source database name

: sham

Auxiliary database name : sham


Source database path

= /u01/app/oracle/oradata/sham/

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


192.168.241.131

(OEL5.SERVER1.COM) SERVER1

PRODUCTION

AUXILIARY SERVER 192.168.241.132

(OEL5.SERVER2.COM) SERVER2

DEVELOPMENT

SOURCE SERVER

CHECK NETWORK AVAILABILITY BETWEEN TWO SERVERS


SERVER 1 :

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

DUPLICATING ORACLE DATABASE USING RMAN

| ORACLE 10g

SERVER 2 :

CREATE DIRECTORY STRUCTURE FOR AUXILIARY DATABASE


$ mkdir -p /u01/app/oracle/oradata/sham/
$ mkdir -p /u01/app/oracle/admin/sham/adump/
$ mkdir -p /u01/app/oracle/admin/sham/bdump/
$ mkdir -p /u01/app/oracle/admin/sham/cdump/
$ mkdir -p /u01/app/oracle/admin/sham/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-oel5.com

SYS>show parameter service_names;


NAME
TYPE
VALUE
------------------------------------ ----------- ---------------------service_names
string
sham.server1-oel5.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

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

DUPLICATING ORACLE DATABASE USING RMAN

| ORACLE 10g

SENDING PFILE TO AUXILIARY SERVER

TNSNAMES.ORA ON TARGET SERVER 192.168.241.131

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


# Generated by Oracle configuration tools.
TO_SHAMDB =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL=TCP)(HOST=192.168.241.132)(PORT=1521))
)

FOR AUXILIARY SERVER

(CONNECT_DATA =
(SERVER=DEDICATED)
(SERVICE_NAME=sham)
)
)
SHAMDB =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST=192.168.241.131)(PORT=1521))
(CONNECT_DATA =

FOR TARGET SERVER

(SERVER = DEDICATED)
(SERVICE_NAME = sham.server1-oel5.com)
)
)

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

DUPLICATING ORACLE DATABASE USING RMAN

| ORACLE 10g

LISTENER.ORA ON AUXILIARY SERVER 192.168.241.132

# 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)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL=TCP)(HOST=192.168.241.132)(PORT=1521))
)
)

[oracle@oel5 admin]$ tnsping to_sham


TNS Ping Utility for Linux: Version 10.2.0.5.0 - Production on 11-NOV-2014 01:06:15
Copyright (c) 1997, 2010, Oracle.

All rights reserved.

Used parameter files:


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.241.132)
(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME=sham)))OK (0 msec)
[oracle@oel5 admin]$ tnsping shamdb
TNS Ping Utility for Linux: Version 10.2.0.5.0 - Production on 11-NOV-2014 01:33:20
Copyright (c) 1997, 2010, Oracle.

All rights reserved.

Used parameter files:


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)
(HOST = 192.168.241.131)(PORT = 1521))) (CONNECT_DATA = (SERVER = DEDICATED)
(SERVICE_NAME = sham.server1-oel5.com))) OK (10 msec)
CONFIGURE PASSWORD FILE ON TARGET & AUXILIARY SERVER
ON TARGET SERVER 191.168.241.131
$ cd $ORACLE_HOME/dbs
$ export ORACLE_SID=sham
[oracle@oel5 dbs]$ orapwd file=orapwsham password=dba entries=3 force=y

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

DUPLICATING ORACLE DATABASE USING RMAN

| ORACLE 10g

ON AUXILIARY SERVER2 191.168.241.132


$ cd $ORACLE_HOME/dbs
$ export ORACLE_SID=sham
[oracle@oel5 dbs]$ orapwd file=orapwsham password=dba entries=3 force=y
Note: Database Password must be same on Target and Auxiliary server.
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-oel5.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

DUPLICATING ORACLE DATABASE USING RMAN

| ORACLE 10g

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
AUXILIARY 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='server2-oel5.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'
# 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/sham)
# log_file_name_convert=('/u01/app/oracle/oradata/sham/', '/u01/app/oracle/oradata/sham')

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

DUPLICATING ORACLE DATABASE USING RMAN

| ORACLE 10g

STARTUP AUXILIARY DATABASE AT NOMOUNT STAGE & EXIT


$ export ORACLE_SID=sham
$ 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]
SYS> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Once I started my auxiliary instance in NOMOUNT state, i have disconnected SYS as NO SESSION
before duplicating a database. It is must and should.
$ export ORACLE_SID=sham
$ rman target /
Recovery Manager: Release 10.2.0.5.0 - Production on Tue Nov 11 08:15:54 2014
Copyright (c) 1982, 2007, Oracle.

All rights reserved.

Connected to target database: SHAM (DBID=926462179)


RMAN> backup database plus archivelog;
Starting backup at 11-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=14 recid=14 stamp=863358645
input archive log thread=1 sequence=15 recid=15 stamp=863358734
channel ORA_DISK_1: starting piece 1 at 11-NOV-14
channel ORA_DISK_1: finished piece 1 at 11-NOV-14
piece
handle=/u01/app/oracle/flash_recovery_area/SHAM/backupset/2014_11_11/o1_mf_annnn_TAG20141111T135
214_b63ksqp8_.bkp tag=TAG20141111T135214 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 11-NOV-14
Starting backup at 11-NOV-14
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

DUPLICATING ORACLE DATABASE USING RMAN

| ORACLE 10g

input datafile fno=00001 name=/u01/app/oracle/oradata/sham/system01.dbf


input datafile fno=00003 name=/u01/app/oracle/oradata/sham/sysaux01.dbf
input datafile fno=00002 name=/u01/app/oracle/oradata/sham/undotbs01.dbf
input datafile fno=00005 name=/u01/app/oracle/oradata/sham/sample01.dbf
input datafile fno=00004 name=/u01/app/oracle/oradata/sham/users01.dbf
channel ORA_DISK_1: starting piece 1 at 11-NOV-14
channel ORA_DISK_1: finished piece 1 at 11-NOV-14
piece
handle=/u01/app/oracle/flash_recovery_area/SHAM/backupset/2014_11_11/o1_mf_nnndf_TAG20141111T135
216_b63kss5h_.bkp tag=TAG20141111T135216 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:36
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 11-NOV-14
channel ORA_DISK_1: finished piece 1 at 11-NOV-14
piece
handle=/u01/app/oracle/flash_recovery_area/SHAM/backupset/2014_11_11/o1_mf_ncsnf_TAG20141111T135
216_b63kv0o3_.bkp tag=TAG20141111T135216 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:06
Finished backup at 11-NOV-14
Starting backup at 11-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=16 recid=16 stamp=863358780
channel ORA_DISK_1: starting piece 1 at 11-NOV-14
channel ORA_DISK_1: finished piece 1 at 11-NOV-14
piece
handle=/u01/app/oracle/flash_recovery_area/SHAM/backupset/2014_11_11/o1_mf_annnn_TAG20141111T135
300_b63kv5od_.bkp tag=TAG20141111T135300 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 11-NOV-14

list bkp.txt

Now i copied all my backup(which was taken by rman) from target server to auxiliary server.

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

DUPLICATING ORACLE DATABASE USING RMAN

| ORACLE 10g

ON AUXILIARY SERVER (RECEIVED ALL BACKUPS)

START THE CLONING PROCESS IN TARGET SERVER


Target and Auxiliary database name as SHAM but connect string is different.
$ export ORACLE_SID=sham
$ rman target sys/dba@shamdb auxiliary sys/dba@to_sham
Recovery Manager: Release 10.2.0.5.0 - Production on Tue Nov 11 15:24:44 2014
Copyright (c) 1982, 2007, Oracle.

All rights reserved.

connected to target database: SHAM (DBID=926462179)


connected to auxiliary database: SHAM (not mounted)
RMAN> duplicate target database to 'sham' nofilenamecheck;
Starting Duplicate Db at 11-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

480540;

set newname for datafile

1 to

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

2 to

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

3 to

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

4 to

"/u01/app/oracle/oradata/sham/users01.dbf";
set newname for datafile

5 to

"/u01/app/oracle/oradata/sham/sample01.dbf";
restore
check readonly
clone database
;

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

DUPLICATING ORACLE DATABASE USING RMAN

| ORACLE 10g

executing Memory Script


executing command: SET until clause
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 11-NOV-14
using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: starting datafile backupset restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /u01/app/oracle/oradata/sham/system01.dbf
restoring datafile 00002 to /u01/app/oracle/oradata/sham/undotbs01.dbf
restoring datafile 00003 to /u01/app/oracle/oradata/sham/sysaux01.dbf
restoring datafile 00004 to /u01/app/oracle/oradata/sham/users01.dbf
restoring datafile 00005 to /u01/app/oracle/oradata/sham/sample01.dbf
channel ORA_AUX_DISK_1: reading from backup piece
/u01/app/oracle/flash_recovery_area/SHAM/backupset/2014_11_11/o1_mf_nnndf_TAG20141111T135216_b63
kss5h_.bkp
channel ORA_AUX_DISK_1: restored backup piece 1
piece
handle=/u01/app/oracle/flash_recovery_area/SHAM/backupset/2014_11_11/o1_mf_nnndf_TAG20141111T135
216_b63kss5h_.bkp tag=TAG20141111T135216
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:45
Finished restore at 11-NOV-14
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "SHAM" RESETLOGS ARCHIVELOG
MAXLOGFILES

16

MAXLOGMEMBERS

MAXDATAFILES

100

MAXINSTANCES

MAXLOGHISTORY

292

LOGFILE
GROUP

SIZE 50 M ,

GROUP

SIZE 50 M ,

GROUP

SIZE 50 M

DATAFILE
'/u01/app/oracle/oradata/sham/system01.dbf'
CHARACTER SET WE8ISO8859P1
contents of Memory Script:
{
switch clone datafile all;
}
executing Memory Script

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

DUPLICATING ORACLE DATABASE USING RMAN

| ORACLE 10g

datafile 2 switched to datafile copy


input datafile copy recid=1 stamp=863365636 filename=/u01/app/oracle/oradata/sham/undotbs01.dbf
datafile 3 switched to datafile copy
input datafile copy recid=2 stamp=863365636 filename=/u01/app/oracle/oradata/sham/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy recid=3 stamp=863365636 filename=/u01/app/oracle/oradata/sham/users01.dbf
datafile 5 switched to datafile copy
input datafile copy recid=4 stamp=863365636 filename=/u01/app/oracle/oradata/sham/sample01.dbf
contents of Memory Script:
{
set until scn

480540;

recover
clone database
delete archivelog
;
}
executing Memory Script
executing command: SET until clause
Starting recover at 11-NOV-14
using channel ORA_AUX_DISK_1
starting media recovery
archive log thread 1 sequence 16 is already on disk as file
/u01/app/oracle/flash_recovery_area/SHAM/archivelog/2014_11_11/o1_mf_1_16_b63kv40v_.arc
archive log
filename=/u01/app/oracle/flash_recovery_area/SHAM/archivelog/2014_11_11/o1_mf_1_16_b63kv40v_.arc
thread=1 sequence=16
media recovery complete, elapsed time: 00:00:03
Finished recover at 11-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
Fixed Size

373293056 bytes
1273780 bytes

Variable Size

113246284 bytes

Database Buffers

255852544 bytes

Redo Buffers

2920448 bytes

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

DUPLICATING ORACLE DATABASE USING RMAN

| ORACLE 10g

sql statement: CREATE CONTROLFILE REUSE SET DATABASE "SHAM" RESETLOGS ARCHIVELOG
MAXLOGFILES

16

MAXLOGMEMBERS

MAXDATAFILES

100

MAXINSTANCES

MAXLOGHISTORY

292

LOGFILE
GROUP

SIZE 50 M ,

GROUP

SIZE 50 M ,

GROUP

SIZE 50 M

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

1 to

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

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

catalog clone datafilecopy

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

catalog clone datafilecopy

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

catalog clone datafilecopy

"/u01/app/oracle/oradata/sham/sample01.dbf";

switch clone datafile all;


}
executing Memory Script
executing command: SET NEWNAME
renamed temporary file 1 to /u01/app/oracle/oradata/sham/temp01.dbf in control file
cataloged datafile copy
datafile copy filename=/u01/app/oracle/oradata/sham/undotbs01.dbf recid=1 stamp=863365649
cataloged datafile copy
datafile copy filename=/u01/app/oracle/oradata/sham/sysaux01.dbf recid=2 stamp=863365649
cataloged datafile copy
datafile copy filename=/u01/app/oracle/oradata/sham/users01.dbf recid=3 stamp=863365649
cataloged datafile copy
datafile copy filename=/u01/app/oracle/oradata/sham/sample01.dbf recid=4 stamp=863365649
datafile 2 switched to datafile copy
input datafile copy recid=1 stamp=863365649 filename=/u01/app/oracle/oradata/sham/undotbs01.dbf
datafile 3 switched to datafile copy
input datafile copy recid=2 stamp=863365649 filename=/u01/app/oracle/oradata/sham/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy recid=3 stamp=863365649 filename=/u01/app/oracle/oradata/sham/users01.dbf
datafile 5 switched to datafile copy
input datafile copy recid=4 stamp=863365649 filename=/u01/app/oracle/oradata/sham/sample01.dbf

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

DUPLICATING ORACLE DATABASE USING RMAN

| ORACLE 10g

contents of Memory Script:


{
Alter clone database open resetlogs;
}
executing Memory Script
database opened
Finished Duplicate Db at 11-NOV-14
CONNECTING AUXILIARY DATABASE
$ export ORACLE_SID=sham
$ sqlplus "/as sysdba"
SQL*Plus: Release 10.2.0.5.0 - Production on Tue Nov 11 16:09:25 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, dbid, open_mode from v$database;
NAME

DBID

OPEN_MODE

--------- ----------

----------

SHAM

READ WRITE

926530381

Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

Vous aimerez peut-être aussi