使用RMAN增量备份处理Dataguard因归档丢失造成的gap
场景:
备库执行日志应用出现如下报错:
Thu Mar 29 11:21:45 2018
FAL[client]: Failed to request gap sequence
GAP - thread 1 sequence 184-185
DBID 1484954774 branch 960494131
FAL[client]: All defined FAL servers have been attempted.
------------------------------------------------------------
Check that the CONTROL_FILE_RECORD_KEEP_TIME initialization
parameter is defined to a value that's sufficiently large
enough to maintain adequate log switch information to resolve
archivelog gaps.
查询缺失的归档日志:
SQL> select * from v$archive_gap;
THREAD# LOW_SEQUENCE# HIGH_SEQUENCE#
---------- ------------- --------------
1 183 185
去主库查看归档,发现归档已丢失
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /u01/archivelog
Oldest online log sequence 186
Next log sequence to archive 188
Current log sequence 188
[oracle@prim archivelog]$ pwd
/u01/archivelog
[oracle@prim archivelog]$ ls -ltr
total 1964
-rw-r----- 1 oracle oinstall 74752 Mar 29 11:17 1_186_960494131.dbf
-rw-r----- 1 oracle oinstall 1930240 Mar 29 11:17 1_187_960494131.dbf
下面开始使用RMAN进行基于SCN增量备份恢复的方式进行恢复,参考文档 ID 836986.1
1.取消备库日志应用
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE cancel;
2.在备库上确定需要开始增量备份的SCN
SQL> SELECT CURRENT_SCN FROM V$DATABASE;
CURRENT_SCN
-----------
3505254
SQL> select min(checkpoint_change#) from v$datafile_header
where file# not in (select file# from v$datafile where enabled = 'READ ONLY');
MIN(CHECKPOINT_CHANGE#)
-----------------------
(如果结果为空,重启备库到mount状态)
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 1002127360 bytes
Fixed Size 2259440 bytes
Variable Size 285214224 bytes
Database Buffers 708837376 bytes
Redo Buffers 5816320 bytes
Database mounted.
SQL> select min(checkpoint_change#) from v$datafile_header
where file# not in (select file# from v$datafile where enabled = 'READ ONLY');
MIN(CHECKPOINT_CHANGE#)
-----------------------
3505255
选择以上结果中最小SCN作为增量备份的起点(此处是350524)。
3.在主库上进行基于SCN的增量备份
RMAN> BACKUP INCREMENTAL FROM SCN 3505254 DATABASE FORMAT '/tmp/ForStandby_%U' tag 'FORSTANDBY';
4.拷贝刚才的备份到备库
scp /tmp/ForStandby_* 192.168.211.162:/tmp
5.将拷贝过来的备份注册到备库的控制文件中
[oracle@stand ~]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Thu Mar 29 11:37:52 2018
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORCL (DBID=1484954774, not open)
RMAN> CATALOG START WITH '/tmp/ForStandby';
using target database control file instead of recovery catalog
searching for all files that match the pattern /tmp/ForStandby
List of Files Unknown to the Database
=====================================
File Name: /tmp/ForStandby_08sv0bdj_1_1
File Name: /tmp/ForStandby_07sv0bcg_1_1
Do you really want to catalog the above files (enter YES or NO)? yes
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /tmp/ForStandby_08sv0bdj_1_1
File Name: /tmp/ForStandby_07sv0bcg_1_1
6.使用增量备份恢复备库
RMAN> RECOVER DATABASE NOREDO;
Starting recover at 29-MAR-18
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=16 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 00001: /u01/app/oracle/oradata/rzorcl/system01.dbf
destination for restore of datafile 00002: /u01/app/oracle/oradata/rzorcl/sysaux01.dbf
destination for restore of datafile 00003: /u01/app/oracle/oradata/rzorcl/undotbs01.dbf
destination for restore of datafile 00004: /u01/app/oracle/oradata/rzorcl/users01.dbf
destination for restore of datafile 00005: /u01/app/oracle/oradata/rzorcl/example01.dbf
destination for restore of datafile 00006: /u01/app/oracle/oradata/rzorcl/odc_tps01.dbf
destination for restore of datafile 00007: /u01/app/oracle/oradata/rzorcl/test01.dbf
destination for restore of datafile 00008: /u01/app/oracle/oradata/rzorcl/big01.dbf
destination for restore of datafile 00009: /u01/app/oracle/oradata/rzorcl/big02.dbf
channel ORA_DISK_1: reading from backup piece /tmp/ForStandby_07sv0bcg_1_1
channel ORA_DISK_1: piece handle=/tmp/ForStandby_07sv0bcg_1_1 tag=FORSTANDBY
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished recover at 29-MAR-18
7.在主库为备库重新备份控制文件,并scp到备库
RMAN> BACKUP CURRENT CONTROLFILE FOR STANDBY FORMAT '/tmp/ForStandbyCTRL.bck';
Starting backup at 29-MAR-18
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=9 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including standby control file in backup set
channel ORA_DISK_1: starting piece 1 at 29-MAR-18
channel ORA_DISK_1: finished piece 1 at 29-MAR-18
piece handle=/tmp/ForStandbyCTRL.bck tag=TAG20180329T114413 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 29-MAR-18
[oracle@prim tmp]$ scp ForStandbyCTRL.bck 192.168.211.162:/tmp
oracle@192.168.211.162's password:
ForStandbyCTRL.bck 100% 9856KB 9.6MB/s 00:00
8.备库还原控制文件:
RMAN> shutdown immediate;
database dismounted
Oracle instance shut down
RMAN> startup nomount;
connected to target database (not started)
Oracle instance started
Total System Global Area 1002127360 bytes
Fixed Size 2259440 bytes
Variable Size 285214224 bytes
Database Buffers 708837376 bytes
Redo Buffers 5816320 bytes
RMAN> RESTORE STANDBY CONTROLFILE FROM '/tmp/ForStandbyCTRL.bck';
Starting restore at 29-MAR-18
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=10 device type=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/app/oracle/oradata/rzorcl/control01.ctl
output file name=/u01/app/oracle/oradata/rzorcl/control02.ctl
Finished restore at 29-MAR-18
9.重启备库到mount
RMAN> SHUTDOWN;
RMAN> STARTUP MOUNT;
10.如果数据库是用OMF方式管理数据文件的,则需要在备库的控制文件中重新注册下数据文件,示例如下:
(如果数据文件存放在文件系统,没有使用OMF,则跳过此步骤)
RMAN> CATALOG START WITH '+DATA/rzorcl/datafile/';
List of Files Unknown to the Database
=====================================
File Name: +data/rzorcl/DATAFILE/SYSTEM.309.685535773
File Name: +data/rzorcl/DATAFILE/SYSAUX.301.685535773
File Name: +data/rzorcl/DATAFILE/UNDOTBS1.302.685535775
File Name: +data/rzorcl/DATAFILE/SYSTEM.297.688213333
File Name: +data/rzorcl/DATAFILE/SYSAUX.267.688213333
File Name: +data/rzorcl/DATAFILE/UNDOTBS1.268.688213335
Do you really want to catalog the above files (enter YES or NO)? YES
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: +data/rzorcl/DATAFILE/SYSTEM.297.688213333
File Name: +data/rzorcl/DATAFILE/SYSAUX.267.688213333
File Name: +data/rzorcl/DATAFILE/UNDOTBS1.268.688213335
确保主库在这个SCN之后没有添加新的数据文件,如果有则需要单独进行备份和还原,参考文档文档 ID 836986.1
SQL> select file#,name from v$datafile where creation_change# > 3505254;
no rows selected
RMAN> SWITCH DATABASE TO COPY;
datafile 1 switched to datafile copy "+DATA/rzorcl/datafile/system.297.688213333"
datafile 2 switched to datafile copy "+DATA/rzorcl/datafile/undotbs1.268.688213335"
datafile 3 switched to datafile copy "+DATA/rzorcl/datafile/sysaux.267.688213333"
11. 若备库开启了闪回,需要重新开启闪回
SQL> ALTER DATABASE FLASHBACK OFF;
SQL> ALTER DATABASE FLASHBACK ON;
12. 备库clear standby log group
SQL> ALTER DATABASE CLEAR LOGFILE GROUP 4;
SQL> ALTER DATABASE CLEAR LOGFILE GROUP 5;
SQL> ALTER DATABASE CLEAR LOGFILE GROUP 6;
SQL> ALTER DATABASE CLEAR LOGFILE GROUP 7;
13. 备库开启日志应用,至此整个过程结束
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
使用RMAN增量备份处理Dataguard因归档丢失造成的gap的更多相关文章
- 如何通过rman的增量备份恢复dataguard中standby端的数据
很多正在使用dataguard的客户,都会遇到一个棘手的问题: 在备份端与主库同步的过程中由于网络原因或磁盘问题导致一个或多个归档日志丢失,进而dataguard同步无法继续.很多客户都选择了重新全库 ...
- oracle11gRAC环境使用RMAN增量备份方案
转摘:http://blog.itpub.net/29819001/viewspace-1320977/ [oracle@zx ~]$ rman target /Recovery Manager: R ...
- RMAN增量备份-备份保留策略-设置备份集属性
RMAN增量备份:增量备份级别:0,1,2,3,4BACKUP DATABASE也是创建数据库的完整备份,但是这种备份不同于增量备份的0级备份.这种备份不包含增量备份的0级备份,并不支持在此基础上再创 ...
- 如何使用块更改跟踪文件估算RMAN增量备份大小 (Doc ID 1938079.1)
How to estimate RMAN incremental backup size using block change tracking file (Doc ID 1938079.1) APP ...
- 【转】在rman增量备份中,有差异增量和累积增量的概念
本文转自hougoo的博客 1.概念 差异增量:是备份上级及同级备份以来所有变化的数据块,差异增量是默认增量备份方式 累积增量:是备份上级备份以来所有变化的块 因为累积增量是备份上级备份以来所有变化的 ...
- Oracle 12 Rman增量备份
增量备份 增量备份主要作用是仅复制自上次备份以来已更改的数据块.您可以使用RMAN创建数据文件,表空间或整个数据库的增量备份. 将增量备份作为策略的一部分的主要原因是: 用于基于增量更新备份的策略,其 ...
- 怎样使用 RMAN 增量备份恢复 data guard log gap(日志断档)
主库查询最小scn 信息: SQL> col current_scn for 999999999999999 SQL> SELECT CURRENT_SCN FROM V$DATABAS ...
- Oracle Rman 增量备份与差异备份
一.增量与差异 关于Incremental增量备份级别: Oracle 9i 共有五种级别 0 1 2 3 4,0级最高-4级最低,0级是1级的基础以此类推. Oracle 10g官方文档明确指出增量 ...
- 【RMAN】使用RMAN增量备份刷新 Standby Database
Step 1: Create the Incremental Backup RMAN> BACKUP DEVICE TYPE DISK INCREMENTAL FROM SCN 750983 D ...
随机推荐
- CSS基础-CSS三大特性
继承性 层叠性 优先级 优先级权重 !important
- 51Nod 算法马拉松22 开黑记
这是一场惨烈的开黑大战,始于全机房开黑指望刷进rank前十拿钱的壮志,终于被各路神犇怒踩成rank20,差点200点头盾不保的落魄,想起将近一年前ad和zcg等学长挤进rank10的壮举,不由得唏嘘, ...
- 树莓派搭建web服务器(详细且良心)
安装Apache Apache服务器可以从Debian的源中下载.可以用apt下载. 首先要更新apt的软件列表.如果不运行sudo apt-get updata的话,apt软件就不知道有没有新的软件 ...
- 第三次Scrum
1.小组成员 周 斌舒 溢许嘉荣唐 浩黄欣欣廖帅元刘洋江薛思汝 2.小组第三次冲刺完成情况 github仓库小组的第三次任务是完成体系结构环境图和系统原型图.在体系结构设计中,分为上级系统----把目 ...
- *p++、*++p、(*p)++区别
关于数组指针的谜题 假设 p 是指向数组 arr 中第 n 个元素的指针,那么 *p++.*++p.(*p)++ 分别是什么意思呢? *p++ 等价于 *(p++),表示先取得第 n 个元素的值,再将 ...
- SQL Server ->> FileTable
FileTable是SQL Server 2012的新特性之一.它是基于SQL Server 2008的FILESTREAM特性上而来的,允许我们把Windows文件存储在SQL Server中,让S ...
- Best Time to Buy and Sell Stock II--疑惑
https://oj.leetcode.com/problems/best-time-to-buy-and-sell-stock-ii/ 代码如下时能AC class Solution { publi ...
- tpcc-mysql安装测试与使用生成对比图
1:下载tpcc-mysql的压缩包,从下面的网站进行下载 https://github.com/Percona-Lab/tpcc-mysql 也可直接从叶总博客直接下载: http://imysql ...
- DevExpress源码编译总结 z
本篇文章内容包括基础知识(GAC.程序集强签名.友元程序集).编译过程.注册GAC.添加工具箱.多语言支持.运行时和设计时调试 源码地址 链接:http://pan.baidu.com/s/1eQm1 ...
- yii2框架安装运行init.bat报错php.exe不是内部或外部命令
在安装yii2框架的时候,遇到一个很纠结的问题.就是当我把安装包下载下来之后,在公司的电脑安装可以正常,当我回家用自己的电脑安装就报错,提示 php.exe 不是内部或外部命令,也不是可运行的程序.这 ...