合 【OGG】Using the Oracle GoldenGate for SQL Server CDC Capture Replication
Before You Begin
This tutorial shows you how to use the CDC Capture replication, which utilizes the SQL Server Change Data Capture feature to read DML from the transaction log and load it into individual staging tables for each user table enabled with supplemental logging. The CDC Extract then reads the DML from the staging tables and reconstructs transactions then writes the data into trail files.
This tutorial takes approximately 15 minutes to complete.
Background
Previously, only Classic Capture was possible with SQL Server databases. With the Oracle GoldenGate 12c (12.3.0.1) release, the CDC Capture replication is introduced.
What Do You Need?
Before starting this tutorial:
Using the following tasks, you create both a Uni-Directional and a Bi-Directional SQL Server to SQL Server Replication.
一、Setting Up the Uni-Directional CDC Extract
Create a system DSN to the source database and set the change the default database to option to the source database. Use a Windows or SQL Server login that has
sysadmin
rights for this connection. You can alter the permissions todbowner
at a later time, if you want to use the same account for the Extract and are not allowed to have Extract running withsysadmin
.Unzip the
ggs_Windows_x64_MSSQL_64bit_CDC.zip
file to a new Oracle GoldenGate installation directory.Create a
GLOBALS
file in the base Oracle GoldenGate installation directory, and set theGGSCHEMA
parameter to that of an existing or new schema in the source database. Oracle recommends that you create a specific schema for Oracle GoldenGate objects.For example -
1CREATE SCHEMA ggs. Do not to use the dbo schema.
1GGSCI> EDIT PARAMS ./GLOBALSSave the GLOBALS file.
Using
GGSCHEMA
in theGLOBALS
file is a new requirement for Oracle GoldenGate for SQL Server CDC Capture. It is required so thatADD TRANDATA
can identify which schema to create necessary objects under then Extract knows which schema to call those objects from during runtime. Classic Extract does not have this requirement.Start
ggsci.exe
and create the necessary sub directories.1GGSCI> CREATE SUBDIRSCreate the Manager parameter file; list a valid
PORT
for the Manager to use, then save the file. For example,PORT 7809
1GGSCI> EDIT PARAMS MGRConnect to the source database from GGSCI and enable supplemental logging for the user tables to be captured from using one of the following:
For a SQL Server Authenticated DSN, the
USERID
andPASSWORD
are optional:12GGSCI> DBLOGIN SOURCEDB sourcedsn [USERID user PASSWORD password]GGSCI> ADD TRANDATA dbo.*Or for a Windows Authenticated DSN:
12GGSCI> DBLOGIN SOURCEDB sourcedsnGGSCI> ADD TRANDATA dbo.*In the Management Studio, within a query window for the source database. You must manually drop the SQL Server CDC cleanup job for the database because it may cause data loss for the Extract.
1EXECUTE sys.sp_cdc_drop_job 'cleanup';Use the
ogg_cdc_cleanup_setup.bat
utility (in the Oracle GoldenGate installation directory) to create the Oracle GoldenGate CDC cleanup job and associated objects. Theggschema
name used must be the same that you used with theGGSCHEMA
parameter of theGLOBALS
file. You must use a SQL Server authenticated user that hassysadmin
rights.1d:\>OGG\ogg_cdc_cleanup_setup.bat createJob username password databasename servername\instancename ggschemaCreate and save a new Extract parameter file using this sample of the minimum required parameters for a uni-directional implementation.
123456GGSCI> EDIT PARAMS cdcextEXTRACT cdcextSOURCEDB sourcedsn [USERID user PASSWORD password]EXTTRAIL ./dirdat/ceTABLE dbo.*;本人提供Oracle(OCP、OCM)、MySQL(OCP)、PostgreSQL(PGCA、PGCE、PGCM)等数据库的培训和考证业务,私聊QQ646634621或微信dbaup66,谢谢!