Sunday, October 20, 2019

Database Refresh - ( Clone ) - RMAN - Duplicate database to ...

Database Refresh - ( Clone ) - RMAN - Duplicate database to ...

[oracle@stand ~]$ cat test.env
export ORACLE_SID=test
export ORACLE_HOME=/u01/app/12c/database/dbhome_2
export TNS_ADMIN=$ORACLE_HOME/network/admin
export PATH=$ORACLE_HOME/bin:/opt/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH


[oracle@stand dbs]$ cat initTEST_20OCT.ora
test.__data_transfer_cache_size=0
*.__db_cache_size=184M
test.__db_cache_size=289406976
test.__java_pool_size=4194304
test.__large_pool_size=8388608
*.__oracle_base='/u01/app/12c/database'# ORACLE_BASE set from environment
test.__pga_aggregate_target=293601280
test.__sga_target=486539264
test.__shared_io_pool_size=12582912
*.__shared_pool_size=128M
test.__shared_pool_size=159383552
test.__streams_pool_size=0
*.archive_lag_target=0
*.audit_file_dest='/u01/app/12c/database/admin/prim/adump'
*.audit_trail='DB'
*.compatible='12.1.0.2.0'
*.connection_brokers='((TYPE=DEDICATED)(BROKERS=1))','((TYPE=EMON)(BROKERS=1))'# connection_brokers default value
*.control_files='/u01/app/12c/database/oradata/prim/control01.ctl','/u01/app/12c/database/fast_recovery_area/prim/control02.ctl'#Restore Controlfile
*.core_dump_dest='/u01/app/12c/database/diag/rdbms/prim/test/cdump'
*.db_block_size=8192
*.db_domain='som.com'
*.db_file_name_convert='/u01/app/12c/database/oradata/stand','/u01/app/12c/database/oradata/prim'
*.db_name='TEST'#Reset to original value by RMAN
*.db_recovery_file_dest='/u01/app/12c/database/fast_recovery_area'
*.db_recovery_file_dest_size=4560M
*.db_unique_name='prim'
*.dg_broker_start=TRUE
*.diagnostic_dest='/u01/app/12c/database'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=primXDB)'
*.fal_client='PRIM'
*.fal_server='STAND'
*.log_archive_config='dg_config=(prim,stand)'
*.log_archive_dest_1='location=use_db_recovery_file_dest valid_for=(all_logfiles,all_roles) db_unique_name=prim'
*.log_archive_dest_2='service="stand"','ASYNC NOAFFIRM delay=0 optional compression=disable max_failure=0 max_connections=1 reopen=300 db_unique_name="stand" net_timeout=30','valid_for=(online_logfile,all_roles)'
*.log_archive_dest_state_2='ENABLE'
*.log_archive_max_processes=4
*.log_archive_min_succeed_dest=1
*.log_buffer=5068K# log buffer update
*.log_file_name_convert='/u01/app/12c/database/oradata/stand','/u01/app/12c/database/oradata/prim'
*.memory_target=744M
*.open_cursors=300
*.optimizer_dynamic_sampling=2
*.optimizer_mode='ALL_ROWS'
*.plsql_warnings='DISABLE:ALL'# PL/SQL warnings at init.ora
*.processes=300
*.query_rewrite_enabled='TRUE'
*.remote_login_passwordfile='EXCLUSIVE'
*.result_cache_max_size=1920K
*.skip_unusable_indexes=TRUE
*.standby_file_management='AUTO'
*.undo_tablespace='UNDOTBS1'



Once backup copied from Source , NOMOUNT USING above pfile and then use below method

[oracle@stand 2016_10_18]$ rman auxiliary /

Recovery Manager: Release 12.1.0.2.0 - Production on Sun Oct 20 18:18:27 2016

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

connected to auxiliary database: TEST (not mounted)

RMAN> DUPLICATE DATABASE TO "TEST"  BACKUP LOCATION '/u01/app/12c/database/fast_recovery_area/PRIM/backupset/2016_10_18' NOFILENAMECHECK;

Starting Duplicate Db at 20-OCT-16

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

Fixed Size                     2929256 bytes
Variable Size                587206040 bytes
Database Buffers             184549376 bytes
Redo Buffers                   5455872 bytes

contents of Memory Script:
{
   sql clone "alter system set  db_name =
 ''PRIM'' comment=
 ''Modified by RMAN duplicate'' scope=spfile";
   shutdown clone immediate;
   startup clone force nomount
   restore clone primary controlfile from  '/u01/app/12c/database/fast_recovery_area/PRIM/backupset/2016_10_18/o1_mf_ncsnf_TAG20161018T164053_gtm7kbb6_.bkp';
   alter clone database mount;
}
executing Memory Script

sql statement: alter system set  db_name =  ''PRIM'' comment= ''Modified by RMAN duplicate'' scope=spfile

Oracle instance shut down

Oracle instance started

Total System Global Area     780140544 bytes

Fixed Size                     2929256 bytes
Variable Size                583011736 bytes
Database Buffers             188743680 bytes
Redo Buffers                   5455872 bytes

Starting restore at 20-OCT-16
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=25 device type=DISK

channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03
output file name=/u01/app/12c/database/oradata/prim/control01.ctl
output file name=/u01/app/12c/database/fast_recovery_area/prim/control02.ctl
Finished restore at 20-OCT-16

database mounted
released channel: ORA_AUX_DISK_1
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=25 device type=DISK

contents of Memory Script:
{
   set until scn  2189123;
   set newname for datafile  1 to
 "/u01/app/12c/database/oradata/prim/system01.dbf";
   set newname for datafile  3 to
 "/u01/app/12c/database/oradata/prim/sysaux01.dbf";
   set newname for datafile  4 to
 "/u01/app/12c/database/oradata/prim/undotbs01.dbf";
   set newname for datafile  6 to
 "/u01/app/12c/database/oradata/prim/users01.dbf";
   restore
   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 20-OCT-16
using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00001 to /u01/app/12c/database/oradata/prim/system01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00003 to /u01/app/12c/database/oradata/prim/sysaux01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00004 to /u01/app/12c/database/oradata/prim/undotbs01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00006 to /u01/app/12c/database/oradata/prim/users01.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u01/app/12c/database/fast_recovery_area/PRIM/backupset/2016_10_18/o1_mf_nnndf_TAG20161018T164053_gtm7fy6w_.bkp
channel ORA_AUX_DISK_1: piece handle=/u01/app/12c/database/fast_recovery_area/PRIM/backupset/2016_10_18/o1_mf_nnndf_TAG20161018T164053_gtm7fy6w_.bkp tag=TAG20161018T164053
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:02:05
Finished restore at 20-OCT-16

contents of Memory Script:
{
   switch clone datafile all;
}
executing Memory Script

datafile 1 switched to datafile copy
input datafile copy RECID=1 STAMP=1022178438 file name=/u01/app/12c/database/oradata/prim/system01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=1022178438 file name=/u01/app/12c/database/oradata/prim/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=1022178438 file name=/u01/app/12c/database/oradata/prim/undotbs01.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=4 STAMP=1022178438 file name=/u01/app/12c/database/oradata/prim/users01.dbf

contents of Memory Script:
{
   set until scn  2189123;
   recover
   clone database
    delete archivelog
   ;
}
executing Memory Script

executing command: SET until clause

Starting recover at 20-OCT-16
using channel ORA_AUX_DISK_1

starting media recovery

channel ORA_AUX_DISK_1: starting archived log restore to default destination
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=4
channel ORA_AUX_DISK_1: reading from backup piece /u01/app/12c/database/fast_recovery_area/PRIM/backupset/2016_10_18/o1_mf_annnn_TAG20161018T164244_gtm7kd7d_.bkp
channel ORA_AUX_DISK_1: piece handle=/u01/app/12c/database/fast_recovery_area/PRIM/backupset/2016_10_18/o1_mf_annnn_TAG20161018T164244_gtm7kd7d_.bkp tag=TAG20161018T164244
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
archived log file name=/u01/app/12c/database/fast_recovery_area/PRIM/archivelog/2016_10_20/o1_mf_1_4_gtrpfk20_.arc thread=1 sequence=4
channel clone_default: deleting archived log(s)
archived log file name=/u01/app/12c/database/fast_recovery_area/PRIM/archivelog/2016_10_20/o1_mf_1_4_gtrpfk20_.arc RECID=1 STAMP=1022178441
media recovery complete, elapsed time: 00:00:00
Finished recover at 20-OCT-16
Oracle instance started

Total System Global Area     780140544 bytes

Fixed Size                     2929256 bytes
Variable Size                583011736 bytes
Database Buffers             188743680 bytes
Redo Buffers                   5455872 bytes

contents of Memory Script:
{
   sql clone "alter system set  db_name =
 ''TEST'' comment=
 ''Reset to original value by RMAN'' scope=spfile";
}
executing Memory Script

sql statement: alter system set  db_name =  ''TEST'' comment= ''Reset to original value by RMAN'' scope=spfile
Oracle instance started

Total System Global Area     780140544 bytes

Fixed Size                     2929256 bytes
Variable Size                583011736 bytes
Database Buffers             188743680 bytes
Redo Buffers                   5455872 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "TEST" RESETLOGS ARCHIVELOG
  MAXLOGFILES     16
  MAXLOGMEMBERS      3
  MAXDATAFILES      100
  MAXINSTANCES     8
  MAXLOGHISTORY      292
 LOGFILE
  GROUP   1 ( '/u01/app/12c/database/oradata/prim/redo01.log' ) SIZE 50 M  REUSE,
  GROUP   2 ( '/u01/app/12c/database/oradata/prim/redo02.log' ) SIZE 50 M  REUSE,
  GROUP   3 ( '/u01/app/12c/database/oradata/prim/redo03.log' ) SIZE 50 M  REUSE
 DATAFILE
  '/u01/app/12c/database/oradata/prim/system01.dbf'
 CHARACTER SET AL32UTF8


contents of Memory Script:
{
   set newname for tempfile  1 to
 "/u01/app/12c/database/oradata/prim/temp01.dbf";
   switch clone tempfile all;
   catalog clone datafilecopy  "/u01/app/12c/database/oradata/prim/sysaux01.dbf",
 "/u01/app/12c/database/oradata/prim/undotbs01.dbf",
 "/u01/app/12c/database/oradata/prim/users01.dbf";
   switch clone datafile all;
}
executing Memory Script

executing command: SET NEWNAME

renamed tempfile 1 to /u01/app/12c/database/oradata/prim/temp01.dbf in control file

cataloged datafile copy
datafile copy file name=/u01/app/12c/database/oradata/prim/sysaux01.dbf RECID=1 STAMP=1022178465
cataloged datafile copy
datafile copy file name=/u01/app/12c/database/oradata/prim/undotbs01.dbf RECID=2 STAMP=1022178465
cataloged datafile copy
datafile copy file name=/u01/app/12c/database/oradata/prim/users01.dbf RECID=3 STAMP=1022178465

datafile 3 switched to datafile copy
input datafile copy RECID=1 STAMP=1022178465 file name=/u01/app/12c/database/oradata/prim/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=2 STAMP=1022178465 file name=/u01/app/12c/database/oradata/prim/undotbs01.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=3 STAMP=1022178465 file name=/u01/app/12c/database/oradata/prim/users01.dbf
Reenabling controlfile options for auxiliary database
Executing: alter database force logging

contents of Memory Script:
{
   Alter clone database open resetlogs;
}
executing Memory Script

database opened
Cannot remove created server parameter file
Finished Duplicate Db at 20-OCT-16

RMAN>

SQL> select name,open_mode from v$database;

NAME      OPEN_MODE
--------- --------------------
TEST      READ WRITE


BR,

No comments:

Post a Comment