Oracle Golden Gate 系列十三 -- 配置GG进程检查点(checkpoint) 说明

 

一.Checkpoints 理论说明

有关GG的Checkpoints 在系列一, GG的架构中以说明:

OracleGolden Gate 系列一 --GG 架构 说明

http://blog.csdn.net/tianlesoftware/article/details/6925907

 

这里在单独拿出来说明一下,因为这是一个较为重要的概念。

 

Checkpoints storethe current read and write positions of a process to disk for recovery purposes.These checkpoints ensure that data changes that are marked for synchronizationactually are extracted by Extract and replicated by Replicat, and they preventredundant processing.

--Checkpoint 存储了进程当前读和写的位置。 Checkpoints 保证已经改变的数据已经同步,从而阻止其他冗余的操作。

They providefault tolerance by preventing the loss of data should the system, the network,or an Oracle GoldenGate process need to be restarted. For complexsynchronization configurations, checkpoints enable multiple Extract or Replicatprocesses to read from the same set of trails.

--通过Checkpoints 可以在以下情况下的数据丢失:系统或者网络故障,重启GG进程。Checkpoints支持多个Extact 或者Replicat 进程读取同一个trail 文件。

Checkpoints workwith inter-process acknowledgments to prevent messages from being lost in thenetwork. Oracle GoldenGate has a proprietary guaranteed-message delivery technology.

 

Extract createscheckpoints for its positions in the data source and in the trail. Replicat createscheckpoints for its position in the trail.

       --默认情况下Extract 和 Replicat 进程都会在trail文件里记录checkpoints 的位置。

 

A checkpointsystem is used by Extract and Replicat processes that operate continuously, butit is not required by Extract and Replicat processes that run in batch mode. Abatch process can be re-run from its start point, whereas continuous processingrequires the support for planned or unplanned interruptions that is provided bycheckpoints.

--checkpoints 机制保证了Extract 和 Replicat 进程可以连续的操作。

 

Replicat storesits checkpoints in a checkpoint table in the target database to couple the commitof its transaction with its position in the trail file. This ensures that atransaction will only be applied once, even if there is a failure of theReplicat process or the database process. For reporting purposes, Replicat alsohas a checkpoint file on disk in the dirchk subdirectory of the OracleGoldenGate directory.

--Replicat 在Target 库的checkpoint 表里记录了已经提交了事务在trail 文件里的位置。这样就可以保证事务只被应用一次,即使在replicat 进程或者DB 出现故障的情况下。 为了做报告,Replicat也会在GG 安装目录的dirchk 目录里存放一个checkpoint 文件。

 

You canoptionally configure Replicat to use this file as its sole checkpoint store,and not use a checkpoint table at all. In this mode, however, there can becases where the checkpoint in the file is not consistent with what was appliedafter a database recovery, if the failure either rolled back or rolled forwarda transaction that was considered applied by Replicat. The checkpoint table guaranteesconsistency after recovery.

--我们可以在不使用checkpoint 的情况下,配置Replicat 进程使用这个本地的文件来存储checkpoint,但是使用本地的checkpoint 文件, 在数据库做了recover的情况下,不能保证数据的一致性。

在事务rolled back 或 rolledforward失败的情况下,使用本地checkpoint 文件还是可以保证一致性。

而如果使用checkpoint table,在databaserecover 的情况下也可以保证数据的一致性。 所以推荐也是使用checkpont。

 

Replicatmaintains checkpoints that provide a known position in the trail from which to startafter an expected or unexpected shutdown. To store a record of its checkpoints,Replicat uses a checkpoint table in the target database. This enables theReplicat checkpoint to be included within the Replicat transaction itself, toensure that a transaction will only be applied once, even if there is a failureof the Replicat process or the database process. Thecheckpoint table remains small because rows are deleted when no longer needed, andit does not affect database performance.

--Checkpoint 保留了很少的记录,对于哪些很长时间内不需要的的数据会自动删除,所以checkpoint 不会对数据库造成性能上的影响。

 

 

GoldenGate的检查点信息有两种存放方式:

1.     存放在GGHOME\dirchk下的文件中。

这种是默认的方法,一个进程对应一个文件。提取进程可以只使用这种模式。不需要checkpoint table。 但是这种方式在db recovery 之后可能出现数据不一致。

 

gg2:/u01/backup> cd /u01/ggate/dirchk

gg2:/u01/ggate/dirchk> ls

REP1.cpr  REPT2.cpr

 

2.     存放在数据库指定的表中,需要单独配置。

 

配置步骤如下:

(1)在./GLOBALS文件里添加checkpoint 表名

CHECKPOINTTABLE [<owner>.<table>]   --指定的检查点记录表

(2)连上DB,创建checkpoint 表

GGSCI> DBLOGIN [SOURCEDB <dsn>][,USERID <db_user>[, PASSWORD <pw>]]

GGSCI> ADD CHECKPOINTTABLE [<owner>.<table>]   --生成这个检查点记录表

(3)在新增复制进程时可以在添加时指定checkpointtable[<owner>.<table>] 替代nodbcheckpoint,使用数据库记录检查点信息。

 

二.示例

2.1   配置./GLOBALS 参数

GGSCI (gg2) 65> view params ./GLOBALS

 

GGSCHEMA ggate

CHECKPOINTTABLE ggate.checkpoint

 

当我们在GLOBALS 文件里指定了默认的checkpoint 之后,新的Replicat groups 在创建时会自动使用这个参数,不需要其他指令。

 

2.2 连上数据库,创建checkpoint表

 

GGSCI (gg2) 58> dblogin useridggate@gg2,password ggate

Successfully logged into database.

 

GGSCI (gg2) 59> add checkpointtableggate.checkpoint

Successfully created checkpoint tableGGATE.CHECKPOINT.

 

2.3 在创建Replicat进程时,指定checkpoint 表

GGSCI (gg2) 14> add replicatrep1,exttrail /u01/ggate/dirdat/lt, checkpointtable ggate.checkpoint

REPLICAT added.

 

至此,Checkpoint 的配置就完成。 我们查看一下checkpoint 表。

 

SQL> conn ggate/ggate

deConnected.

SQL> desc checkpoint

 Name                                     Null?    Type

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

 GROUP_NAME                                NOT NULLVARCHAR2(8)

 GROUP_KEY                                 NOT NULLNUMBER(19)

 SEQNO                                             NUMBER(10)

 RBA                                       NOT NULLNUMBER(19)

 AUDIT_TS                                          VARCHAR2(29)

 CREATE_TS                                 NOT NULL DATE

 LAST_UPDATE_TS                            NOT NULL DATE

 CURRENT_DIR                               NOT NULLVARCHAR2(255)

 

SQL> select * from checkpoint;

 

GROUP_NA GROUP_KEY      SEQNO        RBA AUDIT_TS                      CREATE_TS    LAST_UPDATE_ CURRENT_DIR

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

REP1    3987940558         12       1564 2011-11-17 17:21:55.471376    17-NOV-11   17-NOV-11    /u01/ggate

 

 

 

 

 

 

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

版权所有,文章允许转载,但必须以链接方式注明源地址,否则追究法律责任!

Blog:     http://blog.csdn.net/tianlesoftware

Weibo: http://weibo.com/tianlesoftware

Email:   tianlesoftware@gmail.com

Skype: tianlesoftware

 

-------加群需要在备注说明Oracle表空间和数据文件的关系,否则拒绝申请----

DBA1 群:62697716(满);   DBA2 群:62697977(满)  DBA3 群:62697850(满)  

DBA 超级群:63306533(满);  DBA4 群:83829929(满) DBA5群: 142216823(满) 

DBA6 群:158654907(满)   DBA7 群:69087192(满)  DBA8 群:172855474

DBA 超级群2:151508914  DBA9群:102954821     聊天 群:40132017(满)

posted @ 2011-11-17 20:05  hibernate我最强  阅读(352)  评论(0编辑  收藏  举报