Вы находитесь на странице: 1из 17

ACTIVE

DATABASE DUPLICATION - DIFFERENT DIRECTORY STRUCTURE

RMAN ACTIVE DATABASE CLONING

RMAN has the ability duplicate a database from a backup or from an active database. Using RMAN possible to create a duplicate database on a remote server with the same directory structure and

different directory structure or else the local server with a different directory structure.

Oracle 11 g has introduced active database duplication, we can create a duplicate of the target database without any backups. Duplication is performed over the network. Let us do active database duplication in auxiliary server with different directory structure.

Source server database name

: CRMS

Auxiliary server database name

: HRMS

Source database path

: /u02/app/oracle/oradata/crms/

Auxiliary database path : /u01/app/oracle/oradata/hrms/

SOURCE SERVER

192.168.1.130 (SERVER1.ORACLE.COM) SERVER1 PRODUCTION

AUXILIARY SERVER 192.168.1.131 (SERVER2.ORACLE.COM) SERVER2 DEVELOPMENT

NETWORK AVAILABILITY

BETWEEN TWO SERVERS

FROM SOURCE SERVER
FROM SOURCE
SERVER
NETWORK AVAILABILITY BETWEEN TWO SERVERS FROM SOURCE SERVER Exploring the Oracle DBA Technology by Gunasekaran ,

Exploring the Oracle DBA Technology

by

Gunasekaran , Thiyagu

ACTIVE

DATABASE DUPLICATION - DIFFERENT DIRECTORY STRUCTURE

FROM THE AUXILIARY

SERVER

- DIFFERENT DIRECTORY STRUCTURE FROM THE AUXILIARY SERVER STEPS TO PERFORM ACTIVE DATABASE DUPLICATION Configure t
- DIFFERENT DIRECTORY STRUCTURE FROM THE AUXILIARY SERVER STEPS TO PERFORM ACTIVE DATABASE DUPLICATION Configure t

STEPS

TO PERFORM ACTIVE DATABASE DUPLICATION

Configure the network files

Add an entry in tnsnames.ora & listener.ora on the Target server & Auxiliary server.

Create & Edit the initialization parameter file

Create an init.ora from the source database & SCP to the auxiliary server. Make all necessary changes the new init.ora file as per clone database such as, Changing db_name = < new_name >, db_domain = <new_name>, etc Set new path to control_files, audit_file_dest, diagnostic_dest, db_recovery_file_dest, etc

If FILE SYSTEM or DIRECTORY NAMING CONVENTION is different, must add below parameters

db_file_name_convert=(/source path location’, clone path location)

log_file_name_convert=(/source path location’, ’clone path location’)

Create all necessary directories physically in auxiliary server. Create a Password file (password must be same) for clone & target database. Start the auxiliary database instance using the init.ora file. Connect to the Target(source) & Auxiliary (clone) databases in the Target server. Execute the duplicate command to perform database duplication.

Exploring the Oracle DBA Technology

by

Gunasekaran , Thiyagu

ACTIVE

DATABASE DUPLICATION - DIFFERENT DIRECTORY STRUCTURE

CONNECTING

SOURCE

DATABASE

SYS>select name, dbid from v$database;

NAME

DBID

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

CRMS

1569424116

SYS>show parameter db_domain;

NAME

TYPE

VALUE

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

db_domain

string

server1.com

SYS>show parameter service_names;

 

NAME

TYPE

VALUE

 

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

service_names

string

crms.server1.com

 

PARAMETER

FILE BACKUP FOR AUXILIARY DATABASE

SYS>show parameter pfile;

NAME TYPE VALUE ------- --------- ------------------------------------------------------ spfile string
NAME
TYPE
VALUE
-------
--------- ------------------------------------------------------
spfile
string
/u02/app/oracle/product/11.2.0/dbhome_1/dbs/spfilecrms.ora
SENDING
PFILE TO THE AUXILIARY SERVER

crms

db_cache_size=419430400

 

crms

java_pool_size=16777216

crms

large_pool_size=16777216

crms

oracle_base='/u02/app/oracle'

# ORACLE_BASE set from environment

crms

pga_aggregate_target=503316480

crms

sga_target=754974720

 

crms

shared_io_pool_size=0

crms

shared_pool_size=285212672

 

Exploring the Oracle DBA Technology

by

Gunasekaran , Thiyagu

TARGET

DATABASE

PFILE

ACTIVE

DATABASE DUPLICATION - DIFFERENT DIRECTORY STRUCTURE

crms streams_pool_size=0 *.audit_file_dest='/u02/app/oracle/admin/crms/adump' *.audit_trail='db'
crms
streams_pool_size=0
*.audit_file_dest='/u02/app/oracle/admin/crms/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='/u02/app/oracle/oradata/crms/control01.ctl','/u02/app/oracle/flash_recovery_area/crms/control02.ctl'
*.db_block_size=8192
*.db_domain='server1.com'
*.db_name='crms'
*.db_recovery_file_dest='/u02/app/oracle/flash_recovery_area'
*.db_recovery_file_dest_size=4039114752
*.diagnostic_dest='/u02/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=crmsXDB)'
*.log_archive_format='%t_%s_%r.dbf'
*.memory_target=1244659712
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'
AUXILIARY DATABASE
PFILE
hrms
db_cache_size=419430400
hrms
java_pool_size=16777216
hrms
large_pool_size=16777216
hrms
oracle_base='/u02/app/oracle'
# ORACLE_BASE set from environment
hrms
pga_aggregate_target=503316480
hrms
sga_target=754974720
hrms
shared_io_pool_size=0
hrms
shared_pool_size=285212672
hrms
streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/hrms/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='/u01/app/oracle/oradata/hrms/control01.ctl', '/u01/app/oracle/flash_recovery_area/hrms/control02.ctl'
*.db_block_size=8192
*.db_domain='server2.com'
*.db_name='hrms'
*.db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'
*.db_recovery_file_dest_size=4039114752
*.diagnostic_dest='/u01/app/oracle'

Exploring the Oracle DBA Technology

by

Gunasekaran , Thiyagu

ACTIVE

DATABASE DUPLICATION - DIFFERENT DIRECTORY STRUCTURE

*.dispatchers='(PROTOCOL=TCP) (SERVICE=hrmsXDB)'

*.log_archive_format='%t_%s_%r.dbf'

*.memory_target=1244659712

*.open_cursors=300

*.processes=150

*.remote_login_passwordfile='EXCLUSIVE'

*.undo_tablespace='UNDOTBS1'

# Below Parameters are used for from where to where the DATAFILES & LOGFILES will be cloned.

db_file_name_convert=('/u02/app/oracle/oradata/crms/', '/u01/app/oracle/oradata/hrms/’)

log_file_name_convert=('/u02/app/oracle/oradata/crms/', '/u01/app/oracle/oradata/hrms/')

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.

CREATE DIRECTORY STRUCTURE FOR AUXILIARY DATABASE

$ mkdir -p /u01/app/oracle/oradata/hrms/

$

mkdir -p /u01/app/oracle/admin/hrms/adump/

$ mkdir -p /u01/app/oracle/admin/hrms/dpdump/ $ mkdir -p /u01/app/oracle/flash_recovery_area/hrms #(for control file)
$ mkdir -p /u01/app/oracle/admin/hrms/dpdump/
$ mkdir -p /u01/app/oracle/flash_recovery_area/hrms
#(for control file)
LISTENER.ORA
ON
TARGET SERVER  192.168. 1.130
# listener.ora Network Configuration File: /u02/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME=crms)
(ORACLE_HOME = /u02/app/oracle/product/11.2.0/dbhome_1)
# (GLOBAL_DBNAME=crms)
)
)
ADR_BASE_LISTENER = /u02/app/oracle
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL=TCP)(HOST=192.168.241.130)(PORT=1521))
)
)

Exploring the Oracle DBA Technology

by

Gunasekaran , Thiyagu

ACTIVE

DATABASE DUPLICATION - DIFFERENT DIRECTORY STRUCTURE

TNSNAMES.ORA ON TARGET SERVER 192.168.1.130

# tnsnames.ora Network Configuration File: /u02/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora

# Generated by Oracle configuration tools.

CRMSDB =

(DESCRIPTION =

(ADDRESS_LIST =

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

= ( PROTOCOL =TCP)( HOST =192.168.1.130 )( PORT =1521)) ) FOR TARGET SERVER ( CONNECT_DATA =

)

FOR

TARGET SERVER

(CONNECT_DATA =

(SERVER=DEDICATED)

(SERVICE_NAME=

)

crms)

)
)

HRMSDB =

(DESCRIPTION =

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

(CONNECT_DATA =

FOR AUXILIARY SERVER

(SERVER = DEDICATED)

(SERVICE_NAME =

)

)

hrms)

SERVER = DEDICATED) ( SERVICE_NAME = ) ) hrms ) LISTENER.ORA ON AUXILIARY SERVER  192.168.1.131
LISTENER.ORA ON AUXILIARY SERVER  192.168.1.131
LISTENER.ORA ON AUXILIARY SERVER  192.168.1.131

# listener.ora Network Configuration File: /u02/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora

# Generated by Oracle configuration tools.

LISTENER =

(DESCRIPTION_LIST =

(DESCRIPTION =

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

) )
)
)

ADR_BASE_LISTENER = /u02/app/oracle

SID_LIST_LISTENER = (SID_LIST = (SID_DESC =
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =

(ORACLE_HOME = /u02/app/oracle/product/11.2.0/dbhome_1)

(SID_NAME = hrms)

) )
)
)

Exploring the Oracle DBA Technology

by

Gunasekaran , Thiyagu

ACTIVE

DATABASE DUPLICATION - DIFFERENT DIRECTORY STRUCTURE

STARTING LISTENER IN AUXILIARY SERVER

$ lsnrctl

--- > listener control

LSNRCTL> start listener

Starting /u02/app/oracle/product/11.2.0/dbhome_1/bin/tnslsnr: please wait

TNSLSNR for Linux: Version 11.2.0.1.0 - Production

System parameter file is /u02/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora

Log messages written to /u02/app/oracle/diag/tnslsnr/SERVER2/listener/alert/log.xml

Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.131)(PORT=1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.131)(PORT=1521)))

STATUS of the LISTENER

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

Alias

listener

 

Version

TNSLSNR for Linux: Version 11.2.0.1.0 - Production

Start Date

06-JAN-2015 00:30:41

 

Uptime

0 days 0 hr. 0 min. 0 sec

 
Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File
Trace Level
off
Security
ON: Local OS Authentication
SNMP
OFF
Listener Parameter File
/u02/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File
/u02/app/oracle/diag/tnslsnr/SERVER2/listener/alert/log.xml
Listening Endpoints Summary
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.131)(PORT=1521)))

Services Summary

Service "hrms" has 1 instance(s).

Instance "hrms", status UNKNOWN, has 1 handler(s) for this service

The command completed successfully

STARTING LISTENER IN TARGET SERVER

$ lsnrctl start listener

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 06-JAN-2015 00:30:48

Copyright (c) 1991, 2009, Oracle. All rights reserved.

Starting /u02/app/oracle/product/11.2.0/dbhome_1/bin/tnslsnr: please wait

TNSLSNR for Linux: Version 11.2.0.1.0 - Production

System parameter file is /u02/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora

Log messages written to /u02/app/oracle/diag/tnslsnr/SERVER1/listener/alert/log.xml

Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=SERVER1.ORACLE.COM)(PORT=1521))) ***********

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=SERVER1.ORACLE.COM)(PORT=1521)))

Exploring the Oracle DBA Technology

by

Gunasekaran , Thiyagu

ACTIVE

DATABASE DUPLICATION - DIFFERENT DIRECTORY STRUCTURE

STATUS of the LISTENER

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

Alias listener Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production Start Date 06-JAN-2015 00:30:48 Uptime
Alias
listener
Version
TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date
06-JAN-2015 00:30:48
Uptime
0 days 0 hr. 0 min. 0 sec
Trace Level
off
Security
ON: Local OS Authentication
SNMP
OFF

Listener Parameter File

/u02/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora

Listener Log File

/u02/app/oracle/diag/tnslsnr/SERVER1/listener/alert/log.xml

Listening Endpoints Summary

(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=SERVER1.ORACLE.COM)(PORT=1521)))

Services Summary

Service "crms" has 1 instance(s).

Instance "crms", status UNKNOWN, has 1 handler(s) for this service

The command completed successfully

CHECKING TNS CONNECTIVITY ON TARGET SEVER [oracle@SERVER1 admin]$ tnsping crmsdb TNS Ping Utility for Linux:
CHECKING TNS CONNECTIVITY ON TARGET SEVER
[oracle@SERVER1 admin]$ tnsping crmsdb
TNS Ping Utility for Linux: Version 11.2.0.1.0 - Production on 06-JAN-2015 01:40:28
Copyright (c) 1997, 2009, 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.1.130) (PORT = 1521))) (CONNECT_DATA = (SERVER = DEDICATED)(SERVICE_NAME = crms)))OK (20 msec)

[oracle@SERVER1 admin]$ tnsping hrmsdb

TNS Ping Utility for Linux: Version 11.2.0.1.0 - Production on 06-JAN-2015 01:42:54 Copyright (c) 1997, 2009, 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.1.131) (PORT = 1521))) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = hrms)))OK (10 msec)

CONFIGURE

PASSWORD FILE ON

AUXILIARY SERVER

$ cd $ORACLE_HOME/dbs $ export ORACLE_SID= h rms [oracle@SERVER2 dbs]$ orapwd file=orapw h rms password=

$ cd $ORACLE_HOME/dbs

$ export ORACLE_SID=hrms

[oracle@SERVER2 dbs]$ orapwd file=orapwhrms password=

$ cd $ORACLE_HOME/dbs $ export ORACLE_SID= h rms [oracle@SERVER2 dbs]$ orapwd file=orapw h rms password= oracle

oracle

$ cd $ORACLE_HOME/dbs $ export ORACLE_SID= h rms [oracle@SERVER2 dbs]$ orapwd file=orapw h rms password= oracle
$ export ORACLE_SID= h rms [oracle@SERVER2 dbs]$ orapwd file=orapw h rms password= oracle entries=3 force=y
$ export ORACLE_SID= h rms [oracle@SERVER2 dbs]$ orapwd file=orapw h rms password= oracle entries=3 force=y
$ export ORACLE_SID= h rms [oracle@SERVER2 dbs]$ orapwd file=orapw h rms password= oracle entries=3 force=y
$ export ORACLE_SID= h rms [oracle@SERVER2 dbs]$ orapwd file=orapw h rms password= oracle entries=3 force=y
$ export ORACLE_SID= h rms [oracle@SERVER2 dbs]$ orapwd file=orapw h rms password= oracle entries=3 force=y
$ export ORACLE_SID= h rms [oracle@SERVER2 dbs]$ orapwd file=orapw h rms password= oracle entries=3 force=y

entries=3 force=y

$ export ORACLE_SID= h rms [oracle@SERVER2 dbs]$ orapwd file=orapw h rms password= oracle entries=3 force=y
$ export ORACLE_SID= h rms [oracle@SERVER2 dbs]$ orapwd file=orapw h rms password= oracle entries=3 force=y
$ export ORACLE_SID= h rms [oracle@SERVER2 dbs]$ orapwd file=orapw h rms password= oracle entries=3 force=y
$ export ORACLE_SID= h rms [oracle@SERVER2 dbs]$ orapwd file=orapw h rms password= oracle entries=3 force=y

Password must be same on Target database & Auxiliary database.

When you connect RMAN to the

Source database as TARGET, must specify a password, even if RMAN uses OS authentication.

Exploring the Oracle DBA Technology

by

Gunasekaran , Thiyagu

ACTIVE

DATABASE DUPLICATION - DIFFERENT DIRECTORY STRUCTURE

SET THE

SAME PASSWORD OF CLONE DATABASE INTO THE TARGET DATABASE

SYS> alter user sys identified by

oracle

;

(or)

$ cd $ORACLE_HOME/dbs

$ export ORACLE_SID=crms

[oracle@SERVER2 dbs]$ orapwd file=orapwcrms password=

oracle

entries=3 force=y

To create a password in target server, we can use alter user statement or orapwd utlity.

STARTUP

AUXILIARY DATABASE AT

NOMOUNT STAGE & EXIT

[oracle@SERVER2 ~]$ export ORACLE_SID=hrms [oracle@SERVER2 ~]$ sqlplus "/as sysdba"

SQL*Plus: Release 11.2.0.1.0 Production on Tue Jan 6 01:52:05 2015

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

Connected to an idle instance.

SQL> startup nomount; ORACLE instance started.

Total System Global Area 1255473152 bytes Fixed Size Variable Size Database Buffers Redo Buffers 1336232
Total System Global Area 1255473152 bytes
Fixed Size
Variable Size
Database Buffers
Redo Buffers
1336232 bytes
822086744 bytes
419430400 bytes
12619776 bytes
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

POINTS TO NOTE :

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.

DUPLICATING TARGET DATABASE

In order to clone with the source database open and must be on archivelog mode. From 11g we can clone databases using the “from active” database option. In this case we do NOT require an existing backup, the active datafiles will be used as the source for the clone.

DUPLICATE TARGET DATABASE COMMAND PERFORMS THE FOLLOWING STEPS.

Creates an SPFILE.

Shuts down the instance and restarts it with the new spfile.

Restores the controlfile from the backup.

Mounts the database. Restore all datafiles.

RMAN creates all files in the converted names.

Recovers the datafiles up to the time specified and opens the database for availability.

Exploring the Oracle DBA Technology

by

Gunasekaran , Thiyagu

ACTIVE

DATABASE DUPLICATION - DIFFERENT DIRECTORY STRUCTURE

CONNECT TO THE TARGET (SOURCE) & AUXILIARY (NEW CLONE) DATABASES USING RMAN

$ export ORACLE_SID=crms

$ rman target sys/oracle@CRMSDB auxiliary sys/orac1e@HRMSDB

Recovery Manager: Release 11.2.0.1.0 - Production on Tue Jan 6 01:52:55 2015

Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.

connected to target database: CRMS (DBID=1569424116) connected to auxiliary database: HRMS (not mounted)

RMAN> duplicate target database to 'hrms' from active database;

Starting Duplicate Db at 06-JAN-15

using target database control file instead of recovery catalog

allocated channel: ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: SID=19 device type=DISK

contents of Memory Script:

{

sql clone "create spfile from memory"; } executing Memory Script sql statement: create spfile from
sql clone "create spfile from memory";
}
executing Memory Script
sql statement: create spfile from memory
contents of Memory Script:
{
shutdown clone immediate;

startup clone nomount;

}

executing Memory Script

Oracle instance shut down

connected to auxiliary database (not started)

Oracle instance started

Total System Global Area

Fixed Size

Variable Size

Database Buffers

Redo Buffers

1255473152 bytes

1336232 bytes

838863960 bytes

402653184 bytes

12619776 bytes

contents of Memory Script:

{

sql clone "alter system set db_name =

''CRMS'' comment=

''Modified by RMAN duplicate'' scope=spfile";

Exploring the Oracle DBA Technology

by

Gunasekaran , Thiyagu

ACTIVE

DATABASE DUPLICATION - DIFFERENT DIRECTORY STRUCTURE

sql clone "alter system set db_unique_name =

''HRMS'' comment=

''Modified by RMAN duplicate'' scope=spfile";

shutdown clone immediate;

startup clone force nomount

backup as copy current controlfile auxiliary format

'/u01/app/oracle/oradata/hrms/control01.ctl' ;

restore clone controlfile to '/u01/app/oracle/flash_recovery_area/hrms/control02.ctl' from

'/u01/app/oracle/oradata/hrms/control01.ctl';

alter clone database mount;

}

executing Memory Script

sql statement: alter system set db_name = ''CRMS'' comment= ''Modified by RMAN duplicate'' scope=s pfile

sql statement: alter system set db_unique_name = ''HRMS'' comment= ''Modified by RMAN duplicate'' scope=spfile

Oracle instance shut down

Oracle instance started

Total System Global Area 1255473152 bytes Fixed Size 1336232 bytes Variable Size 838863960 bytes Database
Total System Global Area
1255473152 bytes
Fixed Size
1336232 bytes
Variable Size
838863960 bytes
Database Buffers
402653184 bytes
Redo Buffers
12619776 bytes
Starting backup at 06-JAN-15

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=33 device type=DISK

channel ORA_DISK_1: starting datafile copy

copying current control file

output file name=/u02/app/oracle/product/11.2.0/dbhome_1/dbs/snapcf_crms.f

tag=TAG20150106T013212 RE CID=6 STAMP=868239132

channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01

Finished backup at 06-JAN-15

Starting restore at 06-JAN-15

allocated channel: ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: SID=18 device type=DISK

channel ORA_AUX_DISK_1: copied control file copy

Finished restore at 06-JAN-15

database mounted

contents of Memory Script:

{

set newname for datafile 1 to

"/u01/app/oracle/oradata/hrms//system01.dbf";

Exploring the Oracle DBA Technology

by

Gunasekaran , Thiyagu

ACTIVE

DATABASE DUPLICATION - DIFFERENT DIRECTORY STRUCTURE

set newname for datafile 2 to

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

set newname for datafile 3 to

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

set newname for datafile 4 to

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

backup as copy reuse datafile 1 auxiliary format

"/u01/app/oracle/oradata/hrms//system01.dbf"

datafile

2

auxiliary format

"/u01/app/oracle/oradata/hrms//sysaux01.dbf"

datafile

3 auxiliary format

"/u01/app/oracle/oradata/hrms//undotbs01.dbf"

4 auxiliary format

"/u01/app/oracle/oradata/hrms//users01.dbf"

datafile

;

sql 'alter system archive log current';

}

executing Memory Script

executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME

Starting backup at 06-JAN-15 using channel ORA_DISK_1 channel ORA_DISK_1: starting datafile copy input datafile file number=00001 name=/u02/app/oracle/oradata/crms/system01.dbf output file name=/u01/app/oracle/oradata/hrms/system01.dbf tag=TAG20150106T013219 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:55 channel ORA_DISK_1: starting datafile copy input datafile file number=00002 name=/u02/app/oracle/oradata/crms/sysaux01.dbf output file name=/u01/app/oracle/oradata/hrms/sysaux01.dbf tag=TAG20150106T013219 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:55 channel ORA_DISK_1: starting datafile copy input datafile file number=00003 name=/u02/app/oracle/oradata/crms/undotbs01.dbf output file name=/u01/app/oracle/oradata/hrms/undotbs01.dbf tag=TAG20150106T013219 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15 channel ORA_DISK_1: starting datafile copy input datafile file number=00004 name=/u02/app/oracle/oradata/crms/users01.dbf output file name=/u01/app/oracle/oradata/hrms/users01.dbf tag=TAG20150106T013219 channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03 Finished backup at 06-JAN-15

sql statement: alter system archive log current

Exploring the Oracle DBA Technology

by

Gunasekaran , Thiyagu

ACTIVE

DATABASE DUPLICATION - DIFFERENT DIRECTORY STRUCTURE

contents of Memory Script:

{

backup as copy reuse

archivelog like

"/u02/app/oracle/flash_recovery_area/CRMS/archivelog/2015_01_06/o1_mf_1_14_bbovl f5y arc"

auxiliary format

"/u01/app/oracle/flash_recovery_area/HRMS/archivelog/2015_01_06/o1_mf_1_14_%u

catalog clone recovery area;

switch clone datafile all;

}

executing Memory Script

arc"

;

Starting backup at 06-JAN-15

using channel ORA_DISK_1

channel ORA_DISK_1: starting archived log copy

input archived log thread=1 sequence=14 RECID=13 STAMP=868239269

output file

name=/u01/app/oracle/flash_recovery_area/HRMS/archivelog/2015_01_06/o1_mf_1_14_1kps0ht6_

RECID=0 STAMP=0

.arc

channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:01 Finished backup at 06-JAN-15 searching for
channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:01
Finished backup at 06-JAN-15
searching for all files in the recovery area
List of Files Unknown to the Database
=====================================
File Name:
/u01/app/oracle/flash_recovery_area/HRMS/archivelog/2015_01_06/o1_mf_1_14_1kps0ht6 arc

cataloging files

cataloging done

List of Cataloged Files

=======================

File Name:

/u01/app/oracle/flash_recovery_area/HRMS/archivelog/2015_01_06/o1_mf_1_14_1kps0ht6 arc

datafile 1 switched to datafile copy

input datafile copy RECID=6 STAMP=868239272 file name=/u01/app/oracle/oradata/hrms/system01.dbf

datafile 2 switched to datafile copy

input datafile copy RECID=7 STAMP=868239272 file name=/u01/app/oracle/oradata/hrms/sysaux01.dbf

datafile 3 switched to datafile copy

input datafile copy RECID=8 STAMP=868239272 file name=/u01/app/oracle/oradata/hrms/undotbs01.dbf

datafile 4 switched to datafile copy

input datafile copy RECID=9 STAMP=868239272 file name=/u01/app/oracle/oradata/hrms/users01.dbf

contents of Memory Script:

{

set until scn 1001716;

Exploring the Oracle DBA Technology

by

Gunasekaran , Thiyagu

ACTIVE

DATABASE DUPLICATION - DIFFERENT DIRECTORY STRUCTURE

recover

clone database

delete archivelog

}

;

executing Memory Script

executing command: SET until clause

Starting recover at 06-JAN-15

using channel ORA_AUX_DISK_1

starting media recovery

archived log for thread 1 with sequence 14 is already on disk as file /u01/app/oracle/flash_recovery _area/HRMS/archivelog/2015_01_06/o1_mf_1_14_1kps0ht6 arc

archived log file name=/u01/app/oracle/flash_recovery_area/HRMS/archivelog/2015_01_06/o1_mf_1_14_1kp s0ht6 arc thread=1 sequence=14

media recovery complete, elapsed time: 00:00:01

Finished recover at 06-JAN-15

contents of Memory Script:

{ shutdown clone immediate; startup clone nomount; sql clone "alter system set db_name = ''HRMS''
{
shutdown clone immediate;
startup clone nomount;
sql clone "alter system set db_name =
''HRMS'' comment=
''Reset to original value by RMAN'' scope=spfile";
sql clone "alter system reset db_unique_name scope=spfile";
shutdown clone immediate;

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

Variable Size

Database Buffers

Redo Buffers

1255473152 bytes

1336232 bytes

838863960 bytes

402653184 bytes

12619776 bytes

sql statement: alter system set db_name = ''HRMS'' comment= ''Reset to original value by RMAN'' sc ope=spfile

sql statement: alter system reset db_unique_name scope=spfile

Oracle instance shut down

Exploring the Oracle DBA Technology

by

Gunasekaran , Thiyagu

ACTIVE

DATABASE DUPLICATION - DIFFERENT DIRECTORY STRUCTURE

connected to auxiliary database (not started) Oracle instance started

Total System Global Area

Fixed Size Variable Size Database Buffers Redo Buffers

1255473152 bytes

1336232 bytes 838863960 bytes 402653184 bytes 12619776 bytes

sql statement: CREATE CONTROLFILE REUSE SET DATABASE "HRMS" RESETLOGS ARCHIVELOG

MAXLOGFILES 16 MAXLOGMEMBERS 3 MAXDATAFILES 100 MAXINSTANCES 8 MAXLOGHISTORY 292 LOGFILE GROUP 1 ( '/u01/app/oracle/oradata/hrms//redo01.log' ) SIZE 50 M REUSE, GROUP 2 ( '/u01/app/oracle/oradata/hrms//redo02.log' ) SIZE 50 M REUSE, GROUP 3 ( '/u01/app/oracle/oradata/hrms//redo03.log' ) SIZE 50 M REUSE DATAFILE

'/u01/app/oracle/oradata/hrms/system01.dbf' CHARACTER SET WE8MSWIN1252 contents of Memory Script: { set
'/u01/app/oracle/oradata/hrms/system01.dbf'
CHARACTER SET WE8MSWIN1252
contents of Memory Script:
{
set newname for tempfile 1 to
"/u01/app/oracle/oradata/hrms//temp01.dbf";

switch clone tempfile all; catalog clone datafilecopy "/u01/app/oracle/oradata/hrms/sysaux01.dbf",

"/u01/app/oracle/oradata/hrms/undotbs01.dbf",

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

switch clone datafile all;

}

executing Memory Script

executing command: SET NEWNAME

renamed tempfile 1 to /u01/app/oracle/oradata/hrms//temp01.dbf in control file

cataloged datafile copy datafile copy file name=/u01/app/oracle/oradata/hrms/sysaux01.dbf RECID=1 STAMP=868239296 cataloged datafile copy datafile copy file name=/u01/app/oracle/oradata/hrms/undotbs01.dbf RECID=2 STAMP=868239296 cataloged datafile copy datafile copy file name=/u01/app/oracle/oradata/hrms/users01.dbf RECID=3 STAMP=868239297

datafile 2 switched to datafile copy input datafile copy RECID=1 STAMP=868239296 file name=/u01/app/oracle/oradata/hrms/sysaux01.dbf

Exploring the Oracle DBA Technology

by

Gunasekaran , Thiyagu

ACTIVE

DATABASE DUPLICATION - DIFFERENT DIRECTORY STRUCTURE

datafile 3 switched to datafile copy input datafile copy RECID=2 STAMP=868239296 file name=/u01/app/oracle/oradata/hrms/undotbs01.dbf

datafile 4 switched to datafile copy input datafile copy RECID=3 STAMP=868239297 file name=/u01/app/oracle/oradata/hrms/users01.dbf

contents of Memory Script:

{

Alter clone database open resetlogs;

}

executing Memory Script

database opened Finished Duplicate Db at 06-JAN-15

ADD AN ENTRY IN

/etc/oratab FILE

hrms:/u02/app/oracle/product/11.2.0/dbhome_1:Y

CONNECTING

AUXILIARY DATABASE

CONNECTING AUXILIARY DATABASE Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu
CONNECTING AUXILIARY DATABASE Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

Exploring the Oracle DBA Technology

by

Gunasekaran , Thiyagu

ACTIVE

DATABASE DUPLICATION - DIFFERENT DIRECTORY STRUCTURE

ACTIVE DATABASE DUPLICATION - DIFFERENT DIRECTORY STRUCTURE DBID is different from the target database so it

DBID is different from the target database so it can be backed up independently and using the

same catalog as well.

SQL> select dbid from v$database;

DBID

----------

916592507

select dbid from v$database; DBID ---------- 916592507 Exploring the Oracle DBA Technology by Gunasekaran , Thiyagu

Exploring the Oracle DBA Technology

by

Gunasekaran , Thiyagu