rman备份搭建DataGuard

前期参数设置部分忽略,可参考其它文章介绍。

1、从主库创建备库控制文件备份

backup current controlfile for standby format '/home/oracle/standby_controlfile.bak';

2、备份主库

run

allocate channel ch1 type disk;
allocate channel ch2 type disk;
allocate channel ch3 type disk;
allocate channel ch4 type disk;
backup database format '/home/oracle/DB0_%U.bak';
release channel ch1;
release channel ch2;
release channel ch3;
release channel ch4;
}

3、传输备份集到备库

scp xxxxxx.bak xxxxxx.bak oracle@xxx.xxx.xxx.xxx:/home/oracle/backup/

4、备库启动到umount状态

startup nomount

5、恢复备库控制文件

restore standby controlfile from '/home/oracle/xxxxxx.bak';

6、启动到mount状态

alter database mount;

7、注册备份集到控制文件

catalog start with '/home/oracle/backup/';

8、批量生成set newname语句

select 'set newname for datafile '||file#||' to ''/u01/app/oracle/oradata/orcl/'||substr(name,21,100)||''';' from v$datafile;

select 'set newname for tempfile '||file#||' to ''/u01/app/oracle/oradata/orcl/'||substr(name,21,100)||''';' from v$tempfile;

9、全库恢复

run

allocate channel ch1 type disk;
allocate channel ch2 type disk;
allocate channel ch3 type disk;
allocate channel ch4 type disk;
set newname for datafile 1 to '/u01/app/oracle/oradata/orclstd/system01.dbf';
set newname for datafile 2 to '/u01/app/oracle/oradata/orclstd/sysaux01.dbf';
set newname for datafile 3 to '/u01/app/oracle/oradata/orclstd/undotbs01.dbf';
set newname for datafile 4 to '/u01/app/oracle/oradata/orclstd/user01.dbf';
set newname for datafile 5 to '/u01/app/oracle/oradata/orclstd/test.dbf';
set newname for datafile 6 to '/u01/app/oracle/oradata/orclstd/testdg.dbf';
set newname for datafile 7 to '/u01/app/oracle/oradata/orclstd/testdg01.dbf';
set newname for datafile 8 to '/u01/app/oracle/oradata/orclstd/test02.dbf';
set newname for datafile 9 to '/u01/app/oracle/oradata/orclstd/testdg03.dbf';
restore database;
switch datafile all;
release channel ch1;
release channel ch2;
release channel ch3;
release channel ch4;
}

10、追加归档

recover database;

11、启用实时应用

alter database recover managed standby database using current logfile disconnect from session;

12、关闭实时应用

alter database recover managed standby database cancel;

13、打开数据库

alter database open;

14、开启实时应用

alter database recover managed standby database using current logfile disconnect from session;

15、测试是否同步

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值