ADG备库重建

2018年3月15日 10131点热度 0人点赞 0条评论

由于种种原因,ADG备库需要重建,以下详细描述了在不关闭主库的情况下,如何重建备库并实时同步。

清除备库数据的模拟操作大致是,oracle用户关闭备库,grid用户进入asmcmd,删除相关数据文件目录。确认备库的密码文件 $ORACLE_HOME/dbs/orapw<inst_name> 正确,tnsname.ora配置文件正确,确认之前建立的spfile文件正确。

■主库备份
非压缩方式备份【比压缩方式快】:
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;
}

■主库生成standby控制文件
backup device type disk format '/nfs/bak/standby_%d_%s_%p_%u.ctl' current controlfile for standby;

■把备份文件、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

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越来越少,直到同步完毕。

liking

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

文章评论