利用rman快速搭建oracle dataguard standby
利用rman快速搭建oracle dataguard standby的过程
c:\rman target / catalog mailto:paultest/paultest@dev89]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 mailto:sys/abcdefg@standby]sys/abcdefg@standby
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>