Performing a Clone Using a Data Guard Snapshot Database

Performing a Clone Using a Data Guard Snapshot Database

Performing a clone using a Data Guard Snapshot Database

This note describes the process of performing a database refresh of the reporting database using the Data Guard Standby database as the source for the clone and not the production primary database.

Environment:

  • Primary Database :ttrl
  • Standby Database : ttrl_dr (db_unique_name)
  • Cloned Database: strl

Verify Data Guard Broker Configuration

DGMGRL> connect sys

Password:

Connected.

DGMGRL> show configuration

Configuration - ttrlDR

Protection Mode: MaxPerformance

Databases:

ttrl - Primary database

ttrl_dr - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:

SUCCESS

Convert Physical Standby to Snapshot Standby

DGMGRL> convert database ttrl_dr to snapshot standby;

Converting database "ttrl_dr" to a Snapshot Standby database, please wait...

Database "ttrl_dr" converted successfully

DGMGRL> show configuration

Configuration - ttrlDR

Protection Mode: MaxPerformance

Databases:

ttrl - Primary database

ttrl_dr - Snapshot standby database

Fast-Start Failover: DISABLED

Configuration Status:

SUCCESS

On Standby database, check the status of the database

oracle@test-devas:/export/home/oracle $ sqlplus sys as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Wed Jan 7 14:06:44 2015

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

Enter password:

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select database_role from v$database;

DATABASE_ROLE

------

SNAPSHOT STANDBY

SQL> select open_mode from v$database;

OPEN_MODE

------

READ WRITE

Switch a few log files in the snapshot standby database otherwise we will get an error like the one shown below when we run the RMAN DUPLICATE

RMAN-03002: failure of Duplicate Db command at 05/16/2014 11:20:47

RMAN-05501: aborting duplication of target database

RMAN-05541: no archived logs found in target database

SQL> alter system switch logfile;

System altered.

SQL> /

System altered.

From Standby database verify connectivity to the clone database

oracle@test-devas:/export/home/oracle $ tnspingstrl

TNS Ping Utility for Solaris: Version 11.2.0.3.0 - Production on 07-JAN-2015 14:10:51

Copyright (c) 1997, 2011, Oracle. All rights reserved.

Used parameter files:

/u01/app/oracle/product/11.2.0/dbhome_3/network/admin/sqlnet.ora

Used TNSNAMES adapter to resolve the alias

Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = devas)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = strl)))

OK (0 msec)

Drop the existing clone database

$ . oraenv

ORACLE_SID = [ttrl] ?strl

The Oracle base remains unchanged with value /u01/app/oracle

$ sqlplus sys as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Wed Jan 7 14:11:35 2015

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

Enter password:

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> shutdown immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL> startup mount restrict;

ORACLE instance started.

Total System Global Area 2088402944 bytes

Fixed Size 2160896 bytes

Variable Size 1275070208 bytes

Database Buffers 805306368 bytes

Redo Buffers 5865472 bytes

Database mounted.

SQL> drop database;

Database dropped.

Prepare for clone

  • Copy password file from production/standby and rename
  • Copy init.ora from production/standby and rename
  • Edit init.ora and make appropriate changes
  • Remove all Data Guard related parameters
  • Change parameters like db_name, control_file, db_file_name_convert, log_file_name_convert from ttrl to strl
  • Create required directories on target server for clone database
  • Add entries in listener.ora and tnsnames.ora for cloned database
  • Set environment to cloned database – strl

Start the cloned instance in NOMOUNT state

$ . oraenv

ORACLE_SID = [ttrl] ?strl

The Oracle base remains unchanged with value /u01/app/oracle

$ sqlplus sys as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Wed Jan 7 14:26:11 2015

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

Enter password:

Connected to an idle instance.

SQL> startupnomount;

ORACLE instance started.

Total System Global Area 2088402944 bytes

Fixed Size 2160896 bytes

Variable Size 1358956288 bytes

Database Buffers 721420288 bytes

Redo Buffers5865472 bytes

SQL>

From the Snapshot Standby environment, establish an RMAN auxiliary connection to the clone instance which is in nomount state at the moment

$ rman target sys/dbadmin1 auxiliary sys/dbadmin1@strl

Recovery Manager: Release 11.2.0.3.0 - Production on Wed Jan 7 14:30:09 2015

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

connected to target database: TTRL (DBID=3396213702)

connected to auxiliary database: STRL (not mounted)

Issue the DUPLICATE FROM ACTIVE DATABASE command

RMAN> duplicate target database to strl from active database nofilenamecheck;

Starting Duplicate Db at 07-JAN-15

using target database control file instead of recovery catalog

allocated channel: ORA_AUX_DISK_1

....

While the clone process in in progress simulate some changes being made to the primary database

Note that since the standby database is currently running in snapshot standby mode, redo will be shipped from primary to the standby site, but will not be applied at this stage.

$ sqlplus system/dbadmin1

SQL*Plus: Release 11.2.0.3.0 Production on Wed Jan 7 14:33:11 2015

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

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> create table myobjects as select * from dba_objects;

Table created.

SQL> select count(*) from myobjects;

COUNT(*)

------

70365

SQL> insert into myobjects select * from dba_objects;

70365 rows created.

SQL> commit;

Commit complete.

SQL> select count(*) from myobjects;

COUNT(*)

------

140730

Note the output of the RMAN DUPLICATE DATABASE command

RMAN> duplicate target database to strl from active database nofilenamecheck;

Starting Duplicate Db at 07-JAN-15

using target database control file instead of recovery catalog

allocated channel: ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: SID=114 device type=DISK

contents of Memory Script:

{

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 2088402944 bytes

Fixed Size2160896 bytes

Variable Size 1375733504 bytes

Database Buffers 704643072 bytes

Redo Buffers 5865472 bytes

contents of Memory Script:

{

sql clone "alter system setdb_name =

''TTRL'' comment=

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

sql clone "alter system setdb_unique_name =

''STRL'' comment=

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

shutdown clone immediate;

startup clone force nomount

backup as copy current controlfile auxiliary format '/u04/oradata/strl/control01.ctl';

restore clone controlfile to '/u05/oradata/strl/control02.ctl' from

'/u04/oradata/strl/control01.ctl';

restore clone controlfile to '/u05/oradata/strl/control03.ctl' from

'/u04/oradata/strl/control01.ctl';

alter clone database mount;

}

executing Memory Script

sql statement: alter system setdb_name = ''TTRL'' comment= ''Modified by RMAN duplicate'' scope=spfile

sql statement: alter system setdb_unique_name = ''STRL'' comment= ''Modified by RMAN duplicate'' scope=spfile

Oracle instance shut down

Oracle instance started

Total System Global Area 2088402944 bytes

Fixed Size 2160896 bytes

Variable Size 1375733504 bytes

Database Buffers704643072 bytes

Redo Buffers 5865472 bytes

Starting backup at 07-JAN-15

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=20 device type=DISK

channel ORA_DISK_1: starting datafile copy

copying current control file

output file name=/u01/app/oracle/product/11.2.0/dbhome_3/dbs/snapcf_ttrl.f tag=TAG20150107T143242 RECID=13 STAMP=868372362

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

Finished backup at 07-JAN-15

Starting restore at 07-JAN-15

allocated channel: ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: SID=66 device type=DISK

channel ORA_AUX_DISK_1: copied control file copy

Finished restore at 07-JAN-15

Starting restore at 07-JAN-15

using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: copied control file copy

Finished restore at 07-JAN-15

database mounted

contents of Memory Script:

{

sql clone 'alter database flashback off';

setnewname for datafile 1 to

"/u03/oradata/strl/system01.dbf";

setnewname for datafile 2 to

"/u03/oradata/strl/sysaux01.dbf";

setnewname for datafile 3 to

"/u03/oradata/strl/undotbs01.dbf";

setnewname for datafile 4 to

"/u03/oradata/strl/users01.dbf";

setnewname for datafile 5 to

"/u03/oradata/strl/tdl01.dbf";

setnewname for datafile 6 to

"/u03/oradata/strl/tdm01.dbf";

setnewname for datafile 7 to

"/u03/oradata/strl/tds01.dbf";

setnewname for datafile 8 to

"/u03/oradata/strl/til01.dbf";

setnewname for datafile 9 to

"/u03/oradata/strl/tis01.dbf";

setnewname for datafile 10 to

"/u03/oradata/strl/tim01.dbf";

backup as copy reuse

datafile 1 auxiliary format

"/u03/oradata/strl/system01.dbf"datafile

2 auxiliary format

"/u03/oradata/strl/sysaux01.dbf"datafile

3 auxiliary format

"/u03/oradata/strl/undotbs01.dbf"datafile

4 auxiliary format

"/u03/oradata/strl/users01.dbf"datafile

5 auxiliary format

"/u03/oradata/strl/tdl01.dbf"datafile

6 auxiliary format

"/u03/oradata/strl/tdm01.dbf"datafile

7 auxiliary format

"/u03/oradata/strl/tds01.dbf"datafile

8 auxiliary format

"/u03/oradata/strl/til01.dbf"datafile

9 auxiliary format

"/u03/oradata/strl/tis01.dbf"datafile

10 auxiliary format

"/u03/oradata/strl/tim01.dbf" ;

sql 'alter system archive log current';

}

executing Memory Script

sql statement: alter database flashback off

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting backup at 07-JAN-15

using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile copy

inputdatafile file number=00001 name=/u03/oradata/ttrl/system01.dbf

output file name=/u03/oradata/strl/system01.dbf tag=TAG20150107T143253

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

channel ORA_DISK_1: starting datafile copy

inputdatafile file number=00002 name=/u03/oradata/ttrl/sysaux01.dbf

output file name=/u03/oradata/strl/sysaux01.dbf tag=TAG20150107T143253

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

channel ORA_DISK_1: starting datafile copy

inputdatafile file number=00008 name=/u03/oradata/ttrl/til01.dbf

output file name=/u03/oradata/strl/til01.dbf tag=TAG20150107T143253

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

channel ORA_DISK_1: starting datafile copy

inputdatafile file number=00005 name=/u03/oradata/ttrl/tdl01.dbf

output file name=/u03/oradata/strl/tdl01.dbf tag=TAG20150107T143253

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

channel ORA_DISK_1: starting datafile copy

inputdatafile file number=00003 name=/u03/oradata/ttrl/undotbs01.dbf

output file name=/u03/oradata/strl/undotbs01.dbf tag=TAG20150107T143253

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

channel ORA_DISK_1: starting datafile copy

inputdatafile file number=00006 name=/u03/oradata/ttrl/tdm01.dbf

output file name=/u03/oradata/strl/tdm01.dbf tag=TAG20150107T143253

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

channel ORA_DISK_1: starting datafile copy

inputdatafile file number=00010 name=/u03/oradata/ttrl/tim01.dbf

output file name=/u03/oradata/strl/tim01.dbf tag=TAG20150107T143253

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

channel ORA_DISK_1: starting datafile copy

inputdatafile file number=00007 name=/u03/oradata/ttrl/tds01.dbf

output file name=/u03/oradata/strl/tds01.dbf tag=TAG20150107T143253

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

channel ORA_DISK_1: starting datafile copy

inputdatafile file number=00009 name=/u03/oradata/ttrl/tis01.dbf

output file name=/u03/oradata/strl/tis01.dbf tag=TAG20150107T143253

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

channel ORA_DISK_1: starting datafile copy

inputdatafile file number=00004 name=/u03/oradata/ttrl/users01.dbf

output file name=/u03/oradata/strl/users01.dbf tag=TAG20150107T143253

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

Finished backup at 07-JAN-15

sql statement: alter system archive log current

contents of Memory Script:

{

backup as copy reuse

archivelog like "/u02/oraback/ttrl/arch/ttrl_0868370727_0001_0000000005.arch" auxiliary format

"/u02/oraback/strl/arch/strl_0868370727_0001_0000000005.arch" ;

catalog clone archivelog "/u02/oraback/strl/arch/strl_0868370727_0001_0000000005.arch";

switch clone datafile all;

}

executing Memory Script

Starting backup at 07-JAN-15

using channel ORA_DISK_1

channel ORA_DISK_1: starting archived log copy

input archived log thread=1 sequence=5 RECID=1208 STAMP=868372462

output file name=/u02/oraback/strl/arch/strl_0868370727_0001_0000000005.arch RECID=0 STAMP=0

channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:01

Finished backup at 07-JAN-15

cataloged archived log

archived log file name=/u02/oraback/strl/arch/strl_0868370727_0001_0000000005.arch RECID=1208 STAMP=868372464

datafile 1 switched to datafile copy

inputdatafile copy RECID=13 STAMP=868372464 file name=/u03/oradata/strl/system01.dbf

datafile 2 switched to datafile copy

inputdatafile copy RECID=14 STAMP=868372464 file name=/u03/oradata/strl/sysaux01.dbf

datafile 3 switched to datafile copy

inputdatafile copy RECID=15 STAMP=868372464 file name=/u03/oradata/strl/undotbs01.dbf

datafile 4 switched to datafile copy

inputdatafile copy RECID=16 STAMP=868372464 file name=/u03/oradata/strl/users01.dbf

datafile 5 switched to datafile copy

inputdatafile copy RECID=17 STAMP=868372464 file name=/u03/oradata/strl/tdl01.dbf

datafile 6 switched to datafile copy

inputdatafile copy RECID=18 STAMP=868372464 file name=/u03/oradata/strl/tdm01.dbf

datafile 7 switched to datafile copy

inputdatafile copy RECID=19 STAMP=868372464 file name=/u03/oradata/strl/tds01.dbf

datafile 8 switched to datafile copy

inputdatafile copy RECID=20 STAMP=868372464 file name=/u03/oradata/strl/til01.dbf

datafile 9 switched to datafile copy

inputdatafile copy RECID=21 STAMP=868372464 file name=/u03/oradata/strl/tis01.dbf

datafile 10 switched to datafile copy

inputdatafile copy RECID=22 STAMP=868372464 file name=/u03/oradata/strl/tim01.dbf

contents of Memory Script:

{

set until scn 1296532233;

recover

clone database

deletearchivelog

;

}

executing Memory Script

executing command: SET until clause

Starting recover at 07-JAN-15

using channel ORA_AUX_DISK_1

starting media recovery

archived log for thread 1 with sequence 5 is already on disk as file /u02/oraback/strl/arch/strl_0868370727_0001_0000000005.arch

archived log file name=/u02/oraback/strl/arch/strl_0868370727_0001_0000000005.arch thread=1 sequence=5

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

Finished recover at 07-JAN-15

Oracle instance started

Total System Global Area 2088402944 bytes

Fixed Size 2160896 bytes

Variable Size 1375733504 bytes

Database Buffers 704643072 bytes

Redo Buffers 5865472 bytes

contents of Memory Script:

{

sql clone "alter system setdb_name =

''STRL'' comment=

''Reset to original value by RMAN'' scope=spfile";

sql clone "alter system resetdb_unique_name scope=spfile";

shutdown clone immediate;

startup clone nomount;

}

executing Memory Script

sql statement: alter system setdb_name = ''STRL'' comment= ''Reset to original value by RMAN'' scope=spfile

sql statement: alter system resetdb_unique_name scope=spfile

Oracle instance shut down

connected to auxiliary database (not started)

Oracle instance started

Total System Global Area 2088402944 bytes

Fixed Size 2160896 bytes

Variable Size 1375733504 bytes

Database Buffers 704643072 bytes

Redo Buffers 5865472 bytes

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

MAXLOGFILES 16

MAXLOGMEMBERS 5

MAXDATAFILES 100

MAXINSTANCES 8

MAXLOGHISTORY 1412

LOGFILE

GROUP 1 ( '/u04/oradata/strl/redo01a.log', '/u05/oradata/strl/redo01b.log' ) SIZE 150 M REUSE,

GROUP 2 ( '/u04/oradata/strl/redo02a.log', '/u05/oradata/strl/redo02b.log' ) SIZE 150 M REUSE,

GROUP 3 ( '/u04/oradata/strl/redo03a.log', '/u05/oradata/strl/redo03b.log' ) SIZE 150 M REUSE

DATAFILE

'/u03/oradata/strl/system01.dbf'

CHARACTER SET WE8MSWIN1252

contents of Memory Script:

{

setnewname for tempfile 1 to

"/u03/oradata/strl/temp01.dbf";

switch clone tempfile all;

catalog clone datafilecopy "/u03/oradata/strl/sysaux01.dbf",

"/u03/oradata/strl/undotbs01.dbf",

"/u03/oradata/strl/users01.dbf",

"/u03/oradata/strl/tdl01.dbf",

"/u03/oradata/strl/tdm01.dbf",

"/u03/oradata/strl/tds01.dbf",

"/u03/oradata/strl/til01.dbf",

"/u03/oradata/strl/tis01.dbf",

"/u03/oradata/strl/tim01.dbf";

switch clone datafile all;

}

executing Memory Script

executing command: SET NEWNAME

renamedtempfile 1 to /u03/oradata/strl/temp01.dbf in control file

catalogeddatafile copy

datafile copy file name=/u03/oradata/strl/sysaux01.dbf RECID=1 STAMP=868372488

catalogeddatafile copy

datafile copy file name=/u03/oradata/strl/undotbs01.dbf RECID=2 STAMP=868372488

catalogeddatafile copy

datafile copy file name=/u03/oradata/strl/users01.dbf RECID=3 STAMP=868372488

catalogeddatafile copy

datafile copy file name=/u03/oradata/strl/tdl01.dbf RECID=4 STAMP=868372488

catalogeddatafile copy

datafile copy file name=/u03/oradata/strl/tdm01.dbf RECID=5 STAMP=868372488

catalogeddatafile copy

datafile copy file name=/u03/oradata/strl/tds01.dbf RECID=6 STAMP=868372488

catalogeddatafile copy

datafile copy file name=/u03/oradata/strl/til01.dbf RECID=7 STAMP=868372488

catalogeddatafile copy

datafile copy file name=/u03/oradata/strl/tis01.dbf RECID=8 STAMP=868372488

catalogeddatafile copy

datafile copy file name=/u03/oradata/strl/tim01.dbf RECID=9 STAMP=868372488

datafile 2 switched to datafile copy

inputdatafile copy RECID=1 STAMP=868372488 file name=/u03/oradata/strl/sysaux01.dbf

datafile 3 switched to datafile copy

inputdatafile copy RECID=2 STAMP=868372488 file name=/u03/oradata/strl/undotbs01.dbf

datafile 4 switched to datafile copy

inputdatafile copy RECID=3 STAMP=868372488 file name=/u03/oradata/strl/users01.dbf

datafile 5 switched to datafile copy

inputdatafile copy RECID=4 STAMP=868372488 file name=/u03/oradata/strl/tdl01.dbf

datafile 6 switched to datafile copy

inputdatafile copy RECID=5 STAMP=868372488 file name=/u03/oradata/strl/tdm01.dbf

datafile 7 switched to datafile copy

inputdatafile copy RECID=6 STAMP=868372488 file name=/u03/oradata/strl/tds01.dbf

datafile 8 switched to datafile copy

inputdatafile copy RECID=7 STAMP=868372488 file name=/u03/oradata/strl/til01.dbf

datafile 9 switched to datafile copy

inputdatafile copy RECID=8 STAMP=868372488 file name=/u03/oradata/strl/tis01.dbf

datafile 10 switched to datafile copy

inputdatafile copy RECID=9 STAMP=868372488 file name=/u03/oradata/strl/tim01.dbf

Reenablingcontrolfile options for auxiliary database

Executing: alter database force logging

contents of Memory Script:

{

Alter clone database open resetlogs;

}

executing Memory Script

database opened

Executing: alter database flashback on

Finished Duplicate Db at 07-JAN-15

Convert the snapshot standby database back to original role of physical standby

DGMGRL> connect sys/dbadmin1

Connected.

DGMGRL> convert database ttrl_dr to physical standby;

Converting database "ttrl_dr" to a Physical Standby database, please wait...

Operation requires shutdown of instance "ttrl" on database "ttrl_dr"

Shutting down instance "ttrl"...

Database closed.

Database dismounted.

ORACLE instance shut down.

Operation requires startup of instance "ttrl" on database "ttrl_dr"

Starting instance "ttrl"...

ORACLE instance started.

Database mounted.

Continuing to convert database "ttrl_dr" ...

Operation requires shutdown of instance "ttrl" on database "ttrl_dr"

Shutting down instance "ttrl"...

ORA-01109: database not open

Database dismounted.

ORACLE instance shut down.

Operation requires startup of instance "ttrl" on database "ttrl_dr"

Starting instance "ttrl"...

ORACLE instance started.

Database mounted.

Database "ttrl_dr" converted successfully

Confirm the role transition

DGMGRL> show configuration

Configuration - ttrlDR

Protection Mode: MaxPerformance

Databases:

ttrl - Primary database

ttrl_dr - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:

SUCCESS

SQL> select database_role from v$database;

DATABASE_ROLE

------

PHYSICAL STANDBY

Open the Standby database and check if the changes made to the primary database while standby database was in snapshot standby mode have now been applied

SQL> select count(*) from system.myobjects;

select count(*) from system.myobjects

*

ERROR at line 1:

ORA-01219: database not open: queries allowed on fixed tables/views only

SQL> alter database open;

Database altered.

SQL> select count(*) from system.myobjects;

COUNT(*)

------

140730