科技行者

行者学院 转型私董会 科技行者专题报道 网红大战科技行者

知识库

知识库 安全导航

至顶网软件频道[盖国强]使用Oracle RMAN进行快速Dataguard数据库创建

[盖国强]使用Oracle RMAN进行快速Dataguard数据库创建

  • 扫一扫
    分享文章到微信

  • 扫一扫
    关注官方公众号
    至顶头条

从Oracle9i开始,Oracle允许使用duplicate的方式进行Dataguard备用数据库的创建,非常简便。当然首先需要在主库进行一个RMAN备份,然后需要将备份传送到备用数据库和主库相同的目录下。

作者:盖国强 来源:

关键字: ORACLE RMAN Dataguard 盖国强 eygle

  • 评论
  • 分享微博
  • 分享邮件

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

一切都非常的简便。

查看本文来源

    • 评论
    • 分享微博
    • 分享邮件
    邮件订阅

    如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。

    重磅专题
    往期文章
    最新文章