Chinaunix首页 | 论坛 | 博客
  • 博客访问: 104586460
  • 博文数量: 19283
  • 博客积分: 9968
  • 博客等级: 上将
  • 技术积分: 196062
  • 用 户 组: 普通用户
  • 注册时间: 2007-02-07 14:28
文章分类

全部博文(19283)

文章存档

2011年(1)

2009年(125)

2008年(19094)

2007年(63)

分类: Oracle

2008-04-03 21:39:00

作者:盖国强 来源:

从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.

一切都非常的简便。

阅读(246) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~