云平台网络异常使用增量备份恢复Oracle DG备库

云平台网络异常使用增量备份恢复Oracle DG备库

在云平台由于虚拟机网络故障导致主库网络瘫痪,主库实例恢复后,备库通过增量备份恢复案例。
1、查看备库告警日志
在这里插入图片描述
备库告警日志中最后要写的的是日志序列为63616的SRL日志,可以看到redo log在写入时有错误,checksum是检验文件的校验码,此时oracle给予的提示是可能网络连接无法连接主库。

看了下备库日志归档日志如下,自9.11号22:08之后就再无归档日志
在这里插入图片描述

备注:后面已经排查清楚,是由于主库sys密码改了,然而主库密码文件没有覆盖到备库上,导致备库一直没有归档日志。如下
在这里插入图片描述

2、主库日志序列
在这里插入图片描述

3、备库日志序列
在这里插入图片描述
自9.11到当前11月份为止所产生的归档日志已有400多g,直接用MOS上增量备份恢复方法肯定比注册归档日志要合适。
参考

Steps to perform for Rolling Forward a Physical Standby Database using
RMAN Incremental Backup. (文档 ID 836986.1)

在这里插入图片描述

4、备库上查询gap情况

SQL> select * from V$ARCHIVE_GAP;
no rows selected

备库无gap

5、停止备库的日志应用

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;

5、查看备库最小的scn

col MIN(CHECKPOINT_CHANGE#) for 999999999999999999
col CURRENT_SCN for 99999999999999999

(1)

查看备库数据文件头部最小的scn
SQL> select min(checkpoint_change#) from v$datafile_header;

MIN(CHECKPOINT_CHANGE#)
-----------------------
541057243        

(2)

X$KCVFH是GV$DATAFILE_HEADER的内部视图,检查下最小的检查点scn
SQL>  select min(fhscn) from x$kcvfh;

MIN(FHSCN)
------------------------------------------------
541057243

(3)
查看下当前的scn

SQL>  SELECT CURRENT_SCN FROM V$DATABASE;

       CURRENT_SCN
------------------
           541067278

6、确定主库是否添加数据文件

select FILE#,name from v$datafile where CREATION_CHANGE#> =541057243;
FILE# NAME
----- -----
no rows selected

主库没有在备库最小scn之后产生新的数据文件,所以不需要做RMAN数据文件备份

7、主库做增量备份

#!/bin/bash
export ORACLE_SID=orcl
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
export ORACLE_BASE=/u01/app/oracle
export NLS_LANG="AMERICAN_AMERICA.ZHS16GBK"
backtime=`date +"20%y%m%d%H%M%S"`
$ORACLE_HOME/bin/rman target / log=/u01/rman/db_$backtime.log <<EOF
run{
allocate channel c1 device type disk;
allocate channel c2 device type disk;
allocate channel c3 device type disk;
allocate channel c4 device type disk;
backup as compressed backupset INCREMENTAL from scn 541057243 database format '/u01/rman/zengliang_%u.bak' tag 'zengliang';-->那上面查到的最小scn为起点
release channel c1;
release channel c2;
release channel c3;
release channel c4;
}
exit
EOF

再生成备库的控制文件

alter database create standby controlfile as '/u01/rman/cf_file.ctl';

8、在备库恢复
拷贝备份和控制文件到备库

RMAN> shutdown;
RMAN> startup nomount;
RMAN> restore standby controlfile from '/u01/rman/cf_file.ctl';
RMAN> alter database mount;
RMAN> CATALOG START WITH '/u01/rman';
RMAN> recover database noredo;

备库输出日志过程

RMAN> recover database noredo;
Starting recover at 25-NOV-19
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=576 device type=DISK
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00005: /u01/app/oradata/standby/xcgov.dbf
destination for restore of datafile 00058: /oracle_nas/wangzhanqun116/standby/xc_ylx_01.dbf
destination for restore of datafile 00063: /oracle_nas/wangzhanqun116/standby/cgs_test01.dbf
channel ORA_DISK_1: reading from backup piece /u01/rman/zengliang_2ouhokf9.bak
channel ORA_DISK_1: piece handle=/u01/rman/zengliang_2ouhokf9.bak tag=ZENGLIANG
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00014: /u01/app/oradata/standby/XC_DCQ.dbf
destination for restore of datafile 00026: /u01/app/oradata/standby/XC_RFB.dbf
destination for restore of datafile 00039: /u01/app/oradata/standby/XC_HBJ.dbf
destination for restore of datafile 00049: /u01/app/oradata/standby/xc_cgs.dbf
destination for restore of datafile 00074: /oracle_nas/wangzhanqun116/standby/XC_DCQ01.dbf
destination for restore of datafile 00075: /oracle_nas/wangzhanqun116/standby/XC_DCQ02.dbf
channel ORA_DISK_1: reading from backup piece /u01/rman/zengliang_2nuhokf9.bak
channel ORA_DISK_1: piece handle=/u01/rman/zengliang_2nuhokf9.bak tag=ZENGLIANG
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:55
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00002: /u01/app/oradata/standby/sysaux01.dbf
destination for restore of datafile 00027: /u01/app/oradata/standby/XC_JTJ.dbf
destination for restore of datafile 00028: /u01/app/oradata/standby/XC_GTJ.dbf
destination for restore of datafile 00066: /oracle_nas/wangzhanqun116/standby/system01.dbf
destination for restore of datafile 00067: /oracle_nas/wangzhanqun116/standby/system02.dbf
channel ORA_DISK_1: reading from backup piece /u01/rman/zengliang_2muhokf9.bak
channel ORA_DISK_1: piece handle=/u01/rman/zengliang_2muhokf9.bak tag=ZENGLIANG
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:03:15
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00019: /u01/app/oradata/standby/xcgov2.dbf
destination for restore of datafile 00064: /oracle_nas/wangzhanqun116/standby/cgs_test02.dbf
destination for restore of datafile 00065: /oracle_nas/wangzhanqun116/standby/sysaux01.dbf
channel ORA_DISK_1: reading from backup piece /u01/rman/zengliang_2puhokjh.bak
channel ORA_DISK_1: piece handle=/u01/rman/zengliang_2puhokjh.bak tag=ZENGLIANG
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00001: /u01/app/oradata/standby/system01.dbf
destination for restore of datafile 00016: /u01/app/oradata/standby/XC_LYJ.dbf
destination for restore of datafile 00046: /u01/app/oradata/standby/XC_WDQ.dbf
destination for restore of datafile 00070: /oracle_nas/wangzhanqun116/standby/xc_cgj01.dbf
destination for restore of datafile 00071: /oracle_nas/wangzhanqun116/standby/xc_cgj02.dbf
channel ORA_DISK_1: reading from backup piece /u01/rman/zengliang_2quhokno.bak
channel ORA_DISK_1: piece handle=/u01/rman/zengliang_2quhokno.bak tag=ZENGLIANG
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:45
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00009: /u01/app/oradata/standby/swj.dbf
destination for restore of datafile 00022: /u01/app/oradata/standby/XC_NYJ.dbf
destination for restore of datafile 00047: /u01/app/oradata/standby/xc_jaq.dbf
destination for restore of datafile 00050: /u01/app/oradata/standby/xc_xcx.dbf
destination for restore of datafile 00076: /oracle_nas/wangzhanqun116/standby/XC_GHJ01.dbf
destination for restore of datafile 00077: /oracle_nas/wangzhanqun116/standby/XC_GHJ02.dbf
channel ORA_DISK_1: reading from backup piece /u01/rman/zengliang_2ruhokou.bak
channel ORA_DISK_1: piece handle=/u01/rman/zengliang_2ruhokou.bak tag=ZENGLIANG
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:45
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00030: /u01/app/oradata/standby/XC_GAJ.dbf
destination for restore of datafile 00037: /u01/app/oradata/standby/XC_GHJ.dbf
destination for restore of datafile 00048: /u01/app/oradata/standby/xc_yzs.dbf
destination for restore of datafile 00072: /oracle_nas/wangzhanqun116/standby/XC_CGS01.dbf
destination for restore of datafile 00073: /oracle_nas/wangzhanqun116/standby/XC_CGS02.dbf
channel ORA_DISK_1: reading from backup piece /u01/rman/zengliang_2suhokou.bak
channel ORA_DISK_1: piece handle=/u01/rman/zengliang_2suhokou.bak tag=ZENGLIANG
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:55
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00006: /u01/app/oradata/standby/XCZF_ZZ.dbf
destination for restore of datafile 00007: /u01/app/oradata/standby/njj.dbf
destination for restore of datafile 00008: /u01/app/oradata/standby/gxw.dbf
destination for restore of datafile 00051: /u01/app/oradata/standby/xc_ylx.dbf
destination for restore of datafile 00078: /oracle_nas/wangzhanqun116/standby/XC_GLJ01.dbf
destination for restore of datafile 00079: /oracle_nas/wangzhanqun116/standby/XC_GLJ02.dbf
channel ORA_DISK_1: reading from backup piece /u01/rman/zengliang_2tuhokv1.bak
channel ORA_DISK_1: piece handle=/u01/rman/zengliang_2tuhokv1.bak tag=ZENGLIANG
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00045: /u01/app/oradata/standby/sjj.dbf
destination for restore of datafile 00052: /u01/app/oradata/standby/XC_SJJnew.dbf
destination for restore of datafile 00054: /u01/app/oradata/standby/CZJNEW.dbf
destination for restore of datafile 00055: /u01/app/oradata/standby/CGS_TEST.dbf
destination for restore of datafile 00085: /oracle_nas/wangzhanqun116/standby/XC_NYJ02.dbf
destination for restore of datafile 00086: /oracle_nas/wangzhanqun116/standby/XC_RSJ01.dbf
channel ORA_DISK_1: reading from backup piece /u01/rman/zengliang_2uuhol13.bak
channel ORA_DISK_1: piece handle=/u01/rman/zengliang_2uuhol13.bak tag=ZENGLIANG
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00010: /u01/app/oradata/standby/sgj.dbf
destination for restore of datafile 00011: /u01/app/oradata/standby/XC_SFJ.dbf
destination for restore of datafile 00012: /u01/app/oradata/standby/XC_SFQ.dbf
destination for restore of datafile 00013: /u01/app/oradata/standby/XC_KFQ.dbf
destination for restore of datafile 00015: /u01/app/oradata/standby/XC_FGW.dbf
destination for restore of datafile 00080: /oracle_nas/wangzhanqun116/standby/XC_JYJ01.dbf
channel ORA_DISK_1: reading from backup piece /u01/rman/zengliang_30uhol55.bak
channel ORA_DISK_1: piece handle=/u01/rman/zengliang_30uhol55.bak tag=ZENGLIANG
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:55
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00017: /u01/app/oradata/standby/XC_KJJ.dbf
destination for restore of datafile 00018: /u01/app/oradata/standby/XC_AJJ.dbf
destination for restore of datafile 00020: /u01/app/oradata/standby/XC_LSJ.dbf
destination for restore of datafile 00021: /u01/app/oradata/standby/XC_MZJ.dbf
destination for restore of datafile 00023: /u01/app/oradata/standby/XC_CZJ.dbf
destination for restore of datafile 00081: /oracle_nas/wangzhanqun116/standby/XC_JYJ02.dbf
channel ORA_DISK_1: reading from backup piece /u01/rman/zengliang_31uhol84.bak
channel ORA_DISK_1: piece handle=/u01/rman/zengliang_31uhol84.bak tag=ZENGLIANG
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:45
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00056: /u01/app/oradata/standby/XCGOV_20180919.dbf
destination for restore of datafile 00057: /oracle_nas/wangzhanqun116/standby/xc_zjj_01.dbf
channel ORA_DISK_1: reading from backup piece /u01/rman/zengliang_2vuhol18.bak
channel ORA_DISK_1: piece handle=/u01/rman/zengliang_2vuhol18.bak tag=ZENGLIANG
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:04:35
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00024: /u01/app/oradata/standby/XC_TYJ.dbf
destination for restore of datafile 00025: /u01/app/oradata/standby/XC_GLJ.dbf
destination for restore of datafile 00029: /u01/app/oradata/standby/XC_WGXJ.dbf
destination for restore of datafile 00031: /u01/app/oradata/standby/XC_SWJ.dbf
destination for restore of datafile 00032: /u01/app/oradata/standby/XC_DZJ.dbf
destination for restore of datafile 00082: /oracle_nas/wangzhanqun116/standby/XC_KFQ02.dbf
channel ORA_DISK_1: reading from backup piece /u01/rman/zengliang_32uholcb.bak
channel ORA_DISK_1: piece handle=/u01/rman/zengliang_32uholcb.bak tag=ZENGLIANG
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00033: /u01/app/oradata/standby/XC_SYJ.dbf
destination for restore of datafile 00034: /u01/app/oradata/standby/XC_GSJ.dbf
destination for restore of datafile 00035: /u01/app/oradata/standby/XC_SJJ.dbf
destination for restore of datafile 00036: /u01/app/oradata/standby/XC_RSJ.dbf
destination for restore of datafile 00038: /u01/app/oradata/standby/XC_WJW.dbf
destination for restore of datafile 00083: /oracle_nas/wangzhanqun116/standby/XC_KFQ01.dbf
channel ORA_DISK_1: reading from backup piece /u01/rman/zengliang_33uholfa.bak
channel ORA_DISK_1: piece handle=/u01/rman/zengliang_33uholfa.bak tag=ZENGLIANG
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00059: /oracle_nas/wangzhanqun116/standby/xc_zjj_02.dbf
destination for restore of datafile 00061: /oracle_nas/wangzhanqun116/standby/xc_ylx_02.dbf
destination for restore of datafile 00087: /oracle_nas/wangzhanqun116/standby/XC_RSJ02.dbf
channel ORA_DISK_1: reading from backup piece /u01/rman/zengliang_35uholjn.bak
channel ORA_DISK_1: piece handle=/u01/rman/zengliang_35uholjn.bak tag=ZENGLIANG
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00040: /u01/app/oradata/standby/XC_JIAOTJ.dbf
destination for restore of datafile 00041: /u01/app/oradata/standby/XC_ZJJ.dbf
destination for restore of datafile 00042: /u01/app/oradata/standby/XC_CGJ.dbf
destination for restore of datafile 00043: /u01/app/oradata/standby/XC_GJJ.dbf
destination for restore of datafile 00044: /u01/app/oradata/standby/XC_XMJ.dbf
destination for restore of datafile 00084: /oracle_nas/wangzhanqun116/standby/XC_NYJ01.dbf
channel ORA_DISK_1: reading from backup piece /u01/rman/zengliang_34uholge.bak
channel ORA_DISK_1: piece handle=/u01/rman/zengliang_34uholge.bak tag=ZENGLIANG
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00003: /u01/app/oradata/standby/undotbs01.dbf
destination for restore of datafile 00060: /oracle_nas/wangzhanqun116/standby/testnas.dbf
destination for restore of datafile 00062: /oracle_nas/wangzhanqun116/standby/cs.dbf
channel ORA_DISK_1: reading from backup piece /u01/rman/zengliang_36uholm2.bak
channel ORA_DISK_1: piece handle=/u01/rman/zengliang_36uholm2.bak tag=ZENGLIANG
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00004: /u01/app/oradata/standby/users01.dbf
destination for restore of datafile 00053: /u01/app/oradata/standby/xcgov_test.dbf
destination for restore of datafile 00068: /oracle_nas/wangzhanqun116/standby/xcgov01.dbf
destination for restore of datafile 00069: /oracle_nas/wangzhanqun116/standby/xcgov02.dbf
channel ORA_DISK_1: reading from backup piece /u01/rman/zengliang_2luhokf9.bak
channel ORA_DISK_1: piece handle=/u01/rman/zengliang_2luhokf9.bak tag=ZENGLIANG
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:53:05

Finished recover at 25-NOV-19

RMAN> 

9、恢复中备库的日志

adrci> show alert -tail -f
2019-11-25 15:57:00.837000 +08:00
Incremental restore complete of datafile 84 /oracle_nas/wangzhanqun116/standby/XC_NYJ01.dbf
  checkpoint is 595658251
2019-11-25 15:57:09.833000 +08:00
Incremental restore complete of datafile 62 /oracle_nas/wangzhanqun116/standby/cs.dbf
  checkpoint is 595658895
2019-11-25 15:57:11.995000 +08:00
Incremental restore complete of datafile 60 /oracle_nas/wangzhanqun116/standby/testnas.dbf
  checkpoint is 595658895
2019-11-25 15:57:38.240000 +08:00
Incremental restore complete of datafile 3 /u01/app/oradata/standby/undotbs01.dbf
  checkpoint is 595658895
2019-11-25 15:58:25.986000 +08:00
Incremental restore complete of datafile 4 /u01/app/oradata/standby/users01.dbf
  checkpoint is 595651669
2019-11-25 16:50:20.382000 +08:00
Incremental restore complete of datafile 53 /u01/app/oradata/standby/xcgov_test.dbf
  checkpoint is 595651669
2019-11-25 16:50:48.643000 +08:00
Incremental restore complete of datafile 69 /oracle_nas/wangzhanqun116/standby/xcgov02.dbf
  checkpoint is 595651669
Incremental restore complete of datafile 68 /oracle_nas/wangzhanqun116/standby/xcgov01.dbf
  checkpoint is 595651669

增量恢复备库完毕

10、让备库开启mrp,把主库的redo刷到备库

这一步比较重要,如果跳过这步直接open,数据库会提示

ORA-10458: standby database requires recovery
ORA-01152: file 1 was not restored from a sufficiently old backup 
ORA-01110: data file 1: '/u01/app/oradata/standby/system01.dbf'

下面是通过mrp把主库日志写到备库再同步。

SQL> alter database recover managed standby database using current logfile disconnect;

这期间备库日志
在这里插入图片描述

开启mrp后,备库缺少的日志,主库会自动去写

11、在主库切几回日志,看下主库备库日志序列
主库

alter system switch logfile;
SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /u01/app/archlog/
Oldest online log sequence     78077
Next log sequence to archive   0
Current log sequence           78079

备库

SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /u01/app/archlog/
Oldest online log sequence     78077
Next log sequence to archive   0
Current log sequence           78079

主库备库日志序列已同步

12、open备库

刚才已经在备库用mrp同步日志了,为了open先cancel
SQL> alter database recover managed standby database cancel;

Database altered.

SQL> alter database open;

Database altered.
再次开启mrp
SQL> alter database recover managed standby database using current logfile disconnect;

Database altered.
SQL> select database_role,open_mode from v$database;

DATABASE_ROLE    OPEN_MODE
---------------- --------------------
PHYSICAL STANDBY READ ONLY WITH APPLY


SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /u01/app/archlog/
Oldest online log sequence     78077
Next log sequence to archive   0
Current log sequence           78079

备库已开启mrp实时同步,并且日志序列与主库同步

13、手动验证
后面主库与备库手动验证数据一致性,没问题

在这里插入图片描述
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值