使用RMAN進行快速Dataguard資料庫建立

dawn009發表於2014-05-20

從Oracle9i開始,Oracle允許使用duplicate的方式進行Dataguard備用資料庫的建立,非常簡便。

當然首先需要在主庫進行一個RMAN備份,然後需要將備份傳送到備用資料庫和主庫相同的目錄下。
在備用主機建立監聽、必要的目錄結構、引數檔案,啟動例項,然後就可以在主庫連線從庫進行恢復。

恢復的主要命令是: duplicate target database for standby;

$ rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Mon Aug 20 13:58:12 2007
Copyright (c) 1982, 2005, Oracle. All rights reserved.

connected to target database: EYGLE (DBID=1447940999)

RMAN> connect auxiliary sys/oracle@julia

connected to auxiliary database: EYGLE (not mounted)

RMAN> duplicate target database for standby;

Starting Duplicate Db at 20-AUG-07
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=155 devtype=DISK

contents of Memory Script:
{
restore clone standby controlfile;
sql clone 'alter database mount standby database';
}
executing Memory Script

Starting restore at 20-AUG-07
using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: starting datafile backupset restore
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: reading from backup piece /data2/ora10g/flash_recovery_area/EYGLE/backupset/2007_08_08/o1_mf_ncsnf_TAG20070808T104424_3clcn8p7_.bkp
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/data2/ora10g/flash_recovery_area/EYGLE/backupset/2007_08_08/o1_mf_ncsnf_TAG20070808T104424_3clcn8p7_.bkp tag=TAG20070808T104424
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:05
output filename=/data2/ora10g/oradata/JULIA/controlfile/o1_mf_3clr03bp_.ctl
output filename=/data2/ora10g/flash_recovery_area/JULIA/controlfile/o1_mf_3clr04gj_.ctl
Finished restore at 20-AUG-07

sql statement: alter database mount standby database
released channel: ORA_AUX_DISK_1

contents of Memory Script:
{
set newname for clone tempfile 1 to new;
switch clone tempfile all;
set newname for clone datafile 1 to new;
set newname for clone datafile 2 to new;
set newname for clone datafile 3 to new;
set newname for clone datafile 4 to new;
set newname for clone datafile 5 to new;
restore
check readonly
clone database
;
}
executing Memory Script

executing command: SET NEWNAME

renamed temporary file 1 to /data2/ora10g/oradata/JULIA/datafile/o1_mf_temp_%u_.tmp in control file

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 20-AUG-07
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=157 devtype=DISK

channel ORA_AUX_DISK_1: starting datafile backupset restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /data2/ora10g/oradata/JULIA/datafile/o1_mf_system_%u_.dbf
restoring datafile 00002 to /data2/ora10g/oradata/JULIA/datafile/o1_mf_undotbs1_%u_.dbf
restoring datafile 00003 to /data2/ora10g/oradata/JULIA/datafile/o1_mf_sysaux_%u_.dbf
restoring datafile 00004 to /data2/ora10g/oradata/JULIA/datafile/o1_mf_users_%u_.dbf
restoring datafile 00005 to /data2/ora10g/oradata/JULIA/datafile/o1_mf_eygle_%u_.dbf
channel ORA_AUX_DISK_1: reading from backup piece /data2/ora10g/flash_recovery_area/EYGLE/backupset/2007_08_08/o1_mf_nnndf_TAG20070808T104424_3clcj9k0_.bkp
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/data2/ora10g/flash_recovery_area/EYGLE/backupset/2007_08_08/o1_mf_nnndf_TAG20070808T104424_3clcj9k0_.bkp tag=TAG20070808T104424
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:04:28
Finished restore at 20-AUG-07

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

datafile 1 switched to datafile copy
input datafile copy recid=6 stamp=631118486 filename=/data2/ora10g/oradata/JULIA/datafile/o1_mf_system_3dlfnc5b_.dbf
datafile 2 switched to datafile copy
input datafile copy recid=7 stamp=631118486 filename=/data2/ora10g/oradata/JULIA/datafile/o1_mf_undotbs1_3dlfnc77_.dbf
datafile 3 switched to datafile copy
input datafile copy recid=8 stamp=631118487 filename=/data2/ora10g/oradata/JULIA/datafile/o1_mf_sysaux_3dlfnc80_.dbf
datafile 4 switched to datafile copy
input datafile copy recid=9 stamp=631118487 filename=/data2/ora10g/oradata/JULIA/datafile/o1_mf_users_3dlfncb6_.dbf
datafile 5 switched to datafile copy
input datafile copy recid=10 stamp=631118488 filename=/data2/ora10g/oradata/JULIA/datafile/o1_mf_eygle_3dlfnbx8_.dbf
Finished Duplicate Db at 20-AUG-07


然後從庫即可啟動進行恢復:

SQL> alter database mount standby database;
alter database mount standby database
*
ERROR at line 1:
ORA-01100: database already mounted


SQL> alter database recover managed standby database disconnect from session;

Database altered.


一切都非常的簡便。

-The End-

----------------------------------------------&gt>

轉載於:

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29119536/viewspace-1165411/,如需轉載,請註明出處,否則將追究法律責任。

相關文章