OGG 指定时间点重新抽取

1. GoldenGate 指定时间点重新抽取

1.1. 查看源端当前的SCN,记录该值作为重新抽取的时间点

SQL>  select dbms_flashback.get_system_change_number from dual;

GET_SYSTEM_CHANGE_NUMBER
------------------------
   1497417

1.2. 查看当前抽取进程ext1的状态

GGSCI (cndba) 16> info ext1 detail

EXTRACT    EXT1      Last Started 2018-06-18 11:38   Status RUNNING
Checkpoint Lag       00:00:00 (updated 00:00:10 ago)
Log Read Checkpoint  Oracle Redo Logs
                     2018-06-18 12:09:23  Thread 1, Seqno 59, RBA 1452032
                     SCN 0.1497446 (1497446)

  Target Extract Trails:

  Remote Trail Name                                Seqno        RBA     Max MB

  ./dirdat/et                                          2       1075        100

  Extract Source                          Begin             End             

  /u01/app/oracle/oradata/cndba/redo02.log  2018-06-17 23:58  2018-06-18 12:09
  /u01/app/oracle/oradata/cndba/redo01.log  2018-06-17 23:08  2018-06-17 23:58
  /u01/app/oracle/oradata/cndba/redo01.log  2018-06-17 22:45  2018-06-17 23:08
  Not Available                           * Initialized *   2018-06-17 22:45
  /u01/app/oracle/oradata/cndba/redo01.log  * Initialized *   2018-06-17 22:30
  /u01/app/oracle/oradata/cndba/redo03.log  2018-06-17 19:51  2018-06-17 21:06
  /u01/app/oracle/oradata/cndba/redo03.log  * Initialized *   2018-06-17 19:51
  /u01/app/oracle/oradata/cndba/redo03.log  * Initialized *   2018-06-17 19:47
  /u01/app/oracle/oradata/cndba/redo03.log  2018-06-17 19:47  2018-06-17 19:47
  /u01/app/oracle/oradata/cndba/redo03.log  * Initialized *   2018-06-17 19:47
  /u01/app/oracle/oradata/cndba/redo03.log  2018-06-17 16:46  2018-06-17 16:47
  /u01/app/oracle/oradata/cndba/redo03.log  2018-06-17 16:39  2018-06-17 16:46
  /u01/app/oracle/oradata/cndba/redo03.log  * Initialized *   2018-06-17 16:39
  /u01/app/oracle/oradata/cndba/redo03.log  2018-06-17 16:37  2018-06-17 16:39
  /u01/app/oracle/oradata/cndba/redo03.log  * Initialized *   2018-06-17 16:37
  /u01/app/oracle/oradata/cndba/redo03.log  * Initialized *   2018-06-17 16:37
  /u01/app/oracle/oradata/cndba/redo03.log  2018-06-13 15:00  2018-06-17 16:37
  /u01/app/oracle/oradata/cndba/redo01.log  2018-06-12 18:53  2018-06-13 15:00
  /u01/app/oracle/oradata/cndba/redo03.log  2018-06-12 17:26  2018-06-12 18:53
  /u01/app/oracle/oradata/cndba/redo03.log  2018-06-12 13:38  2018-06-12 17:26
  /u01/app/oracle/oradata/cndba/redo03.log  2018-06-12 11:08  2018-06-12 13:38
  /u01/app/oracle/oradata/cndba/redo03.log  2018-06-12 09:54  2018-06-12 11:08
  /u01/app/oracle/oradata/cndba/redo03.log  2018-06-12 01:07  2018-06-12 09:54
  /u01/app/oracle/oradata/cndba/redo02.log  2018-06-11 21:54  2018-06-12 01:07
  /u01/app/oracle/oradata/cndba/redo02.log  * Initialized *   2018-06-11 21:54
  /u01/app/oracle/oradata/cndba/redo01.log  2018-06-11 18:46  2018-06-11 18:58
  /u01/app/oracle/oradata/cndba/redo01.log  * Initialized *   2018-06-11 18:46
  /u01/app/oracle/oradata/cndba/redo01.log  2018-06-11 18:36  2018-06-11 18:39
  /u01/app/oracle/oradata/cndba/redo01.log  * Initialized *   2018-06-11 18:36
  /u01/app/oracle/oradata/cndba/redo01.log  2018-06-11 18:34  2018-06-11 18:36
  /u01/app/oracle/oradata/cndba/redo01.log  * Initialized *   2018-06-11 18:34
  /u01/app/oracle/oradata/cndba/redo01.log  2018-06-11 18:30  2018-06-11 18:34
  /u01/app/oracle/oradata/cndba/redo01.log  * Initialized *   2018-06-11 18:30
  /u01/app/oracle/oradata/cndba/redo01.log  2018-06-11 18:27  2018-06-11 18:30
  /u01/app/oracle/oradata/cndba/redo01.log  * Initialized *   2018-06-11 18:27
  /u01/app/oracle/oradata/cndba/redo01.log  2018-06-11 18:25  2018-06-11 18:27
  /u01/app/oracle/oradata/cndba/redo01.log  * Initialized *   2018-06-11 18:25
  /u01/app/oracle/oradata/cndba/redo01.log  2018-06-11 17:19  2018-06-11 18:25
  /u01/app/oracle/oradata/cndba/redo03.log  2018-06-11 17:19  2018-06-11 17:19
  /u01/app/oracle/oradata/cndba/redo03.log  * Initialized *   2018-06-11 17:19
  /u01/app/oracle/oradata/cndba/redo03.log  2018-06-11 17:19  2018-06-11 17:19
  /u01/app/oracle/oradata/cndba/redo03.log  2018-06-11 17:19  2018-06-11 17:19
  /u01/app/oracle/oradata/cndba/redo03.log  2018-06-11 17:19  2018-06-11 17:19
  /u01/app/oracle/oradata/cndba/redo03.log  2018-06-11 17:19  2018-06-11 17:19
  /u01/app/oracle/oradata/cndba/redo03.log  2018-06-11 17:19  2018-06-11 17:19
  /u01/app/oracle/oradata/cndba/redo03.log  2018-06-11 17:19  2018-06-11 17:19
  /u01/app/oracle/oradata/cndba/redo03.log  2018-06-11 17:06  2018-06-11 17:19
  /u01/app/oracle/oradata/cndba/redo03.log  * Initialized *   2018-06-11 17:06
  /u01/app/oracle/oradata/cndba/redo02.log  2018-06-11 14:32  2018-06-11 14:49
  /u01/app/oracle/oradata/cndba/redo02.log  * Initialized *   2018-06-11 14:32
  /u01/app/oracle/oradata/cndba/redo02.log  2018-06-08 18:28  2018-06-11 10:05
  /u01/app/oracle/oradata/cndba/redo03.log  2018-06-08 00:47  2018-06-08 18:28
  /u01/app/oracle/oradata/cndba/redo02.log  2018-06-07 18:05  2018-06-08 00:47
  /u01/app/oracle/oradata/cndba/redo01.log  2018-06-07 16:15  2018-06-07 18:05
  Not Available                           * Initialized *   2018-06-07 16:15
  /u01/app/oracle/oradata/cndba/redo03.log  * Initialized *   2018-06-07 16:30
  /u01/app/oracle/oradata/cndba/redo03.log  * Initialized *   2018-06-07 16:30
  /u01/app/oracle/oradata/cndba/redo03.log  2018-06-07 16:15  2018-06-07 16:30
  Not Available                           * Initialized *   2018-06-07 16:15
  /u01/app/oracle/oradata/cndba/redo03.log  * Initialized *   2018-06-07 16:11
  /u01/app/oracle/oradata/cndba/redo03.log  * Initialized *   2018-06-07 16:11
  /u01/app/oracle/oradata/cndba/redo03.log  2018-06-07 16:08  2018-06-07 16:11


Current directory    /u01/app/oracle/ogg

Report file          /u01/app/oracle/ogg/dirrpt/EXT1.rpt
Parameter file       /u01/app/oracle/ogg/dirprm/ext1.prm
Checkpoint file      /u01/app/oracle/ogg/dirchk/EXT1.cpe
Process file         /u01/app/oracle/ogg/dirpcs/EXT1.pce
Stdout file          /u01/app/oracle/ogg/dirout/EXT1.out
Error log            /u01/app/oracle/ogg/ggserr.log

1.3. 查看当前系统时间以及目前存在的local trail文件

[[email protected] dirdat]# ls -l et*
-rw-rw-rw- 1 oracle oinstall 1016 Jun 17 23:08 et000000
-rw-rw-rw- 1 oracle oinstall 1213 Jun 18 11:38 et000001
-rw-rw-rw- 1 oracle oinstall 1075 Jun 18 11:38 et000002

1.4. 在源端插入数据

SQL> conn test/test
Connected.
SQL> begin for i in 1001..1000000 loop
 insert into test values(i,'test');
 end loop;
 commit;
 end;
 /  2    3    4    5    6  

PL/SQL procedure successfully completed.

SQL> select count(*) from test;

  COUNT(*)
----------
999005
--目标端查看成功同步
SQL> conn test/test
Connected.
SQL> select count(*) from test;

  COUNT(*)
----------
999005
源端生成一个新的tail 文件
[[email protected] dirdat]# ls -l et*
-rw-rw-rw- 1 oracle oinstall     1016 Jun 17 23:08 et000000
-rw-rw-rw- 1 oracle oinstall     1213 Jun 18 11:38 et000001
-rw-rw-rw- 1 oracle oinstall 99999960 Jun 18 12:14 et000002
-rw-rw-rw- 1 oracle oinstall 13888313 Jun 18 12:14 et000003

1.5. 根据SCN,查找相对应时间

SQL> select to_char(scn_to_timestamp(1497417),'yyyy-mm-dd hh24:mi:ss') scn from dual;

SCN
-------------------
2018-06-18 12:08:22

1.6. 删除目标端已经成功复制的数据

SQL> delete from test where id>=1001;

999000 rows deleted.

SQL> commit;

Commit complete.
SQL> select count(*) from test;

  COUNT(*)
----------
  5

1.7. 抽取进程从2018-06-18 12:08:22再次抽取事务

--源端操作
GGSCI (cndba) 24> stop ext1

Sending STOP request to EXTRACT EXT1 ...
Request processed.


GGSCI (cndba) 25> alter extract ext1,TRANLOG, BEGIN 2018-06-18 12:08:22
EXTRACT altered.


GGSCI (cndba) 26> start ext1

Sending START request to MANAGER ...
EXTRACT EXT1 starting


GGSCI (cndba) 27> info all

Program     Status      Group       Lag at Chkpt  Time Since Chkpt

MANAGER     RUNNING                                           
EXTRACT     RUNNING     EXT1        00:22:25      00:00:01    
EXTRACT     RUNNING     EXT2        00:00:00      00:00:07    
EXTRACT     RUNNING     PUMP1       00:00:00      00:00:07    
EXTRACT     RUNNING     PUMP2       00:00:00      00:00:03
目标端数据被重新复制
SQL> select count(*) from test;

  COUNT(*)
----------
    999005

你可能感兴趣的:(GoldenGate)