检查数据库服务器,发现磁盘已满,因为前期规划问题,磁盘空间不足,还好该库不影响。
删除归档时,发现删除过多,导致备库归档没有成功应用,就被删除了。
这个操作确实粗心大意,检查备库归档时,发现无法应用,查看日志有如下报错:
Fetching gap sequence in thread 1, gap sequence 42102-42102 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. ------------------------------------------------------------
处理方法,在主库查看该归档的SCN发生的序列:
SQL> col first_change# for 999999999999999 SQL> select first_change# from v$archived_log where sequence#='42102' 2 ; FIRST_CHANGE# ---------------- 11769444390910 主库 SQL> alter system set log_archive_dest_state_2=defer; 备库 SQL> alter database managed standby database recovery cancel;
对主库进行增量和控制文件备份:
RMAN> backup incremental from scn 11769444390910 database format '/u01/temp/archivedlog_%U'; RMAN> backup current controlfile for standby format '/u01/temp/controlfile.bak';
将文件拷贝到备库后,进行还原
RMAN> shutdown immediate RMAN> startup nomount RMAN> restore standby controlfile from '/u01/temp/controlfile.bak'; RMAN> alter database mount; RMAN> recover database noredo;
另外如果未采用的standby log模式,则需要清空备库redo log,有几组清理几组。
SQL> alter database clear logfile group 1;
切换主库日志文件观察主备库日志序列是否一致!
主库: SQL> alter system switch logfile; SQL> select max(sequence#) from v$log_history; MAX(SEQUENCE#) -------------- 42141 备库: SQL> select max(sequence#) from v$log_history; MAX(SEQUENCE#) -------------- 42141
恢复归档应用
主库 SQL> alter system set log_archive_dest_state_2=enable; 备库 SQL> alter database managed standby database recovery disconnect from session;
关注以下几个视图:
v$managed_standby SQL> select process,status,sequence# from v$managed_standby; v$archive_dest_status SQL> col dest_name for a25 SQL> select dest_name,status,recovery_mode from v$archive_dest_status;
启动时观察alert日志发现如下内容
Wed Sep 30 14:27:09 2015
Managed Standby Recovery not using Real Time Apply
表示归档没有实时同步,检查发现备库监听未开启
$ tnsping sss_dg TNS Ping Utility for Linux: Version 11.2.0.3.0 - Production on 30-SEP-2015 14:27:42 Copyright (c) 1997, 2011, Oracle. All rights reserved. Used parameter files: Used TNSNAMES adapter to resolve the alias Attempting to contact (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=x.x.x.x)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=sss))) TNS-12541: TNS:no listene
参考:
http://www.xifenfei.com/2011/07/data-guard%e5%87%ba%e7%8e%b0gap-sequence%e4%bf%ae%e5%a4%8d.html