oracle ADG备库重建视频教程

2018年3月16日 1076点热度 0人点赞 0条评论

1、登陆集团内网,左上方快速链接“Idisk”
2、找到“协作网盘”,“软件集团-运营商事业本部-华北中心”
注:由于采用html5,所以不支持低版本IE浏览器,建议使用chrome浏览器或其他浏览器。

在 “05-培训文档” --- “oracle相关”
ADG-rebuild.mp4

■主库备份
非压缩方式备份【比压缩方式快】:
run{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
allocate channel c4 type disk;
backup full database format '/nfs/bak/full%d%s%p%u.bak' plus archivelog;
release channel c1;
release channel c2;
release channel c3;
release channel c4;
}
压缩方式备份【比非压缩方式慢】:
run{
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
allocate channel c4 type disk;
backup full as compressed backupset database format '/nfs/bak/full%d%s%p%u.bak' plus archivelog;
release channel c1;
release channel c2;
release channel c3;
release channel c4;
}

■主库生成standby控制文件
backup device type disk format '/nfs/bak/standby%d%s%p%u.ctl' current controlfile for standby;
另一个生成standby控制文件的方式:
alter database create standby controlfile as '/nfs/bak/standby.ctl';

■把备份文件、standby控制文件拷贝到备库
此处使用nfs,无需拷贝,但需要修改备份文件的属性为777

■备库启动到NOMOUNT状态
startup nomount

■备库恢复控制文件
[oracle@dg dbs]$ rman target /
restore standby controlfile from '/nfs/bak/standby_JKDB_1469_1_dtstr683.ctl';

■备库启动到MOUNT状态
sql 'alter database mount';

■备库restore
run {
allocate channel c1 type disk;
allocate channel c2 type disk;
allocate channel c3 type disk;
allocate channel c4 type disk;
restore database;
release channel c1;
release channel c2;
release channel c3;
release channel c4;
}

■备库创建standby logfile
select name from v$datafile
union
select name from v$controlfile
union
select member from v$logfile;

alter database add standby logfile thread 1 group 21 size 2G, group 22 size 2G, group 23 size 2G, group 24 size 2G, group 25 size 2G;
alter database add standby logfile thread 2 group 31 size 2G, group 32 size 2G, group 33 size 2G, group 34 size 2G, group 35 size 2G;
alter database add standby logfile thread 3 group 41 size 2G, group 42 size 2G, group 43 size 2G, group 44 size 2G, group 45 size 2G;

创建完成后查询:
select group#,thread#,sequence#,archived,status from v$standby_log;

■打开备库日志同步
alter database recover managed standby database disconnect from session;

此时查看alertlog:
Thu Mar 15 10:54:36 2018
alter database recover managed standby database disconnect from session
Attempt to start background Managed Standby Recovery process (jkdb1)
Thu Mar 15 10:54:36 2018
MRP0 started with pid=46, OS id=49183
MRP0: Background Managed Standby Recovery process started (jkdb1)
started logmerger process
Thu Mar 15 10:54:41 2018
Managed Standby Recovery not using Real Time Apply
Parallel Media Recovery started with 64 slaves
Waiting for all non-current ORLs to be archived...
All non-current ORLs have been archived.
可见:adg启动了后台备库恢复进程MRP0,并提示没有使用实时恢复模式,启用了64个slaves,并等待所有的非当前ORLs归档。
这可能需要一段时间,需查看alertlog是否正常结束。此时如果打开数据库,会提示如下错误:

SYS@jkdb1> alter database open;
ERROR at line 1:
ORA-10456: cannot open standby database; media recovery session may be in progress
介质恢复正在进行!

干脆停止日志同步:
SYS@jkdb1> alter database recover managed standby database cancel;
Database altered.

直接启动到实时同步模式,让oracle自己跑去吧,直到同步完毕:
SYS@jkdb1> alter database recover managed standby database using current logfile disconnect from session;
Database altered.

确认redolog是否同步完毕:
select thread#, sequence#, name, first_time, next_time, applied from v$archived_log where applied <> 'YES' order by thread#, sequence#;
反复执行以上查询,可以看到没有同步的redolog越来越少,直到同步完毕。

发现备库172针对主库166的同步有问题:
Media Recovery Waiting for thread 2 sequence 22768
Error 1017 received logging on to the standby

Check that the primary and standby are using a password file
and remote_login_passwordfile is set to SHARED or EXCLUSIVE,
and that the SYS password is same in the password files.
returning error ORA-16191

FAL[client, USER]: Error 16191 connecting to jkdb2 for fetching gap sequence
经排查,确认是实例2的密码文件于2月28日被修改过,从实例1拷贝过来,再次同步成功。

liking

这个人很懒,什么都没留下

文章评论