Oracle GoldenGate 系列:深入理解 Oracle GoldenGate 检查点机
检查点将进程的当前读写位置存储在磁盘中用于恢复目的。检查点不仅可以真实地标记 Extract 进程捕获的要进行同步的数据变化以及 Replicat 进程应用到 target 数据库的数据变化,防止进程进行冗余的数据处理,还可以提供容错机制,防止在系统、网络或 Oracle
检查点将进程的当前读写位置存储在磁盘中用于恢复目的。检查点不仅可以真实地标记 Extract进程捕获的要进行同步的数据变化以及 Replicat进程应用到 target数据库的数据变化,防止进程进行冗余的数据处理,还可以提供容错机制,防止在系统、网络或 Oracle GoldenGate进程需要重启时发生数据丢失。对于复杂的同步配置,检查点可以确保多个 Extract或Replicat进程从同一组 trail文件中进行读取操作。检查点和进程间的回执机制共同防止了网络间的信息丢失。 Oracle GoldenGate采用了一套专有的可靠信息传递技术。
Extract进程创建检查点来存储其在数据源中的读取位置以及trail文件中的写入位置信息。由于 Extract进程只捕获已提交的事务,因此 Extract进程必须跟踪所有 open(未提交)事务的操作,才能实时感知这些事务的提交状态。这就要求 Extract进程记录一个检查点来表示该进程当前在事务日志中的读取位置以及最早开始的 open(未提交)事务的起始位置(可能在当前读取的事务日志中,也可能在之前的事务日志中)。为了控制 Extract进程发生中断后必须重新处理的事务日志量,Extract进程会以特定的时间间隔将正在处理的事务(包括长时间运行的事务的状态和数据)的当前状态及数据写入磁盘。当 Extract进程在这些时间间隔中任意某个间隔点停止时,Extract进程可以直接从上一个时间间隔内的某个时间点或者上一个检查点位置开始进行恢复,而不用从事务日志中最早开始的长时间运行事务的起始位置开始进行恢复。这一过程实质上就是 Extract进程的Bounded Recovery机制,详情请参考《Oracle GoldenGate 系列:Extract 进程的恢复原理》,地址:http://blog.csdn.net/xiangsir/article/details/8785484。
Replicat进程创建检查点来存储其在 trail文件中的读取位置。Replicat进程将其检查点信息存储在 target 数据库中的检查点表中来保护其处理的事务的提交信息以及在 trail文件中的读取位置。当数据库进行恢复后,检查点表可以保证数据的一致性,确保即使是在 Replicat进程或者数据库进程发生故障后,一个事务也只会被应用一次。为了实现报告目的,Replicat进程还会在OGG根目录下的 dirchk子目录下写一个检查点文件。对于 initial load之类的非持续性同步配置,不需要检查点机制。
? Extract进程负责维护:
? 3 个输入检查点
? 1 个输出检查点
通过 info extractextract_name,showch命令可以查看上述检查点信息:
Extract进程检查点信息示例
GGSCI(prod.oracle.com) 11> info escott,showch
EXTRACT ESCOTT Last Started 2013-05-23 20:51 Status RUNNING
Checkpoint Lag 00:00:00 (updated 00:00:01 ago)
Log ReadCheckpoint Oracle Redo Logs
2013-05-23 20:52:01 Seqno 201, RBA 352256
SCN 0.1649108 (1649108)
Current CheckpointDetail:
-----三个输入检查点
Read Checkpoint #1
Oracle Redo Log
Startup Checkpoint (starting position in thedata source):
Thread #: 1
Sequence #: 200
RBA: 4214800
Timestamp: 2013-05-23 17:33:36.000000
SCN: 0.1628299 (1628299)
Redo File:/u01/app/oracle/oradata/prod/redo02.log
RecoveryCheckpoint (position of oldest unprocessed transaction in the data source):
Thread #: 1
Sequence #: 201
RBA: 347152
Timestamp: 2013-05-23 20:51:58.000000
SCN: 0.1649106 (1649106)
Redo File:/u01/app/oracle/oradata/prod/redo03.log
CurrentCheckpoint (position of last record read in the data source):
Thread #: 1
Sequence #: 201
RBA: 352256
Timestamp: 2013-05-23 20:52:01.000000
SCN: 0.1649108 (1649108)
Redo File:/u01/app/oracle/oradata/prod/redo03.log
----一个输出检查点
Write Checkpoint #1
GGS Log Trail
CurrentCheckpoint (current write position):
Sequence #: 30
RBA: 1079
Timestamp: 2013-05-23 20:52:04.923545
Extract Trail: ./dirdat/aa
Extract(Pump)进程检查点信息示例
GGSCI(prod.oracle.com) 15> info pscott,showch
EXTRACT PSCOTT Last Started 2013-05-23 21:25 Status RUNNING
Checkpoint Lag 00:00:00 (updated 00:00:06 ago)
Log ReadCheckpoint File ./dirdat/aa000030
First Record RBA 1079
Current CheckpointDetail:
Read Checkpoint #1
GGS Log Trail
Startup Checkpoint (starting position in thedata source):
Sequence #: 30
RBA: 1079
Timestamp: 2013-05-23 20:51:22.385499
Extract Trail: ./dirdat/aa
CurrentCheckpoint (position of last record read in the data source):
Sequence #: 30
RBA: 1079
Timestamp: Not Available
Extract Trail: ./dirdat/aa
Write Checkpoint #1
GGS Log Trail
CurrentCheckpoint (current write position):
Sequence #: 16
RBA: 1251
Timestamp: 2013-05-23 21:37:59.020538
Extract Trail: ./dirdat/pa
Oracle建议在 target数据库中创建检查点表,GoldenGate会同时在检查点文件和检查点表(如果存在)中维护检查点数据。
? Replicat进程负责维护2个输入检查点:
Replicat(Delivery)进程检查点信息示例
GGSCI(dss.oracle.com) 2> info rscott,showch
REPLICAT RSCOTT Last Started 2013-05-23 21:33 Status RUNNING
Checkpoint Lag 00:00:00 (updated 00:00:00 ago)
Log ReadCheckpoint File ./dirdat/pa000016
First Record RBA 1251
Current CheckpointDetail:
Read Checkpoint #1
GGS Log Trail
StartupCheckpoint (starting position in the data source):
Sequence #: 16
RBA: 1251
Timestamp: 2013-05-23 21:26:10.516047
Extract Trail: ./dirdat/pa
CurrentCheckpoint (position of last record read in the data source):
Sequence #: 16
RBA: 1251
Timestamp: Not Available
Extract Trail: ./dirdat/pa
CSN stateinformation:
CRC: 6D-46-5-9A
Latest CSN: 1619129
Latest TXN: 2.32.1145
Latest CSN of finished TXNs: 1619129
Completed TXNs: 2.32.1145
除了上述 infoprocess_name,showch 命令可以查看进程的详细检查点信息外,对于 Replicat进程,我们一般还会配置 checkpoint表,我们还可以在 checkpoint表中获取这些信息。
OGG进程的检查点文件位于 dirchk子目录下,Extract进程的检查点文件扩展名为 cps,Replicat进程的检查点文件扩展名为 cpr:
The different OGG checkpoint files are located underthe dirchk/ location, e.g.
- extract related : *.cpe;
- extract pump (datapump) related : *.cpe;
- bounded recovery related : *.cpb; - refer to 'Bounded Recovery'
- replicat related : *.cpr
源文档 http://www.manishsrivastava-dba.com/2012/11/comparison-of-golden-gate-vs-streams.html>
[oracle@proddirchk]$ ls -lt ESCOTT*
-rw-rw-r-- 1 oracleoinstall 67584 May 23 21:58 ESCOTT.cpe
[oracle@proddirchk]$ ls -lt PSCOTT*
-rw-rw-r-- 1 oracleoinstall 67584 May 23 21:58 PSCOTT.cpe
[oracle@dss dirchk]$ls -lt RSCOTT*
-rw-rw-r-- 1 oracleoinstall 22528 May 23 21:55 RSCOTT.cpr
对于 Replicat进程,我们一般还会配置 checkpoint表,可以直接通过查询检查点表获取进程的检查点信息:
select * fromggs.ggs_checkpoint
Oracle GoldenGate检查点机制工作原理详解:
Extract(Capture)进程如何记录检查点
如上图所示,源数据库中共运行了4个事务:TX1、TX2、TX3和 TX4,Capture(Extract)进程将从事务日志中捕获的最早开始运行的未提交的事务 Begin,TX1 检查点信息、从事务日志中读取的最后一条操作记录Delete,TX4的检查点信息以及按照事务提交顺序写入trail文件的最后一条commit操作 COMMIT,TX3 的检查点信息写入检查点文件(见图中的文本图标)。注意,上图虽未包含事务日志的读取起点信息,并不代表 Extract进程不会将该检查点信息写入磁盘文件。
Extract(Pump)进程如何记录检查点
如上图所示,Pump进程将其在 Extract进程所写的 trail文件中的当前读取位置Commit,TX2以及在自己所写的 remote trail文件中的当前写入位置 Commit,TX2记录到磁盘上的检查点文件中。
Replicat(Delivery)进程如何记录检查点
如上图所示,Replicat进程将其在 Pump文件传送过来的 trail文件中的当前读取位置Commit,TX2写入检查点文件。
作者:xiangsir
QQ:444367417
MSN:xiangsir@hotmail.com

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Solutions to Oracle cannot be opened include: 1. Start the database service; 2. Start the listener; 3. Check port conflicts; 4. Set environment variables correctly; 5. Make sure the firewall or antivirus software does not block the connection; 6. Check whether the server is closed; 7. Use RMAN to recover corrupt files; 8. Check whether the TNS service name is correct; 9. Check network connection; 10. Reinstall Oracle software.

The method to solve the Oracle cursor closure problem includes: explicitly closing the cursor using the CLOSE statement. Declare the cursor in the FOR UPDATE clause so that it automatically closes after the scope is ended. Declare the cursor in the USING clause so that it automatically closes when the associated PL/SQL variable is closed. Use exception handling to ensure that the cursor is closed in any exception situation. Use the connection pool to automatically close the cursor. Disable automatic submission and delay cursor closing.

In Oracle, the FOR LOOP loop can create cursors dynamically. The steps are: 1. Define the cursor type; 2. Create the loop; 3. Create the cursor dynamically; 4. Execute the cursor; 5. Close the cursor. Example: A cursor can be created cycle-by-circuit to display the names and salaries of the top 10 employees.

Oracle database paging uses ROWNUM pseudo-columns or FETCH statements to implement: ROWNUM pseudo-columns are used to filter results by row numbers and are suitable for complex queries. The FETCH statement is used to get the specified number of first rows and is suitable for simple queries.

To stop an Oracle database, perform the following steps: 1. Connect to the database; 2. Shutdown immediately; 3. Shutdown abort completely.

Building a Hadoop Distributed File System (HDFS) on a CentOS system requires multiple steps. This article provides a brief configuration guide. 1. Prepare to install JDK in the early stage: Install JavaDevelopmentKit (JDK) on all nodes, and the version must be compatible with Hadoop. The installation package can be downloaded from the Oracle official website. Environment variable configuration: Edit /etc/profile file, set Java and Hadoop environment variables, so that the system can find the installation path of JDK and Hadoop. 2. Security configuration: SSH password-free login to generate SSH key: Use the ssh-keygen command on each node

SQL statements can be created and executed based on runtime input by using Oracle's dynamic SQL. The steps include: preparing an empty string variable to store dynamically generated SQL statements. Use the EXECUTE IMMEDIATE or PREPARE statement to compile and execute dynamic SQL statements. Use bind variable to pass user input or other dynamic values to dynamic SQL. Use EXECUTE IMMEDIATE or EXECUTE to execute dynamic SQL statements.

When Oracle log files are full, the following solutions can be adopted: 1) Clean old log files; 2) Increase the log file size; 3) Increase the log file group; 4) Set up automatic log management; 5) Reinitialize the database. Before implementing any solution, it is recommended to back up the database to prevent data loss.
