GoldenGate initialization explore ways

Foreword

We know that Oracle GoldenGate is from the transaction log data capture and delivery, delivery redo the system to the target database. It provides a flexible, coupled architecture can be used to implement virtually all replication scenarios. But the biggest problem is that we fully understood at the time of its implementation is to create the replication target database and data before change data capture initialize the target database. To this end, Oracle is also working to solve this problem, the most important part is the application of "CSN" (Commit Sequence Number) in the target client database, so the "CSN" Unlike before we often hear "SCN" (System Change Number), but they are functionally interchangeable, different grammatical knowledge, this paper is stored in LOGCSN use of GoldenGate achieve optimal initialization.

Before reading this document, we should agree on the following points:

l have knowledge and understanding of the basic concepts of Oracle GoldenGate product

l version of the above applies to Oracle GoldenGate10

l for Oracle Database version 9.2 and above

l Applicable operating systems: Oracle GoldenGate supports all Oracle database platform

 

What is LOGCSN

Oracle GoldenGate version 10 introduced Trail file a new mechanism that holds the transaction commit order number (commitsequence number), the name of this mechanism is called LOGCSN. It corresponds to the number inside the database system changes (SCN) .LOGCSN can be viewed in the logdump, it only exists in Translnd 0 (start transaction) or 3 (single transaction operation), if a transaction contains a plurality of operations, then the first an action must contain a TransID0, indicates the start of a transaction, the same thing after the operation will contain Translnd 1, and finally at the end of the transaction will include a TransID2, if the transaction is only one operation, then the operation will contain only a TransID3. At the end of each file will record a LOGCSN number, if the number is greater than LOGCSN scn number of records you explain this transaction queue file occurs after you export data, if the number is less than LOGCSN explanation queue file number you recorded scn this transaction is occurring before you export the data. Here is the view LOGCSN number of tools with LOGDUMP example:

Start LOGDUMP tool in OGG directory


Specify a trace file


Press n flip open the file viewer, can be seen below LOGCSN No.


ATCSN与AFTERCSN

In Oracle GoldenGate 10, we can specify LOGCSN Replicat number when you start the process, we hope to start applying the application data changes. LOGCSN number corresponds to a database inside the system change number SCN number, before the backup source library that we should record the current SCN number database, database application log when the target starts this application from the current SCN number.

If taken exactly corresponds SCN COMMIT operation:

ATCSN <csn>: When using ATCSN parameters, before this Replicat will commit the same transaction-related operations applied once again, because when initialized before the transaction has been restored before this SCN numbers, so in this case re-use ATCSN parameter to start the process Replicat it will lead to data duplication, inconsistent data source and target libraries.

AFTERCSN <csn>:使用AFTERCSN参数时,则只会应用commit之后的操作。不会导致数据重复应用的情况。

如果取的SCN不是对应的commit操作:

不管是用ATCSN或AFTERCSN参数,Replicat进程都会把这个SCN号之前未完成的事务重新应用。在初始化恢复目标库时会回滚掉未提交的事务,所以不会出现数据重复。

建议使用AFTERCSN,不管在哪种情况下都能保证数据一致。

初始化前的准备

为了不会丢失任何数据,在初始化之前,必须查看数据库里是否还存在长事务。可以通过如下命令查看数据库事务的开始时间,并筛选出最小的开始时间,看是否大于Extract进程的启动时间,需要等到其开始时间大于Extract进程的启动时间后才能进行初始化。因为OGG只获取Extract启动后的变化数据。(如果是RAC环境需要查询GV$TRANSACTION视图)。

SQL>select min(start_time) from v$transaction;

常用的初始化工具

Recovery Manager(RMAN)

RMAN(Recovery Manager)是一种用于备份、还原和恢复数据库的Oracle 工具。RMAN只能用于ORACLE8I或更高的版本中。在相同平台相同版本并要求不停业务的情况下,首先选择RMAN这种初始化方式。和其他工具相比RMAN速度比较快,在不停业务的情况下,对数据库性能影响较小,实施难度不大操作方便。但是使用RMAN初始化必须将源数据库开启归档模式。

EXPDP/IMPDP(数据泵)

EXPDP/IMPDP是一个10G引入的备份工具,它能够实现逻辑备份、逻辑恢复、在数据库之间移动对象、实现表空间迁移。它能够在相同平台或不同平台下并且在不停业务的情况下快速完成初始化。但是数据泵这种方式比较耗磁盘IO,所以不建议在业务高峰期的时候使用,会影响使用性能。数据泵是从ORACLE 10G开始引入的一个工具,版本在10G以前的不能使用。

EXP/IMP(导入/导出)

上面说到EXPDP/IMPDP是从10G开始引入的逻辑备份工具,那么在10G之前的版本,ORACLE提供了EXP/IMP(导入/导出)工具,这个也是一种逻辑备份工具,用法和功能都和EXPDP和IMPDP差不多。它们的区别在于EXP是通过数据字典来获取相应对象信息,并且通过SELECT来返回对象中的数据,在EXP时会进行全表扫描,相当于做了一次块检查所以速度较慢。而EXPDP主要是通过执行DBMS_METADATA的包来获取对象的相应信息,直接是通过拷贝相应数据文件块的方式,所以效率比EXP快了很多。EXP/IMP也能在相同平台或不同平台下并且在不停业务的情况下完成初始化,但是速度较慢。不建议在大速度库使用该方法。

GoldenGate Initial Load

goldengate自己也带了一个初始化工具,它能够实现不同平台数据库之间的初始化,如:SQLSERVER到ORACLE,GoldenGateInitial Load直接初始化是Extract进程获取的源端记录直接传输给目标端的Initial Load Replicat进程。这种方式不支持LOB和LONG类型的数据。速度比较慢。

初始化方法分析比较

RMAN

优点:速度快、对主数据库性能影响较小、实施简单。

缺点:限制比较多,如:数据库必须处于归档模式,跨数据库版本、平台限制比较大。

在同平台环境下建议选择RMAN

EXPDP/IMPDP

优点:速度快、支持不同环境下的初始化,而且不会停业务。

缺点:在导出时对主数据库性能影响较大、只支持10G以后的数据库使用。

在不同平台环境下,数据库是10G以上版本的建议使用EXPDP/IMPDP。

EXP/IMP

优点:支持不同环境下的初始化,而且不会停业务、低版本数据库可以使用此工具。

缺点:在导出时对主数据库性能影响较大、速度慢。

如果数据库版本较低,源端和目标端环境又不同,建议使用EXP/IMP,但如果数据量很大操作200G,可以建议用户下班之后停机用冷备的方式来初始化。

GoldenGate Initial Load

优点:能够跨数据库平台初始化。

缺点:不支持LOB和LONG类型的字段、速度比较慢。

如果是跨数据库平台,如SQLSERVER到ORACLE,可以选用OGG自带的迁移功能GoldenGate Initial Load。

综上所述,每一种都有自己的优点和缺点,我们在选择这些工具前,应该先考虑环境,然后在针对不同环境选择最好的工具。

发布了35 篇原创文章 · 获赞 61 · 访问量 16万+

Guess you like

Origin blog.csdn.net/woailyoo0000/article/details/80438681
Recommended