OGG 單表初始化操做步驟

 

有時候ogg兩端數據不一致,且數據量較大,手工修改比較複雜的狀況下,咱們須要對這些表進行初始化。初始化的大概思路是: oracle

1. 中止兩端OGG app

2. 若是業務不能夠停很長時間,就須要配置目標端進程,暫停這些問題表的同步。待新數據導入後,再次停啓進程 進程

3. 源端經過SCN號備份問題表,傳送到目標端還原 get

4. 修改目標端進程配置,從SCN開始恢復 同步

5. 開啓OGG進程 flash

源端簡陋配置: it

GGSCI (db1) 9> info all io

Program Status Group Lag at Chkpt Time Since Chkpt table

MANAGER RUNNING 配置

EXTRACT RUNNING EXTFPZX 00:00:00 00:00:05

GGSCI (db1) 10> view params EXTFPZX

extract extfpzx

userid ogg,password ogg

rmthost 192.168.25.101,mgrport 7809

rmttrail /u01/goldengate/dirdat/fp

ddl include mapped objname db_fpzx.*;

table db_fpzx.*;

目標端簡陋配置:

GGSCI (db2) 6> info all

Program Status Group Lag at Chkpt Time Since Chkpt

MANAGER RUNNING

REPLICAT RUNNING REPFPZX 00:00:00 00:00:01

GGSCI (db2) 7> view params REPFPZX

REPLICAT repfpzx

USERID ogg,PASSWORD ogg

discardfile /u01/goldengate/discard/rep2_discard.dsc, append, megabytes 10

DDL INCLUDE MAPPED

DDLERROR DEFAULT IGNORE RETRYOP

ASSUMETARGETDEFS

map db_fpzx.*, target db_fpzx.*;

咱們對」liuliu」這張表進行初始化

SQL> select * from liuliu;

ID AGE NAME EEE WWW

---------- ---------- -------------------- -------------------- --------------------

2 liu liuliu222

3 liu 123 liuliu333

4 liu liuliu444

5 liu liuliu555

6 liu liuliu666

1 liu liuliu222

7 liu liuliu222

8 shshshs liuliu222

9 liu liuliu222

9 rows selected.

咱們將目標端中的數據刪除,再在源端插入幾條數據,是不會報錯的,可是此時兩端數據已經不一致了,須要對目標端進行初始化。通常來講初始化是在你不知道丟失哪些數據的狀況下進行,若是差個兩三條你知道的數據,直接在目標端進行插入或修改更快。

SQL> delete from liuliu;

9 rows deleted.

SQL> commit;

Commit complete.

SQL> select * from liuliu;

no rows selected

1、中止兩端OGG進程

源端查詢SCN號:

SQL> select dbms_flashback.get_system_change_number from dual;

GET_SYSTEM_CHANGE_NUMBER

------------------------

729295

2、源端經過SCN號備份問題表,傳送到目標端還原

l 備份

exp db_fpzx/fpzx file=/u01/backup/db_fpzx20161129.dmp tables=(liuliu) log=/u01/backup/db_fpzx20161129.log flashback_scn=729295

l 傳輸

scp db_fpzx20161129.dmp oracle@192.168.25.101:/u01/backup

l 還原

imp system/oracle file=/u01/backup/db_fpzx20161129.dmp fromuser=db_fpzx touser=db_fpzx tables=liuliu ignore=y

3、修改目標端進程配置,從SCN開始還原

GGSCI (db2) 44> edit params REPFPZX

REPLICAT repfpzx

USERID ogg,PASSWORD ogg

discardfile /u01/goldengate/discard/rep2_discard.dsc, append, megabytes 10

DDL INCLUDE MAPPED

DDLERROR DEFAULT IGNORE RETRYOP

ASSUMETARGETDEFS

map db_fpzx.liuliu, target db_fpzx.liuliu, filter (@GETENV("transaction","csn") >729295);

map db_fpzx.*,target db_fpzx.*;

~

~4、啓動OGG,查詢兩端狀態

相關文章
相關標籤/搜索