Oracle RMAN ile aynı sunucu üzerinde clone/copy database oluşturma
Vav ismindeki databaseimizi vav4 olarak aynı sunucu üzerine hızlı bir şekilde clonelayalım.
Bu senaryoda vav databaseinin full yedeği /backup dizinin altında.
$ export ORACLE_SID=vav4
$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Mon Feb 18 15:53:38 2013
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup nomount;
ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file ‘/usr/local/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/initvav4.ora’
SQL> quit
Disconnected
$ vi /usr/local/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/initvav4.ora
$ cat /usr/local/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/initvav4.ora
db_name=’vav4’
# Convert file names to allow for different directory structure if necessary.
DB_FILE_NAME_CONVERT=(/usr/local/oracle/app/oracle/oradata/vav/,/usr/local/oracle/app/oracle/oradata/vav4/)
LOG_FILE_NAME_CONVERT=(/usr/local/oracle/app/oracle/oradata/vav/,/usr/local/oracle/app/oracle/oradata/vav4/)
$ mkdir -p /usr/local/oracle/app/oracle/oradata/vav4
$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Mon Feb 18 15:55:06 2013
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup nomount;
ORACLE instance started.
Total System Global Area 304861184 bytes
Fixed Size 2212736 bytes
Variable Size 159386752 bytes
Database Buffers 134217728 bytes
Redo Buffers 9043968 bytes
SQL> show parameter conver
NAME TYPE VALUE
—————————————————— —————- ———————————————
db_file_name_convert string /usr/local/oracle/app/oracle/o
radata/vav/, /usr/local/oracle
/app/oracle/oradata/vav4/
log_file_name_convert string /usr/local/oracle/app/oracle/o
radata/vav/, /usr/local/oracle
/app/oracle/oradata/vav4/
SQL> quit
$ rman auxiliary /
Recovery Manager: Release 11.2.0.1.0 - Production on Mon Feb 18 15:55:53 2013
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
connected to auxiliary database: VAV4 (not mounted)
RMAN> DUPLICATE DATABASE TO vav4 BACKUP LOCATION ‘/backup/’ NOFILENAMECHECK;
Starting Duplicate Db at 18-FEB-13
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 304861184 bytes
Fixed Size 2212736 bytes
Variable Size 159386752 bytes
Database Buffers 134217728 bytes
Redo Buffers 9043968 bytes
contents of Memory Script:
{
sql clone “alter system set db_name =
”VAV” comment=
”Modified by RMAN duplicate” scope=spfile”;
sql clone “alter system set db_unique_name =
”VAV4” comment=
”Modified by RMAN duplicate” scope=spfile”;
shutdown clone immediate;
startup clone force nomount
restore clone primary controlfile from ’/backup/c-4283082488-20130218-02’;
alter clone database mount;
}
executing Memory Script
sql statement: alter system set db_name = ”VAV” comment= ”Modified by RMAN duplicate” scope=spfile
sql statement: alter system set db_unique_name = ”VAV4” comment= ”Modified by RMAN duplicate” scope=spfile
Oracle instance shut down
Oracle instance started
Total System Global Area 304861184 bytes
Fixed Size 2212736 bytes
Variable Size 159386752 bytes
Database Buffers 134217728 bytes
Redo Buffers 9043968 bytes
Starting restore at 18-FEB-13
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=133 device type=DISK
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/usr/local/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/cntrlvav4.dbf
Finished restore at 18-FEB-13
database mounted
released channel: ORA_AUX_DISK_1
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=133 device type=DISK
contents of Memory Script:
{
set until scn 61943415;
set newname for datafile 1 to
”/usr/local/oracle/app/oracle/oradata/vav4/system01.dbf”;
set newname for datafile 2 to
”/usr/local/oracle/app/oracle/oradata/vav4/sysaux01.dbf”;
set newname for datafile 3 to
”/usr/local/oracle/app/oracle/oradata/vav4/undotbs01.dbf”;
set newname for datafile 4 to
”/usr/local/oracle/app/oracle/oradata/vav4/users01.dbf”;
set newname for datafile 5 to
”/usr/local/oracle/app/oracle/oradata/vav4/VAV/datafile/o1_mf_tbs_mehm_8hx5fw82_.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
executing command: SET NEWNAME
Starting restore at 18-FEB-13
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 /usr/local/oracle/app/oracle/oradata/vav4/system01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00002 to /usr/local/oracle/app/oracle/oradata/vav4/sysaux01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00003 to /usr/local/oracle/app/oracle/oradata/vav4/undotbs01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00004 to /usr/local/oracle/app/oracle/oradata/vav4/users01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00005 to /usr/local/oracle/app/oracle/oradata/vav4/VAV/datafile/o1_mf_tbs_mehm_8hx5fw82_.dbf
channel ORA_AUX_DISK_1: reading from backup piece /backup/VAV_807719367_46.rman
channel ORA_AUX_DISK_1: piece handle=/backup/VAV_807719367_46.rman tag=TAG20130218T142927
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:35
Finished restore at 18-FEB-13
contents of Memory Script:
{
switch clone datafile all;
}
executing Memory Script
datafile 1 switched to datafile copy
input datafile copy RECID=6 STAMP=807724632 file name=/usr/local/oracle/app/oracle/oradata/vav4/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=7 STAMP=807724632 file name=/usr/local/oracle/app/oracle/oradata/vav4/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=8 STAMP=807724632 file name=/usr/local/oracle/app/oracle/oradata/vav4/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=9 STAMP=807724632 file name=/usr/local/oracle/app/oracle/oradata/vav4/users01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=10 STAMP=807724632 file name=/usr/local/oracle/app/oracle/oradata/vav4/VAV/datafile/o1_mf_tbs_mehm_8hx5fw82_.dbf
contents of Memory Script:
{
set until scn 61943415;
recover
clone database
delete archivelog
;
}
executing Memory Script
executing command: SET until clause
Starting recover at 18-FEB-13
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=101
channel ORA_AUX_DISK_1: reading from backup piece /backup/VAV_807719395_47.rman
channel ORA_AUX_DISK_1: piece handle=/backup/VAV_807719395_47.rman tag=TAG20130218T142954
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=/usr/local/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/arch/1_101_805379580.dbf thread=1 sequence=101
channel clone_default: deleting archived log(s)
archived log file name=/usr/local/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/arch/1_101_805379580.dbf RECID=1 STAMP=807724634
media recovery complete, elapsed time: 00:00:00
Finished recover at 18-FEB-13
contents of Memory Script:
{
shutdown clone immediate;
startup clone nomount;
sql clone “alter system set db_name =
”VAV4” 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 304861184 bytes
Fixed Size 2212736 bytes
Variable Size 159386752 bytes
Database Buffers 134217728 bytes
Redo Buffers 9043968 bytes
sql statement: alter system set db_name = ”VAV4” 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 304861184 bytes
Fixed Size 2212736 bytes
Variable Size 159386752 bytes
Database Buffers 134217728 bytes
Redo Buffers 9043968 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE “VAV4” RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 ( ‘/usr/local/oracle/app/oracle/oradata/vav4/redo01.log’ ) SIZE 50 M REUSE,
GROUP 2 ( ‘/usr/local/oracle/app/oracle/oradata/vav4/redo02.log’ ) SIZE 50 M REUSE,
GROUP 3 ( ‘/usr/local/oracle/app/oracle/oradata/vav4/redo03.log’ ) SIZE 50 M REUSE
DATAFILE
‘/usr/local/oracle/app/oracle/oradata/vav4/system01.dbf’
CHARACTER SET AL32UTF8
contents of Memory Script:
{
set newname for tempfile 1 to
”/usr/local/oracle/app/oracle/oradata/vav4/temp01.dbf”;
switch clone tempfile all;
catalog clone datafilecopy ”/usr/local/oracle/app/oracle/oradata/vav4/sysaux01.dbf”,
”/usr/local/oracle/app/oracle/oradata/vav4/undotbs01.dbf”,
”/usr/local/oracle/app/oracle/oradata/vav4/users01.dbf”,
”/usr/local/oracle/app/oracle/oradata/vav4/VAV/datafile/o1_mf_tbs_mehm_8hx5fw82_.dbf”;
switch clone datafile all;
}
executing Memory Script
executing command: SET NEWNAME
renamed tempfile 1 to /usr/local/oracle/app/oracle/oradata/vav4/temp01.dbf in control file
cataloged datafile copy
datafile copy file name=/usr/local/oracle/app/oracle/oradata/vav4/sysaux01.dbf RECID=1 STAMP=807724655
cataloged datafile copy
datafile copy file name=/usr/local/oracle/app/oracle/oradata/vav4/undotbs01.dbf RECID=2 STAMP=807724655
cataloged datafile copy
datafile copy file name=/usr/local/oracle/app/oracle/oradata/vav4/users01.dbf RECID=3 STAMP=807724655
cataloged datafile copy
datafile copy file name=/usr/local/oracle/app/oracle/oradata/vav4/VAV/datafile/o1_mf_tbs_mehm_8hx5fw82_.dbf RECID=4 STAMP=807724655
datafile 2 switched to datafile copy
input datafile copy RECID=1 STAMP=807724655 file name=/usr/local/oracle/app/oracle/oradata/vav4/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=2 STAMP=807724655 file name=/usr/local/oracle/app/oracle/oradata/vav4/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=807724655 file name=/usr/local/oracle/app/oracle/oradata/vav4/users01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=4 STAMP=807724655 file name=/usr/local/oracle/app/oracle/oradata/vav4/VAV/datafile/o1_mf_tbs_mehm_8hx5fw82_.dbf
contents of Memory Script:
{
Alter clone database open resetlogs;
}
executing Memory Script
database opened
Finished Duplicate Db at 18-FEB-13
RMAN> quit
Hepsi bu kadar.