使用rman duplicate搭建data guard

本文详细介绍使用RMAN及rmanduplicate命令搭建Oracle DataGuard环境的步骤,包括参数配置、备份文件传输、控制文件恢复及数据文件切换等关键操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

这里主要讲的是利用rman duplicate来进行备机数据的恢复的过程。
rman进行备份恢复往往常用于ASM磁盘组和RAC环境。事实上,感觉rman duplicate和rman 备份出来再手工恢复相比无非就是少了步set name的过程
以下是利用rman duplicate搭建data guard的主要步骤:

参数修改和文件,尤其注意db_file_name_convert和log_file_name_convert。这个参数关系到之后的自动set name步骤
监听,tnsnames。备机的listener.ora需要静态注册
密码文件

主库先做一次全备,ftp传到备机相同目录,注意权限
RMAN> backup format ‘/bak/full__%t_%s_%p’ database plus archivelog;
SQL> alter database force logging;
做一个standby controlfile传到备库,目录相同,注意权限
RMAN> backup format ‘/bak/20111013bak/ctl_%t_%s_%p’ current controlfile for standby;
备库起nomount,同时也检查参数是否正确。起监听。
主库开始利用rman duplicate做恢复
$ rman target /
Recovery Manager: Release 10.2.0.5.0 – Production on Wed Oct 19 16:32:48 2011

Copyright (c) 1982, 2007, Oracle. All rights reserved.

connected to target database: SAMP (DBID=00000000000)

RMAN> connect AUXILIARY sys/samp@rzsamp

connected to auxiliary database: SAMP (not mounted)

RMAN> DUPLICATE TARGET DATABASE FOR STANDBY; (只需这一条命令,以下动作RMAN自动会完成)

Starting Duplicate Db at 10/19/2011 16:33:51
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=1640 devtype=DISK

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

Starting restore at 10/19/2011 16:33:52
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 /Tbackup/samp/ctl_samp_764958200_3810_1
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/Tbackup/samp/ctl_samp_764958200_3810_1 tag=TAG20111019T162320
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03
output filename=/Tbackup/samp/oradata/control01.ctl
output filename=/Tbackup/samp/oradata/control02.ctl
output filename=/Tbackup/samp/oradata/control03.ctl
Finished restore at 10/19/2011 16:33:58

sql statement: alter database mount standby database

contents of Memory Script.:
{
set newname for tempfile 1 to
“/Tbackup/samp/oradata/temp01.dbf”;
switch clone tempfile all;
set newname for datafile 1 to
“/Tbackup/samp/oradata/system01.dbf”;
set newname for datafile 2 to
“/Tbackup/samp/oradata/users02.dbf”;
set newname for datafile 3 to
“/Tbackup/samp/oradata/sysaux01.dbf”;
set newname for datafile 4 to
“/Tbackup/samp/oradata/users01.dbf”;
set newname for datafile 20 to
“/Tbackup/samp/oradata/mccheck01.dbf”;
restore
check readonly
clone database
;
}
executing Memory Script

executing command: SET NEWNAME

renamed temporary file 1 to /Tbackup/samp/oradata/temp01.dbf in control file

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 10/19/2011 16:34:04
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 /Tbackup/samp/oradata/system01.dbf
restoring datafile 00002 to /Tbackup/samp/oradata/users02.dbf
restoring datafile 00003 to /Tbackup/samp/oradata/sysaux01.dbf
restoring datafile 00004 to /Tbackup/samp/oradata/users01.dbf
restoring datafile 00020 to /Tbackup/samp/oradata/mccheck01.dbf
channel ORA_AUX_DISK_1: reading from backup piece /Tbackup/samp/full_764956504_3807_1
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/Tbackup/samp/full_764956504_3807_1 tag=TAG20111019T155503
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:37:16
Finished restore at 10/19/2011 17:11:21

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

datafile 1 switched to datafile copy
input datafile copy recid=21 stamp=764961072 filename=/Tbackup/samp/oradata/system01.dbf
datafile 2 switched to datafile copy
input datafile copy recid=22 stamp=764961072 filename=/Tbackup/samp/oradata/users02.dbf
datafile 3 switched to datafile copy
input datafile copy recid=23 stamp=764961072 filename=/Tbackup/samp/oradata/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy recid=24 stamp=764961073 filename=/Tbackup/samp/oradata/users01.dbf
datafile 5 switched to datafile copy
input datafile copy recid=40 stamp=764961073 filename=/Tbackup/samp/oradata/mccheck01.dbf
Finished Duplicate Db at 10/19/2011 17:11:23


rman duplicate做完后,备库起DG恢复状态,再检查日志应用情况即可。
备库:
SQL>ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;

select SEQUENCE#,applied from v$archived_log;


通过rman duplicate自动完成的步骤,我们可以发现,其实就是完成了之前上次说的rman手工恢复的过程类似

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/24005010/viewspace-710279/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/24005010/viewspace-710279/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值