Wednesday, December 13, 2017

RMAN Database Cloning hotbackups.

RMAN Database Cloning hotbackups.

In this article i will illustrate all steps involved in cloning an Oracle Database with RMAN.

Assumptions:
Source Database: - DELL
Target Database: - DCLONE

Source DB - DELL (192.168.1.11)
[root@rac1 ~]# su - oracle
[oracle@rac1 ~]$
[oracle@rac1 ~]$ cat dell.env
export ORACLE_SID=DELL
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
export PATH=$ORACLE_HOME/bin:$PATH
export TNS_ADMIN=$ORACLE_HOME/network/admin
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib/usr/lib; export LD_LIBRARY_PATH


Add directories for archive and RMAN backups
[root@rac1 ~]# mkdir -p /u01/app/oracle/DELL/arch
[root@rac1 ~]# mkdir -p /u01/RMAN
[root@rac1 ~]# chown –R oracle:oinstall /u01
[root@rac1 ~]# chmod –R 775 /u01


Add Copy initDELL.ora to initDCLONE.ora and change as Parameters
[oracle@rac1 ~]$
[oracle@rac1 ~]$ . dell.env
[oracle@rac1 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Wed Dec 13 20:38:52 2017

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

Connected to an idle instance.

SQL> startup
SQL>
ORACLE instance started.

Total System Global Area 1043886080 bytes
Fixed Size                  2219952 bytes
Variable Size             603979856 bytes
Database Buffers          432013312 bytes
Redo Buffers                5672960 bytes
Database mounted.
Database opened.
SQL>
SQL>
SQL>
SQL> show parameter spfile;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      /u01/app/oracle/product/11.2.0
                                                 /dbhome_1/dbs/spfileDELL.ora
SQL>


SQL> archive log list;
Database log mode              No Archive Mode
Automatic archival             Disabled
Archive destination            /u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch
Oldest online log sequence     1
Current log sequence           2
SQL>
SQL> select name,open_mode from v$database;

NAME      OPEN_MODE
--------- --------------------
DELL      READ WRITE

SQL>
SQL> col TABLESPACE_NAME for a20;
SQL> col FILE_NAME for a40;
SQL> select TABLESPACE_NAME,FILE_NAME from dba_data_files;

TABLESPACE_NAME      FILE_NAME
-------------------- ----------------------------------------
USERS                /u01/app/oracle/DELL/users01.dbf
UNDOTBS1             /u01/app/oracle/DELL/undotbs01.dbf
SYSAUX               /u01/app/oracle/DELL/sysaux01.dbf
SYSTEM               /u01/app/oracle/DELL/system01.dbf

SQL>
SQL> create pfile from spfile;

File created.

SQL> shut
Database closed.
Database dismounted.
ORACLE instance shut down.
[oracle@rac1 ~]$ cd $ORACLE_HOME/dbs
[oracle@rac1 dbs]$
[oracle@rac1 dbs]$ cat initDELL.ora
DELL.__db_cache_size=432013312
DELL.__java_pool_size=4194304
DELL.__large_pool_size=4194304
DELL.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
DELL.__pga_aggregate_target=419430400
DELL.__sga_target=629145600
DELL.__shared_io_pool_size=0
DELL.__shared_pool_size=176160768
DELL.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/DELL/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='/u01/app/oracle/DELL/control01.ctl','/u01/app/oracle/DELL/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='DELL'
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=DELLXDB)'
*.memory_target=1047527424
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'
log_archive_dest=/u01/app/oracle/DELL/arch
[oracle@rac1 dbs]$

[oracle@rac1 dbs]$ mv spfileDELL.ora spfileDELL.ora_bkp
[oracle@rac1 dbs]$


Enable Archive log for RMAN Backup
[oracle@rac1 dbs]$
[oracle@rac1 dbs]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Wed Dec 13 20:40:30 2017

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

Connected to an idle instance.

SQL>
SQL> startup mount
ORACLE instance started.

Total System Global Area 1043886080 bytes
Fixed Size                  2219952 bytes
Variable Size             603979856 bytes
Database Buffers          432013312 bytes
Redo Buffers                5672960 bytes
Database mounted.
SQL>
SQL>
SQL> show parameter spfile;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string
SQL>
SQL> alter database archivelog;

Database altered.

SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /u01/app/oracle/DELL/arch
Oldest online log sequence     1
Next log sequence to archive   2
Current log sequence           2
SQL> alter database open;

Database altered.

SQL>

+++-----the following in Orange color is RMAN backup Script-----+++

sql 'alter system archive log current';
sql "alter session set nls_date_format=''dd.mm.yyyy hh24:mi:ss''";
RUN
{
CONFIGURE CONTROLFILE AUTOBACKUP ON;
configure retention policy to recovery window of 30 days;
CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COMPRESSED BACKUPSET PARALLELISM 4;
set command id to 'SCGOnlineBackupFull';
backup AS COMPRESSED BACKUPSET full database tag SC_FULL format '/u01/RMAN/%d_%T_%s_%p_FULL' ;
sql 'alter system archive log current';
backup tag SC_ARCHIVE format '/u01/RMAN/%d_%T_%s_%p_ARCHIVE' archivelog all not backed up ;
backup tag SC_CONTROL current controlfile format '/u01/RMAN/%d_%T_%s_%p_CONTROL';
crosscheck archivelog all;
delete noprompt archivelog until time 'SYSDATE-8';
delete noprompt obsolete device type disk;
}
+++----------------- END OF SCRIPT ----------------------+++
[oracle@rac1 dbs]$
[oracle@rac1 dbs]$ rman target /

Recovery Manager: Release 11.2.0.1.0 - Production on Wed Dec 13 20:22:10 2017

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

connected to target database: DELL (DBID=3933394912)

RMAN>

RMAN>RMAN>

RMAN> sql 'alter system archive log current';

sql "alter session set nls_date_format=''dd.mm.yyyy hh24:mi:ss''";
RUN
{
CONFIGURE CONTROLFILE AUTOBACKUP ON;
configure retention policy to recovery window of 30 days;
CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COMPRESSED BACKUPSET PARALLELISM 4;
set command id to 'SCGOnlineBackupFull';
backup AS COMPRESSED BACKUPSET full database tag SC_FULL format '/u01/RMAN/%d_%T_%s_%p_FULL' ;
sql 'alter system archive log current';
backup tag SC_ARCHIVE format '/u01/RMAN/%d_%T_%s_%p_ARCHIVE' archivelog all not backed up ;
backup tag SC_CONTROL current controlfile format '/u01/RMAN/%d_%T_%s_%p_CONTROL';
crosscheck archivelog all;
delete noprompt archivelog until time 'SYSDATE-8';
delete noprompt obsolete device type disk;
}
using target database control file instead of recovery catalog
sql statement: alter system archive log current

RMAN>
sql statement: alter session set nls_date_format=''dd.mm.yyyy hh24:mi:ss''

RMAN> 2> 3> 4> 5> 6> 7> 8> 9> 10> 11> 12> 13> 14>
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored

new RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 30 DAYS;
new RMAN configuration parameters are successfully stored

new RMAN configuration parameters:
CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COMPRESSED BACKUPSET PARALLELISM 4;
new RMAN configuration parameters are successfully stored

executing command: SET COMMAND ID

Starting backup at 13-DEC-17
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=34 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=35 device type=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: SID=36 device type=DISK
allocated channel: ORA_DISK_4
channel ORA_DISK_4: SID=37 device type=DISK
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/DELL/system01.dbf
channel ORA_DISK_1: starting piece 1 at 13-DEC-17
channel ORA_DISK_2: starting compressed full datafile backup set
channel ORA_DISK_2: specifying datafile(s) in backup set
input datafile file number=00002 name=/u01/app/oracle/DELL/sysaux01.dbf
channel ORA_DISK_2: starting piece 1 at 13-DEC-17
channel ORA_DISK_3: starting compressed full datafile backup set
channel ORA_DISK_3: specifying datafile(s) in backup set
input datafile file number=00003 name=/u01/app/oracle/DELL/undotbs01.dbf
channel ORA_DISK_3: starting piece 1 at 13-DEC-17
channel ORA_DISK_4: starting compressed full datafile backup set
channel ORA_DISK_4: specifying datafile(s) in backup set
input datafile file number=00004 name=/u01/app/oracle/DELL/users01.dbf
channel ORA_DISK_4: starting piece 1 at 13-DEC-17
channel ORA_DISK_4: finished piece 1 at 13-DEC-17
piece handle=/u01/RMAN/DELL_20171213_4_1_FULL tag=SC_FULL comment=NONE
channel ORA_DISK_4: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_3: finished piece 1 at 13-DEC-17
piece handle=/u01/RMAN/DELL_20171213_3_1_FULL tag=SC_FULL comment=NONE
channel ORA_DISK_3: backup set complete, elapsed time: 00:00:03
channel ORA_DISK_2: finished piece 1 at 13-DEC-17
piece handle=/u01/RMAN/DELL_20171213_2_1_FULL tag=SC_FULL comment=NONE
channel ORA_DISK_2: backup set complete, elapsed time: 00:00:25
channel ORA_DISK_1: finished piece 1 at 13-DEC-17
piece handle=/u01/RMAN/DELL_20171213_1_1_FULL tag=SC_FULL comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45
Finished backup at 13-DEC-17

Starting Control File Autobackup at 13-DEC-17
piece handle=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/c-3933394912-20171213-00 comment=NONE
Finished Control File Autobackup at 13-DEC-17

sql statement: alter system archive log current

Starting backup at 13-DEC-17
current log archived
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
using channel ORA_DISK_4
channel ORA_DISK_1: starting compressed archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=2 RECID=1 STAMP=962655748
channel ORA_DISK_1: starting piece 1 at 13-DEC-17
channel ORA_DISK_2: starting compressed archived log backup set
channel ORA_DISK_2: specifying archived log(s) in backup set
input archived log thread=1 sequence=3 RECID=2 STAMP=962655796
channel ORA_DISK_2: starting piece 1 at 13-DEC-17
channel ORA_DISK_3: starting compressed archived log backup set
channel ORA_DISK_3: specifying archived log(s) in backup set
input archived log thread=1 sequence=4 RECID=3 STAMP=962655796
channel ORA_DISK_3: starting piece 1 at 13-DEC-17
channel ORA_DISK_1: finished piece 1 at 13-DEC-17
piece handle=/u01/RMAN/DELL_20171213_6_1_ARCHIVE tag=SC_ARCHIVE comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_2: finished piece 1 at 13-DEC-17
piece handle=/u01/RMAN/DELL_20171213_7_1_ARCHIVE tag=SC_ARCHIVE comment=NONE
channel ORA_DISK_2: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_3: finished piece 1 at 13-DEC-17
piece handle=/u01/RMAN/DELL_20171213_8_1_ARCHIVE tag=SC_ARCHIVE comment=NONE
channel ORA_DISK_3: backup set complete, elapsed time: 00:00:01
Finished backup at 13-DEC-17

Starting backup at 13-DEC-17
using channel ORA_DISK_1
using channel ORA_DISK_2
using channel ORA_DISK_3
using channel ORA_DISK_4
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
channel ORA_DISK_1: starting piece 1 at 13-DEC-17
channel ORA_DISK_1: finished piece 1 at 13-DEC-17
piece handle=/u01/RMAN/DELL_20171213_9_1_CONTROL tag=SC_CONTROL comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 13-DEC-17

Starting Control File Autobackup at 13-DEC-17
piece handle=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/c-3933394912-20171213-01 comment=NONE
Finished Control File Autobackup at 13-DEC-17

released channel: ORA_DISK_1
released channel: ORA_DISK_2
released channel: ORA_DISK_3
released channel: ORA_DISK_4
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=34 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=35 device type=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: SID=36 device type=DISK
allocated channel: ORA_DISK_4
channel ORA_DISK_4: SID=37 device type=DISK
validation succeeded for archived log
archived log file name=/u01/app/oracle/DELL/arch/1_2_962654179.dbf RECID=1 STAMP=962655748
validation succeeded for archived log
archived log file name=/u01/app/oracle/DELL/arch/1_3_962654179.dbf RECID=2 STAMP=962655796
validation succeeded for archived log
archived log file name=/u01/app/oracle/DELL/arch/1_4_962654179.dbf RECID=3 STAMP=962655796
Crosschecked 3 objects


released channel: ORA_DISK_1
released channel: ORA_DISK_2
released channel: ORA_DISK_3
released channel: ORA_DISK_4
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=34 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=35 device type=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: SID=36 device type=DISK
allocated channel: ORA_DISK_4
channel ORA_DISK_4: SID=37 device type=DISK
specification does not match any archived log in the repository

RMAN retention policy will be applied to the command
RMAN retention policy is set to recovery window of 30 days
released channel: ORA_DISK_1
released channel: ORA_DISK_2
released channel: ORA_DISK_3
released channel: ORA_DISK_4
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=34 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=35 device type=DISK
allocated channel: ORA_DISK_3
channel ORA_DISK_3: SID=36 device type=DISK
allocated channel: ORA_DISK_4
channel ORA_DISK_4: SID=37 device type=DISK
no obsolete backups found

RMAN>

RMAN> exit


Recovery Manager complete.
[oracle@rac1 dbs]$

Check for RMAN Backup Pieces
[oracle@rac1 dbs]$ cd /u01/RMAN/
[oracle@rac1 RMAN]$ ll
total 265740
-rw-r----- 1 oracle oinstall 185761792 Dec 13 20:23 DELL_20171213_1_1_FULL
-rw-r----- 1 oracle oinstall  71180288 Dec 13 20:22 DELL_20171213_2_1_FULL
-rw-r----- 1 oracle oinstall   5431296 Dec 13 20:22 DELL_20171213_3_1_FULL
-rw-r----- 1 oracle oinstall   1073152 Dec 13 20:22 DELL_20171213_4_1_FULL
-rw-r----- 1 oracle oinstall   7267328 Dec 13 20:23 DELL_20171213_6_1_ARCHIVE
-rw-r----- 1 oracle oinstall      3584 Dec 13 20:23 DELL_20171213_7_1_ARCHIVE
-rw-r----- 1 oracle oinstall      2560 Dec 13 20:23 DELL_20171213_8_1_ARCHIVE
-rw-r----- 1 oracle oinstall   1097728 Dec 13 20:23 DELL_20171213_9_1_CONTROL
[oracle@rac1 RMAN]$


Copy the backup Pices to Target Machine
[oracle@rac1 RMAN]$ 
[oracle@rac1 RMAN]$ scp * root@rac2:/u01/RMAN
[oracle@rac1 RMAN]$ 
[oracle@rac1 RMAN]$ cd $ORACLE_HOME/dbs
[oracle@rac1 dbs]$ scp orapwDELL initDELL.ora root@rac2:$ORACLE_HOME/dbs



Target DB – Dclone (192.168.1.12)
[root@rac2 ~]# su - oracle
[oracle@rac2 ~]$
[oracle@rac2 ~]$ cat dclone.env
export ORACLE_SID=DCLONE
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
export PATH=$ORACLE_HOME/bin:$PATH
export TNS_ADMIN=$ORACLE_HOME/network/admin
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib/usr/lib; export LD_LIBRARY_PATH
[oracle@rac2 ~]$

Change the Pfile name to Clone “initDCLONE.ora”
[oracle@rac2 ~]$
[oracle@rac2 ~]$ . dclone.env
[oracle@rac2 ~]$
[oracle@rac2 ~]$ cd $ORACLE_HOME/dbs
[oracle@rac2 dbs]$
[oracle@rac2 dbs]$ cp initDELL.ora initDCLONE.ora
[oracle@rac2 dbs]$
[oracle@rac2 dbs]$ vi initDCLONE.ora
:%s/DELL/DCLONE/g

#--- Then add the following Parameters and save
db_file_name_convert=’/u01/app/oracle/DELL’,’/u01/app/oracle/DCLONE’
log_file_name_convert=’/u01/app/oracle/DELL’,’/u01/app/oracle/DCLONE’

:wq
[oracle@rac2 dbs]$

[oracle@rac2 dbs]$ cat initDCLONE.ora
DCLONE.__db_cache_size=432013312
DCLONE.__java_pool_size=4194304
DCLONE.__large_pool_size=4194304
DCLONE.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
DCLONE.__pga_aggregate_target=419430400
DCLONE.__sga_target=629145600
DCLONE.__shared_io_pool_size=0
DCLONE.__shared_pool_size=176160768
DCLONE.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/DCLONE/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='/u01/app/oracle/DCLONE/control01.ctl','/u01/app/oracle/DCLONE/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='DCLONE'
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=DCLONEXDB)'
*.memory_target=1047527424
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'
log_archive_dest=/u01/app/oracle/DCLONE/arch
db_file_name_convert='/u01/app/oracle/DELL','/u01/app/oracle/DCLONE'
log_file_name_convert='/u01/app/oracle/DELL','/u01/app/oracle/DCLONE'
[oracle@rac2 dbs]$

Create directory structure as per initDCLONE.ora
[root@rac2 ~]#
[root@rac2 ~]# mkdir -p /u01/app/oracle/DCLONE/arch
[root@rac2 ~]#
[root@rac2 ~]# mkdir -p /u01/app/oracle/admin/DCLONE/adump
[root@rac2 ~]#
[root@rac2 ~]# chown –R oracle:oinstall /u01

Connect to RMAN and Create Duplicate database
[root@rac2 ~]#
[root@rac2 ~]# su - oracle
[oracle@rac2 ~]$
[oracle@rac2 ~]$ . dclone.env
[oracle@rac2 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Wed Dec 13 20:52:15 2017

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

Connected to an idle instance.

SQL>
SQL> startup nomount
ORACLE instance started.

Total System Global Area 1043886080 bytes
Fixed Size                  2219952 bytes
Variable Size             603979856 bytes
Database Buffers          432013312 bytes
Redo Buffers                5672960 bytes
SQL>
SQL>
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@rac2 dbs]$
[oracle@rac2 dbs]$ rman auxiliary /

Recovery Manager: Release 11.2.0.1.0 - Production on Wed Dec 13 22:00:38 2017

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

connected to auxiliary database: DCLONE (not mounted)

RMAN>
RMAN> duplicate database to DCLONE backup location '/u01/RMAN';

Starting Duplicate Db at 13-DEC-17

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

Fixed Size                     2219952 bytes
Variable Size                608174160 bytes
Database Buffers             427819008 bytes
Redo Buffers                   5672960 bytes

contents of Memory Script:
{
   sql clone "alter system set  db_name =
 ''DELL'' comment=
 ''Modified by RMAN duplicate'' scope=spfile";
   sql clone "alter system set  db_unique_name =
 ''DCLONE'' comment=
 ''Modified by RMAN duplicate'' scope=spfile";
   shutdown clone immediate;
   startup clone force nomount
   restore clone primary controlfile from  '/u01/RMAN/DELL_20171213_9_1_CONTROL';
   alter clone database mount;
}
executing Memory Script

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

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

Oracle instance shut down

Oracle instance started

Total System Global Area    1043886080 bytes

Fixed Size                     2219952 bytes
Variable Size                608174160 bytes
Database Buffers             427819008 bytes
Redo Buffers                   5672960 bytes

Starting restore at 13-DEC-17
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=18 device type=DISK

channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:02
output file name=/u01/app/oracle/DCLONE/control01.ctl
output file name=/u01/app/oracle/DCLONE/control02.ctl
Finished restore at 13-DEC-17

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

contents of Memory Script:
{
   set until scn  954711;
   set newname for datafile  1 to
 "/u01/app/oracle/DCLONE/system01.dbf";
   set newname for datafile  2 to
 "/u01/app/oracle/DCLONE/sysaux01.dbf";
   set newname for datafile  3 to
 "/u01/app/oracle/DCLONE/undotbs01.dbf";
   set newname for datafile  4 to
 "/u01/app/oracle/DCLONE/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 13-DEC-17
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 00003 to /u01/app/oracle/DCLONE/undotbs01.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u01/RMAN/DELL_20171213_3_1_FULL
channel ORA_AUX_DISK_1: piece handle=/u01/RMAN/DELL_20171213_3_1_FULL tag=SC_FULL
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03
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 00004 to /u01/app/oracle/DCLONE/users01.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u01/RMAN/DELL_20171213_4_1_FULL
channel ORA_AUX_DISK_1: piece handle=/u01/RMAN/DELL_20171213_4_1_FULL tag=SC_FULL
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
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 00002 to /u01/app/oracle/DCLONE/sysaux01.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u01/RMAN/DELL_20171213_2_1_FULL
channel ORA_AUX_DISK_1: piece handle=/u01/RMAN/DELL_20171213_2_1_FULL tag=SC_FULL
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:25
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/oracle/DCLONE/system01.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u01/RMAN/DELL_20171213_1_1_FULL
channel ORA_AUX_DISK_1: piece handle=/u01/RMAN/DELL_20171213_1_1_FULL tag=SC_FULL
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:45
Finished restore at 13-DEC-17

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

datafile 1 switched to datafile copy
input datafile copy RECID=5 STAMP=962661820 file name=/u01/app/oracle/DCLONE/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=6 STAMP=962661820 file name=/u01/app/oracle/DCLONE/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=7 STAMP=962661820 file name=/u01/app/oracle/DCLONE/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=8 STAMP=962661820 file name=/u01/app/oracle/DCLONE/users01.dbf

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

executing command: SET until clause

Starting recover at 13-DEC-17
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=3
channel ORA_AUX_DISK_1: reading from backup piece /u01/RMAN/DELL_20171213_7_1_ARCHIVE
channel ORA_AUX_DISK_1: piece handle=/u01/RMAN/DELL_20171213_7_1_ARCHIVE tag=SC_ARCHIVE
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/oracle/DCLONE/arch/1_3_962654179.dbf thread=1 sequence=3
channel clone_default: deleting archived log(s)
archived log file name=/u01/app/oracle/DCLONE/arch/1_3_962654179.dbf RECID=1 STAMP=962661821
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/RMAN/DELL_20171213_8_1_ARCHIVE
channel ORA_AUX_DISK_1: piece handle=/u01/RMAN/DELL_20171213_8_1_ARCHIVE tag=SC_ARCHIVE
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/oracle/DCLONE/arch/1_4_962654179.dbf thread=1 sequence=4
channel clone_default: deleting archived log(s)
archived log file name=/u01/app/oracle/DCLONE/arch/1_4_962654179.dbf RECID=2 STAMP=962661822
media recovery complete, elapsed time: 00:00:00
Finished recover at 13-DEC-17

contents of Memory Script:
{
   shutdown clone immediate;
   startup clone nomount;
   sql clone "alter system set  db_name =
 ''DCLONE'' 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    1043886080 bytes

Fixed Size                     2219952 bytes
Variable Size                608174160 bytes
Database Buffers             427819008 bytes
Redo Buffers                   5672960 bytes

sql statement: alter system set  db_name =  ''DCLONE'' comment= ''Reset to original value by RMAN'' scope=spfile

sql statement: alter system reset  db_unique_name scope=spfile

Oracle instance shut down

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area    1043886080 bytes

Fixed Size                     2219952 bytes
Variable Size                608174160 bytes
Database Buffers             427819008 bytes
Redo Buffers                   5672960 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "DCLONE" RESETLOGS ARCHIVELOG
  MAXLOGFILES     16
  MAXLOGMEMBERS      3
  MAXDATAFILES      100
  MAXINSTANCES     8
  MAXLOGHISTORY      292
 LOGFILE
  GROUP  1 ( '/u01/app/oracle/DCLONE/redo01.log' ) SIZE 50 M  REUSE,
  GROUP  2 ( '/u01/app/oracle/DCLONE/redo02.log' ) SIZE 50 M  REUSE,
  GROUP  3 ( '/u01/app/oracle/DCLONE/redo03.log' ) SIZE 50 M  REUSE
 DATAFILE
  '/u01/app/oracle/DCLONE/system01.dbf'
 CHARACTER SET WE8MSWIN1252


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

executing command: SET NEWNAME

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

cataloged datafile copy
datafile copy file name=/u01/app/oracle/DCLONE/sysaux01.dbf RECID=1 STAMP=962661837
cataloged datafile copy
datafile copy file name=/u01/app/oracle/DCLONE/undotbs01.dbf RECID=2 STAMP=962661837
cataloged datafile copy
datafile copy file name=/u01/app/oracle/DCLONE/users01.dbf RECID=3 STAMP=962661837

datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=962661837 file name=/u01/app/oracle/DCLONE/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=962661837 file name=/u01/app/oracle/DCLONE/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=962661837 file name=/u01/app/oracle/DCLONE/users01.dbf

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

database opened
Finished Duplicate Db at 13-DEC-17

RMAN>

RMAN> exit


Recovery Manager complete.

Verify Cloned Database Details
[oracle@rac2 dbs]$
[oracle@rac2 dbs]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Wed Dec 13 22:04:51 2017

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select name, open_mode from v$DATABASE;

NAME      OPEN_MODE
--------- --------------------
DCLONE    READ WRITE

SQL>
SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /u01/app/oracle/DCLONE/arch
Oldest online log sequence     1
Next log sequence to archive   1
Current log sequence           1
SQL>
SQL> col TABLESPACE_NAME for a20;
SQL> col FILE_NAME for a40;
SQL> select TABLESPACE_NAME,FILE_NAME from dba_data_files;

TABLESPACE_NAME      FILE_NAME
-------------------- ----------------------------------------
SYSTEM               /u01/app/oracle/DCLONE/system01.dbf
SYSAUX               /u01/app/oracle/DCLONE/sysaux01.dbf
UNDOTBS1             /u01/app/oracle/DCLONE/undotbs01.dbf
USERS                /u01/app/oracle/DCLONE/users01.dbf

SQL>



This Article explains how to Clone ORACLE DATABASE in Linux Environment with RMAN.


No comments:

Post a Comment