利用rman快速搭建standby

paulyibinyi發表於2007-12-19

c:\rman target / catalog paultest/paultest@dev89
Recovery Manager: Release 9.2.0.4.0 - Production

Copyright (c) 1995, 2002, Oracle Corporation.  All rights reserved.

connected to target database: PAUL (DBID=1605165889)
connected to recovery catalog database

 RMAN> backup full  database include current controlfile for standby;

Starting backup at 19-DEC-07
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=9 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including standby controlfile in backupset
input datafile fno=00001 name=D:\ORACLE\ORADATA\PAUL\SYSTEM01.DBF
input datafile fno=00002 name=D:\ORACLE\ORADATA\PAUL\UNDOTBS01.DBF
input datafile fno=00003 name=D:\ORACLE\ORADATA\PAUL\INDX01.DBF
input datafile fno=00005 name=D:\ORACLE\ORADATA\PAUL\USERS01.DBF
input datafile fno=00004 name=D:\ORACLE\ORADATA\PAUL\TOOLS01.DBF
input datafile fno=00006 name=D:\TEST01_P.DBF
input datafile fno=00007 name=D:\TEST02_P.DBF
input datafile fno=00008 name=D:\TEST03_P.ORA
channel ORA_DISK_1: starting piece 1 at 19-DEC-07
channel ORA_DISK_1: finished piece 1 at 19-DEC-07
piece handle=D:\BACKUP\1QJ4078T_1_1 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:46
Finished backup at 19-DEC-07

Starting Control File and SPFILE Autobackup at 19-DEC-07
piece handle=D:\BACKUP\C-1605165889-20071219-02 comment=NONE
Finished Control File and SPFILE Autobackup at 19-DEC-07

RMAN>

Recovery Manager complete.

注意要執行以下語句,要不在用dulicate target database for standby 命令時,會產生一下錯誤

sql statement: alter database mount standby database
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 12/19/2007 12:10:23
RMAN-05507: standby controlfile checkpoint (849056) is more recent than duplication point in time (848440)
SQL> alter system archive log current;

System altered.

將產生的備份檔案複製到備用庫相同 d:\backup目錄下

在主庫上執行

c:\rman target / auxiliary

Recovery Manager: Release 9.2.0.4.0 - Production

Copyright (c) 1995, 2002, Oracle Corporation.  All rights reserved.

connected to target database: PAUL (DBID=1605165889)
connected to auxiliary database: paul (not mounted)

RMAN> duplicate target database for standby nofilenamecheck;
Starting Duplicate Db at 19-DEC-07
using target database controlfile instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=11 devtype=DISK

printing stored script. Memory Script
{
   restore clone standby controlfile to clone_cf;
   replicate clone controlfile from clone_cf;
   sql clone 'alter database mount standby database';
}
executing script. Memory Script

Starting restore at 19-DEC-07

using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: starting datafile backupset restore
channel ORA_AUX_DISK_1: restoring controlfile
output filename=D:\ORACLE\ORADATA\PAUL\CONTROL01.CTL
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=D:\BACKUP\1QJ4078T_1_1 tag=TAG20071219T115925 params=NULL
channel ORA_AUX_DISK_1: restore complete
Finished restore at 19-DEC-07

replicating controlfile
input filename=D:\ORACLE\ORADATA\PAUL\CONTROL01.CTL
output filename=D:\ORACLE\ORADATA\PAUL\CONTROL02.CTL
output filename=D:\ORACLE\ORADATA\PAUL\CONTROL03.CTL

sql statement: alter database mount standby database

printing stored script. Memory Script
{
   set until scn  849370;
   set newname for datafile  1 to
 "D:\ORACLE\ORADATA\PAUL\SYSTEM01.DBF";
   set newname for datafile  2 to
 "D:\ORACLE\ORADATA\PAUL\UNDOTBS01.DBF";
   set newname for datafile  3 to
 "D:\ORACLE\ORADATA\PAUL\INDX01.DBF";
   set newname for datafile  4 to
 "D:\ORACLE\ORADATA\PAUL\TOOLS01.DBF";
   set newname for datafile  5 to
 "D:\ORACLE\ORADATA\PAUL\USERS01.DBF";
   set newname for datafile  6 to
 "D:\TEST01_P.DBF";
   set newname for datafile  7 to
 "D:\TEST02_P.DBF";
   set newname for datafile  8 to
 "D:\TEST03_P.ORA";
   restore
   check readonly
   clone database
   ;
}
executing script. 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

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 19-DEC-07

using channel ORA_AUX_DISK_1
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 D:\ORACLE\ORADATA\PAUL\SYSTEM01.DBF
restoring datafile 00002 to D:\ORACLE\ORADATA\PAUL\UNDOTBS01.DBF
restoring datafile 00003 to D:\ORACLE\ORADATA\PAUL\INDX01.DBF
restoring datafile 00004 to D:\ORACLE\ORADATA\PAUL\TOOLS01.DBF
restoring datafile 00005 to D:\ORACLE\ORADATA\PAUL\USERS01.DBF
restoring datafile 00006 to D:\TEST01_P.DBF
restoring datafile 00007 to D:\TEST02_P.DBF
restoring datafile 00008 to D:\TEST03_P.ORA
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=D:\BACKUP\1QJ4078T_1_1 tag=TAG20071219T115925 params=NULL
channel ORA_AUX_DISK_1: restore complete
Finished restore at 19-DEC-07

printing stored script. Memory Script
{
   switch clone datafile all;
}
executing script. Memory Script

datafile 2 switched to datafile copy
input datafilecopy recid=20 stamp=641736804 filename=D:\ORACLE\ORADATA\PAUL\UNDOTBS01.DBF
datafile 3 switched to datafile copy
input datafilecopy recid=21 stamp=641736804 filename=D:\ORACLE\ORADATA\PAUL\INDX01.DBF
datafile 4 switched to datafile copy
input datafilecopy recid=22 stamp=641736804 filename=D:\ORACLE\ORADATA\PAUL\TOOLS01.DBF
datafile 5 switched to datafile copy
input datafilecopy recid=23 stamp=641736804 filename=D:\ORACLE\ORADATA\PAUL\USERS01.DBF
datafile 6 switched to datafile copy
input datafilecopy recid=24 stamp=641736804 filename=D:\TEST01_P.DBF
datafile 7 switched to datafile copy
input datafilecopy recid=25 stamp=641736804 filename=D:\TEST02_P.DBF
datafile 8 switched to datafile copy
input datafilecopy recid=26 stamp=641736804 filename=D:\TEST03_P.ORA
Finished Duplicate Db at 19-DEC-07

RMAN>

Recovery Manager complete.

然後在備庫啟用恢復管理模式:

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

資料庫已更改;

注意地方:

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

3.dulicate target database for standby 必須加上nofilenamecheck 引數,否則遇到相同檔名在做恢復時會報以下錯誤


sql statement: alter database mount standby database
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 12/19/2007 12:08:37
RMAN-05501: aborting duplication of target database
RMAN-05001: auxiliary filename D:\TEST03_P.ORA conflicts with a file used by the target database
RMAN-05001: auxiliary filename D:\TEST02_P.DBF conflicts with a file used by the
RMAN>

 

 

 

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

相關文章