【故障处理】-OGG 丢失归档20190717
2019-07-17 19:17 那个,我 阅读(960) 评论(0) 编辑 收藏 举报再次遇到OGG 异常:
归档丢失,OGG 不能找到需要的归档文件.
该表完整expdp 导出评估为 110G,了解到只有插入操作,所以只把归档丢失期间的数据补到目标端就好。
1. 清理目标端 2019/07/11 18:00 之后数据
--目标端
SQL>
select count(1) from table1 where GEN_TIME>=to_date('20190711 18:00:00','YYYYMMDD HH24:MI:SS');
delete from table1 where GEN_TIME>=to_date('20190711 18:00:00','YYYYMMDD HH24:MI:SS');
COMMIT;
2. 完成2019/07/11 18:00 之后数据的补充
查询SCN
select to_char(current_scn) from v$database; --16253916840
导出数据
DATE=`date +'%Y%m%d'`
expdp userid=source/pass directory=expdir tables=table1 QUERY=table1:\"where GEN_TIME\>=to_date\(\'20190711 18:00:00\',\'YYYYMMDD HH24:MI:SS\'\)\" filesize=10G dumpfile=initogg$DATE%U.dmp logfile=initogg$DATE.log cluster=n FLASHBACK_SCN=16253916840SCP 到目标端
scp initogg$DATE*.dmp ogg@target:/expdir
目标端导入
DATE=`date +'%Y%m%d'`
impdp target/pass directory=expdir remap_schema=source:target dumpfile=initogg$DATE%U.dmp logfile=impdp_initogg$DATE.log table_exists_action=append验证数据
--source
select count(1) from table1 as of scn 16253916840;
--target
select count(1) from table1;数据一致,该SCN后的数据通过OGG同步即可。
3. Source 端OGG 进程处理
Extract 进程处理
GGSCI> ALTER EXTRACT EXT1 ,ETROLLOVER
GGSCI> info exttrail *
Extract Trail: /ogg/dirdat/ra
Extract: DP1
Seqno: 2900
RBA: 15694
File Size: 100M
Extract Trail: ./dirdat/la
Extract: EXT1
Seqno: 2911 #注意这里新的Seqno 和 RBA
RBA: 0 #下面Dump进程用到
File Size: 100M
#9点到现在归档是连续的,从今天9点的归档开始抽取,前面丢失的不再需要
GGSCI> ALTER EXTRACT EXT1 ,BEGIN 09:00
GGSCI> START EXT1
GGSCI> INFO EXTTRAIL *
Extract Trail: /ogg/dirdat/ra
Extract: DP1
Seqno: 2900
RBA: 15694
File Size: 100M
Extract Trail: ./dirdat/la
Extract: EXT1
Seqno: 2911
RBA: 19070157 #RBA变更,已有数据被抽取到trail文件
File Size: 100MDB 进程处理
GGSCI> info DP1
EXTRACT DP1 Last Started 2019-07-13 14:57 Status STOPPED
Checkpoint Lag 00:00:00 (updated 17:00:23 ago)
Log Read Checkpoint File ./dirdat/la002910 #使用的旧的trail文件
2019-07-11 20:39:24.000000 RBA 31497286
GGSCI> ALTER EXTRACT DP1, EXTSEQNO 2911, EXTRBA 0 #切换到Extract使用的新文件
GGSCI> info DP1
EXTRACT DP1 Initialized 2019-07-17 11:11 Status STOPPED
Checkpoint Lag 00:00:00 (updated 00:00:06 ago)
Log Read Checkpoint File ./dirdat/la002911
First Record RBA 0
#启动Dump进程
GGSCI> START DP1
GGSCI> INFO DP1
EXTRACT DP1 Last Started 2019-07-17 11:12 Status RUNNING
Checkpoint Lag 00:00:00 (updated 00:00:08 ago)
Log Read Checkpoint File ./dirdat/la002911
2019-07-17 11:12:50.000000 RBA 19537151 #需等一会儿才有变化
GGSCI> INFO EXTTRAIL *
Extract Trail: /ogg/dirdat/ra
Extract: DP1
Seqno: 2901 #Dump进程启动后自动切换了远端trail文件
RBA: 19581384
File Size: 100M
Extract Trail: ./dirdat/la
Extract: EXT1
Seqno: 2911
RBA: 19601526
File Size: 100M查看Source 端状态都已正常
GGSCI> INFO ALL #相关进程都处于Running 状态,且无延迟
4. Target 端OGG 进程处理
基于SCN 启动Replicat 进程
GGSCI> info RP1
REPLICAT RP1 Last Started 2019-07-12 06:00 Status STOPPED
Checkpoint Lag 00:00:00 (updated 17:03:31 ago)
Log Read Checkpoint File ./dirdat/ra002900 #当前还在使用2900
2019-07-11 20:39:24.096454 RBA 15694
#从指定SCN 开始应用
GGSCI> START REPLICAT RP1, ATCSN 16253916840
GGSCI> info RP1
REPLICAT RP1 Last Started 2019-07-17 11:15 Status RUNNING
Checkpoint Lag 00:00:00 (updated 00:00:01 ago)
Log Read Checkpoint File ./dirdat/ra002901 #已经自动切换到了2901
2019-07-17 11:15:20.967710 RBA 19923873
Replicat 在2900没找到需要的SCN,在2901里才能找到,所以自动完成了切换
5. 数据验证
--source
select count(1) from table1;
--target
select count(1) from table1;
学习如茶,需细细品味。