dataguard 归档丢失(主库中无此丢失归档处理),备库基于SCN恢复
环境:
OS: CentOS 6.5
DB: Oracle 10.2.0.5 1.主备库环境
主库:
SQL> select dbid,name,LOG_MODE,open_mode,db_unique_name,DATABASE_ROLE,PROTECTION_MODE from v$database; DBID NAME LOG_MODE OPEN_MODE DB_UNIQUE_NAME DATABASE_ROLE PROTECTION_MODE
---------- --------- ------------ ---------- -------------------- ---------------- --------------------
351758316 NETDATA ARCHIVELOG READ WRITE netdata_pd PRIMARY MAXIMUM PERFORMANCE SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /u01/app/oracle/archive/netdata
Oldest online log sequence 65
Next log sequence to archive 67
Current log sequence 67
SQL> 备库:
SQL> select dbid,name,LOG_MODE,open_mode,db_unique_name,DATABASE_ROLE,PROTECTION_MODE from v$database; DBID NAME LOG_MODE OPEN_MODE DB_UNIQUE_ DATABASE_ROLE PROTECTION_MODE
---------- ---------- ------------ ---------- ---------- ---------------- --------------------
351758316 NETDATA ARCHIVELOG MOUNTED netdata_sd PHYSICAL STANDBY MAXIMUM PERFORMANCE SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /u01/app/oracle/archive/netdata
Oldest online log sequence 63
Next log sequence to archive 0
Current log sequence 67
SQL> 2.模拟归档丢失
备库操作:
备库取消归档应用
SQL> ALTER DATABASE recover managed standby DATABASE cancel; Database altered. 备库以只读模式打开
SQL> alter database open read only; Database altered. SQL>
这张表是我建的测试表,用一个job跑的插入数据(每隔3S插入一条
SQL> select count(*) from hr.test; COUNT(*)
----------
28501 SQL> 主库操作:
SQL> select count(*) from hr.test; COUNT(*)
----------
31143 SQL>
可以看到记录数不一致,这是因为归还没有传输过来 主备归档情况
主库操作
SQL> set line 200
SQL> set pagesize 200
SQL> col name format A50
SQL> select name,SEQUENCE#,APPLIED from v$archived_log where dest_id=1; /u01/app/oracle/archive/netdata/1_52_857898543.arc 52 NO
/u01/app/oracle/archive/netdata/1_53_857898543.arc 53 NO
/u01/app/oracle/archive/netdata/1_54_857898543.arc 54 NO
/u01/app/oracle/archive/netdata/1_55_857898543.arc 55 NO
/u01/app/oracle/archive/netdata/1_56_857898543.arc 56 NO
/u01/app/oracle/archive/netdata/1_57_857898543.arc 57 NO
/u01/app/oracle/archive/netdata/1_58_857898543.arc 58 NO
/u01/app/oracle/archive/netdata/1_59_857898543.arc 59 NO
/u01/app/oracle/archive/netdata/1_60_857898543.arc 60 NO
/u01/app/oracle/archive/netdata/1_61_857898543.arc 61 NO
/u01/app/oracle/archive/netdata/1_62_857898543.arc 62 NO
/u01/app/oracle/archive/netdata/1_63_857898543.arc 63 NO
/u01/app/oracle/archive/netdata/1_64_857898543.arc 64 NO
/u01/app/oracle/archive/netdata/1_65_857898543.arc 65 NO
/u01/app/oracle/archive/netdata/1_66_857898543.arc 66 NO 64 rows selected.
SQL> select * from v$log; GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIM
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------
12 1 65 104857600 2 YES INACTIVE 715138 13-SEP-14
13 1 66 104857600 2 YES INACTIVE 715158 13-SEP-14
14 1 67 104857600 2 NO CURRENT 715164 13-SEP-14 SQL> 备库操作
SQL> set line 200
SQL> set pagesize 200
SQL> col name format A50
SQL> select name,SEQUENCE#,APPLIED from v$archived_log where dest_id=1; NAME SEQUENCE# APP
-------------------------------------------------- ---------- ---
/u01/app/oracle/archive/netdata/1_64_857898543.arc 64 YES
/u01/app/oracle/archive/netdata/1_65_857898543.arc 65 YES
/u01/app/oracle/archive/netdata/1_66_857898543.arc 66 YES
/u01/app/oracle/archive/netdata/1_63_857898543.arc 63 YES SQL> select * from v$Log; GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIM
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------
12 1 65 104857600 2 YES CLEARING 715138 13-SEP-14
13 1 63 104857600 2 YES CLEARING 714611 13-SEP-14
14 1 67 104857600 2 YES CLEARING_CURRENT 715164 13-SEP-14 主库操作
SQL> ALTER system SET log_archive_dest_state_2 = 'defer'; System altered. SQL> SQL> alter system archive log current; System altered. SQL> alter system archive log current; System altered. SQL> alter system archive log current; System altered. SQL> alter system archive log current; System altered. SQL> alter system archive log current; System altered. SQL> 删除归档
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /u01/app/oracle/archive/netdata
Oldest online log sequence 70
Next log sequence to archive 72
Current log sequence 72
SQL> 删除归档
[oracle@oracle10g-dg1-213-100 netdata]$ rm -rvf 1\_7*
已删除"1_70_857898543.arc"
已删除"1_71_857898543.arc"
已删除"1_7_857893401.dbf"
主库开启备库归档
SQL> ALTER system SET log_archive_dest_state_2 = 'enable'; 备库重新开启应用
SQL> ALTER DATABASE recover managed standby DATABASE disconnect FROM SESSION; Database altered. SQL>
System altered. SQL> 查询备库alert.log
Waiting for all non-current ORLs to be archived...
Media Recovery Waiting for thread 1 sequence 67
Fetching gap sequence in thread 1, gap sequence 67-70
Sat Sep 13 21:00:27 CST 2014
Completed: ALTER DATABASE recover managed standby DATABASE disconnect FROM SESSION
Sat Sep 13 21:00:57 CST 2014
FAL[client]: Failed to request gap sequence
GAP - thread 1 sequence 67-70
DBID 351758316 branch 857898543
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 is sufficiently large
enough to maintain adequate log switch information to resolve
archivelog gaps.
------------------------------------------------------------- 有gap产生了 备库查询
select name,sequence#,applied from v$archived_log a where a.sequence#=(select max(sequence#) from v$archived_log); NAME SEQUENCE# APP
-------------------------------------------------- ---------- ---
/u01/app/oracle/archive/netdata/1_66_857898543.arc 66 YES 主库查询
SQL> SELECT SEQUENCE#,FIRST_CHANGE#,NEXT_CHANGE# FROM v$archived_log WHERE SEQUENCE# > 67 ORDER BY 1; SEQUENCE# FIRST_CHANGE# NEXT_CHANGE#
---------- ------------- ------------
68 745961 745971
69 745971 745984
70 745984 745988
71 745988 746005 SQL> 主库
基于SCN增量备份
RMAN> backup device type disk incremental from scn 715164 database format '/u01/backup/netdata_incre%U.bbk'; Starting backup at 13-SEP-14
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/u01/app/oracle/oradata/netdata/system01.dbf
input datafile fno=00003 name=/u01/app/oracle/oradata/netdata/sysaux01.dbf
input datafile fno=00005 name=/u01/app/oracle/oradata/netdata/example01.dbf
input datafile fno=00006 name=/u01/app/oracle/oradata/netdata/HTSDK_01.dbf
input datafile fno=00007 name=/u01/app/oracle/oradata/netdata/HTSDK_INDEX_01.dbf
input datafile fno=00002 name=/u01/app/oracle/oradata/netdata/undotbs01.dbf
input datafile fno=00004 name=/u01/app/oracle/oradata/netdata/users01.dbf
channel ORA_DISK_1: starting piece 1 at 13-SEP-14
channel ORA_DISK_1: finished piece 1 at 13-SEP-14
piece handle=/u01/backup/netdata_incre0jpie810_1_1.bbk tag=TAG20140913T212904 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:18
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 13-SEP-14
channel ORA_DISK_1: finished piece 1 at 13-SEP-14
piece handle=/u01/backup/netdata_incre0kpie83e_1_1.bbk tag=TAG20140913T212904 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:04
Finished backup at 13-SEP-14 RMAN> 主库重新生成控制文件 SQL> ALTER DATABASE CREATE standby controlfile AS '/u01/backup/standby.ctl'; Database altered. 拷贝文件至备库
[oracle@oracle10g-dg1-213-100 backup]$ scp * oracle@192.168.213.101:/u01/backup/
oracle@192.168.213.101's password:
netdata_incre0jpie810_1_1.bbk 100% 17MB 8.5MB/s 00:02
netdata_incre0kpie83e_1_1.bbk 100% 7200KB 7.0MB/s 00:01
standby.ctl 100% 7120KB 7.0MB/s 00:01 备库操作
SQL> shutdown immediate;
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SQL> startup nomount;
ORACLE instance started. Total System Global Area 704643072 bytes
Fixed Size 2098912 bytes
Variable Size 192940320 bytes
Database Buffers 503316480 bytes
Redo Buffers 6287360 bytes
SQL> quit 恢复控制文件
RMAN> restore controlfile from '/u01/backup/standby.ctl'; Starting restore at 13-SEP-14
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=541 devtype=DISK channel ORA_DISK_1: copied control file copy
output filename=/u01/app/oracle/oradata/netdata/control01.ctl
output filename=/u01/app/oracle/oradata/netdata/control02.ctl
output filename=/u01/app/oracle/oradata/netdata/control03.ctl
Finished restore at 13-SEP-14 RMAN> RMAN> catalog start with '/u01/backup'
2> ; searching for all files that match the pattern /u01/backup List of Files Unknown to the Database
=====================================
File Name: /u01/backup/netdata_incre0jpie810_1_1.bbk
File Name: /u01/backup/standby.ctl
File Name: /u01/backup/control01.ctl
File Name: /u01/backup/netdata_incre0kpie83e_1_1.bbk Do you really want to catalog the above files (enter YES or NO)? yes
cataloging files...
cataloging done List of Cataloged Files
=======================
File Name: /u01/backup/netdata_incre0jpie810_1_1.bbk
File Name: /u01/backup/standby.ctl
File Name: /u01/backup/control01.ctl
File Name: /u01/backup/netdata_incre0kpie83e_1_1.bbk RMAN> recover DATABASE noredo; Starting recover at 13-SEP-14
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00001: /u01/app/oracle/oradata/netdata/system01.dbf
destination for restore of datafile 00002: /u01/app/oracle/oradata/netdata/undotbs01.dbf
destination for restore of datafile 00003: /u01/app/oracle/oradata/netdata/sysaux01.dbf
destination for restore of datafile 00004: /u01/app/oracle/oradata/netdata/users01.dbf
destination for restore of datafile 00005: /u01/app/oracle/oradata/netdata/example01.dbf
destination for restore of datafile 00006: /u01/app/oracle/oradata/netdata/HTSDK_01.dbf
destination for restore of datafile 00007: /u01/app/oracle/oradata/netdata/HTSDK_INDEX_01.dbf
channel ORA_DISK_1: reading from backup piece /u01/backup/netdata_incre0jpie810_1_1.bbk
channel ORA_DISK_1: restored backup piece 1
piece handle=/u01/backup/netdata_incre0jpie810_1_1.bbk tag=TAG20140913T212904
channel ORA_DISK_1: restore complete, elapsed time: 00:00:04 Finished recover at 13-SEP-14 RMAN> 查询alert 日志
Sat Sep 13 22:04:34 CST 2014
RFS LogMiner: Client disabled from further notification
Sat Sep 13 22:04:54 CST 2014
Incremental restore complete of datafile 4 /u01/app/oracle/oradata/netdata/users01.dbf
checkpoint is 753898
Incremental restore complete of datafile 2 /u01/app/oracle/oradata/netdata/undotbs01.dbf
checkpoint is 753898
last deallocation scn is 669702
Incremental restore complete of datafile 5 /u01/app/oracle/oradata/netdata/example01.dbf
checkpoint is 753898
last deallocation scn is 399417
Incremental restore complete of datafile 6 /u01/app/oracle/oradata/netdata/HTSDK_01.dbf
checkpoint is 753898
Incremental restore complete of datafile 7 /u01/app/oracle/oradata/netdata/HTSDK_INDEX_01.dbf
checkpoint is 753898
Incremental restore complete of datafile 3 /u01/app/oracle/oradata/netdata/sysaux01.dbf
checkpoint is 753898
last deallocation scn is 421688
Incremental restore complete of datafile 1 /u01/app/oracle/oradata/netdata/system01.dbf
checkpoint is 753898
last deallocation scn is 472342 备库重新应用
SQL> ALTER DATABASE recover managed standby DATABASE disconnect FROM SESSION; Database altered. SQL> 测试归档是否
SQL> alter system switch logfile; System altered. SQL> 查询主备
备库操作 archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /u01/app/oracle/archive/netdata
Oldest online log sequence 71
Next log sequence to archive 0
Current log sequence 73
col name format A50;
col dest_name format A40
col error format A20
set line 200;
select name,sequence#,applied from v$archived_log a where a.sequence#=(select max(sequence#) from v$archived_log); NAME SEQUENCE# APP
-------------------------------------------------- ---------- ---
/u01/app/oracle/archive/netdata/1_72_857898543.arc 72 YES col dest_name format A40
SQL> select dest_name,status,error from v$archive_dest where rownum<3; DEST_NAME STATUS ERROR
---------------------------------------- --------- --------------------
LOG_ARCHIVE_DEST_1 VALID
LOG_ARCHIVE_DEST_2 VALID SQL> 主库操作 archive log list;
col name format A50;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /u01/app/oracle/archive/netdata
Oldest online log sequence 71
Next log sequence to archive 73
Current log sequence 73
col dest_name format A40
col error format A20
set line 200;
select name,sequence#,applied from v$archived_log a where a.sequence#=(select max(sequence#) from v$archived_log); NAME SEQUENCE# APP
-------------------------------------------------- ---------- ---
/u01/app/oracle/archive/netdata/1_72_857898543.arc 72 NO
netdata_sd 72 YES col dest_name format A40
SQL> select dest_name,status,error from v$archive_dest where rownum<3; DEST_NAME STATUS ERROR
---------------------------------------- --------- --------------------
LOG_ARCHIVE_DEST_1 VALID
LOG_ARCHIVE_DEST_2 VALID SQL>

dataguard 归档丢失(主库中无此丢失归档处理),备库基于SCN恢复的更多相关文章

  1. Spring Boot中自定义注解+AOP实现主备库切换

    摘要: 本篇文章的场景是做调度中心和监控中心时的需求,后端使用TDDL实现分表分库,需求:实现关键业务的查询监控,当用Mybatis查询数据时需要从主库切换到备库或者直接连到备库上查询,从而减小主库的 ...

  2. DataGuard切换(主库为Rac+备库为Rac)

    http://blog.itpub.net/29477587/viewspace-1331121/ 前段时间做了一次主备库的切换,大体写下操作步骤和记录,分享下. 环境:           db v ...

  3. 主备归档不一致导致的RMAN-08137无法清理归档解决方案

    值班夜里接到归档目录满的告警,执行删除脚本发现报错 RMAN-08137: WARNING: archived log not deleted, needed for standby or upstr ...

  4. DG备库磁盘空间满导致无法创建归档

    上周五去某客户那里做数据库巡检.是window 2008系统上10g的一套NC系统的库,已经配置了DG,可是巡检时发现数据库报错: Tue Nov 11 10:13:57 2014 LNS: Stan ...

  5. Oracle数据库由dataguard备库引起的log file sync等待

    导读: 最近数据库经常出现会话阻塞的报警,过一会又会自动消失,昨天晚上恰好发生了一次,于是赶紧进行了查看,不看不知道,一看吓一跳,发现是由dataguard引起的log file sync等待.我们知 ...

  6. 模拟主库创建数据文件,dg备库空间不足时问题处理

    本篇文档测试目的: 模拟实际环境中,主库对表空间添加数据文件,备库空间不足,最终导致MRP进程自动断开,处理方式. 1.问题环境模拟 1)正常情况下的dg 主库创建数据文件,备库接受日志,自动创建表空 ...

  7. Oracle主库归档丢失,备库日志有gap,在不重建备库的情况下,恢复备库

    本文主要描述Oracle备库日志与主库日志之间有gap,切主库这部分gap的归档日志已经删除或丢失,如何在不重建备库的情况下,恢复备库. 欢迎转载,请注明作者.出处. 作者:张正 blog:http: ...

  8. RMAN数据库恢复 之归档模式有(无)备份-丢失数据文件的恢复

    1.归档模式有备份,丢失数据文件的恢复归档模式有备份,不管丢失什么数据文件,直接在RMAN下RESTOER--->RECOVER--->OPEN即可. RMAN> STARUP MO ...

  9. Kafka设计解析(十一)Kafka无消息丢失配置

    转载自 huxihx,原文链接 Kafka无消息丢失配置 目录 一.Producer端二.Consumer端 Kafka到底会不会丢数据(data loss)? 通常不会,但有些情况下的确有可能会发生 ...

随机推荐

  1. [vijos P1180] 选课

    这一周竟然都没好好码题目,不过至少把这题的树形DP给摸了个大概.吐槽一下自己,递归已经基本不会用了…QAQ!按老师的话来说“太危险了!” 此题用到多叉树转二叉树,左孩子是真正意义的孩子(先修完自己才能 ...

  2. linux kernel 如何处理大小端

    暂时在用MPC8309,不太清楚大小端内核是什么时候给转的. 今天看了关于readl和writel具体实现的文章 今天就主要来分析下readl/writel如何实现高效的数据swap和寄存器读写.我们 ...

  3. Sql 注意点

    1. Set.Select赋值 使用SELECT语句来替代SET命令的主要优点是:可以在一个操作内同时给多个变量赋值.执行下面的SELECT语句,通过SELECT语句赋值的变量就可以用于任何操作了. ...

  4. Android SQLiteOpenHelper(一)

    SQLiteOpenHelper api解释: A helper class to manage database creation and version management. You creat ...

  5. SVG 2D入门11 - 动画

    交互性      SVG拥有良好的用户交互性,例如:1. SVG能响应大部分的DOM2事件.2. SVG能通过cursor良好的捕捉用户鼠标的移动.3. 用户可以很方便的通过设置svg元素的zoomA ...

  6. ffmepg-nginx-nginx-rtmp-module配置脚本

    把上个月写的的配置脚本贴一下: #!/bin/bash #version:-- #create by itn #dis: this is used to auto install ffmpeg+ngi ...

  7. IOS网络开发(一)

    1 简易的聊天工具 1.1 问题 Socket的英文原义是孔或者插座的意思,通常也称作套接字,用于描述IP地址和端口,是一个通信链的句柄,本案例使用第三方Socket编程框架AsyncSocket框架 ...

  8. IT行业的正式入门

    虽然我是计算机专业毕业的大学生,但我自己认为我连什么是 IT都不了解,我热爱Java程序的设计,所以我现在在努力学习,今天是上Java程序设计的第一天,我正式进入IT业,踏上了这条“不归路”.figh ...

  9. windbg

    1, symbols  : srv*c:\symbols*http://msdl.microsoft.com/download/symbols 2,.loadby sos mscorwks  or   ...

  10. 存储OS

    openfiler这个登陆慢 是https协议的问题 http://www.getnas.com/open-source-nas FreeNAS®,目前最受欢迎的开源免费 NAS 操作系统之一,基于以 ...