Oracle GoldenGate 之 MySQL -> MySQL 初始化同步数据

新手安装配置请参考:在Windows中 基于Oracle GoldenGate (OGG)进行MySQL->MySQL数据库同步配置(超详细)

一、【源端】

1、配置MGR管理器进程:EDIT PARAMS MGR

GGSCI (SC-201708231409) 1> EDIT PARAMS MGR

2、填写内容

port 7809
dynamicportlist 7840-7939
autorestart extract *,waitminutes 2,retries 5

3、启动MGR管理器进程:start mgr

GGSCI (SC-201708231409) 3> start mgr
Starting Manager as service ('OGGMGR')...
Service started.

4、查看MGR管理器进程:info mgr

GGSCI (SC-201708231409) 6> info mgr
Manager is running (IP port SC-201708231409.7809, Process ID 7584).

5、创建采集投递进程:ADD EXTRACT EJWINIT, SOURCEISTABLE

GGSCI (SC-201708231409) 7> ADD EXTRACT EJWINIT, SOURCEISTABLE

6、查看创建的进程:INFO EXTRACT *, TASKS

GGSCI (SC-201708231409) 8> INFO EXTRACT *, TASKS
EXTRACT    EJWINIT   Last Started 2019-02-03 11:10   Status STOPPED
Checkpoint Lag       Not Available
Log Read Checkpoint  Table project.nbarankings2013
                     2019-02-03 11:10:17  Record 20
Task                 SOURCEISTABLE

7、编辑配置文件:EDIT PARAMS EJWINIT

GGSCI (SC-201708231409) 9> EDIT PARAMS EJWINIT

8、填写内容

EXTRACT EJWINIT
sourcedb [email protected]:3306 userid project password project
RMTHOST 172.16.94.37, MGRPORT 7809
RMTTASK REPLICAT, GROUP RJWINIT
TABLE project.nbarankings2013;

说明
sourcedb:源端数据库连接信息
RMTHOST:目标端ip
MGRPORT:目标端ogg端口号
TABLE:同步的数据库和表,表名可以使用通配符,如table project.*

9、启动进程【注意:需在配置完目标端的接收进程后在执行】:START EXTRACT EJWINIT

GGSCI (SC-201708231409) 10> START EXTRACT EJWINIT
Sending START request to MANAGER ('OGGMGR') ...
EXTRACT EJWINIT starting

10、查看运行情况 :VIEW REPORT EJWINIT

GGSCI (SC-201708231409) 11> VIEW REPORT EJWINIT

2019-02-03 14:00:37  INFO    OGG-01017  Wildcard resolution set to IMMEDIATE because SOURCEISTABLE is used.

***********************************************************************
                  Oracle GoldenGate Capture for MySQL
      Version 12.3.0.1.2 OGGCORE_12.3.0.1.0_PLATFORMS_171208.0005
   Windows x64 (optimized), MySQL Enterprise on Dec  8 2017 11:57:03

Copyright (C) 1995, 2017, Oracle and/or its affiliates. All rights reserved.


                    Starting at 2019-02-03 14:00:37
***********************************************************************

Operating System Version:
Microsoft Windows 10, on x64
Version 10.0 (Build 14393)

Process id: 8152

Description:

***********************************************************************
**            Running with the following parameters                  **
***********************************************************************

2019-02-03 14:00:37  INFO    OGG-03059  Operating system character set identified as GBK.

2019-02-03 14:00:37  INFO    OGG-02695  ANSI SQL parameter syntax is used for parameter parsing.

2019-02-03 14:00:37  INFO    OGG-01360  EXTRACT is running in Initial Load mode.

2019-02-03 14:00:37  INFO    OGG-01889  Flush size (max message size) is set to 27,985.
EXTRACT EJWINIT
sourcedb [email protected]:3306 userid project password ***
RMTHOST 172.16.94.37, MGRPORT 7809
RMTTASK REPLICAT, GROUP RJWINIT
TABLE project.nbarankings2013;

2019-02-03 14:00:38  INFO    OGG-01851  filecaching started: thread ID: 57860608.

2019-02-03 14:00:38  INFO    OGG-01815  Virtual Memory Facilities for: COM
    anon alloc: MapViewOfFile  anon free: UnmapViewOfFile
    file alloc: MapViewOfFile  file free: UnmapViewOfFile
    target directories:
    E:\OGG\oggmsql\dirtmp.
-- More  --

二、【目标端】

1、配置MGR管理器进程:EDIT PARAMS MGR

GGSCI (DESKTOP-LDTMM0I) 1> EDIT PARAMS MGR

2、填写内容

port 7809
dynamicportlist 7840-7939
autorestart er *, retries 5, waitminutes 3
purgeoldextracts D:\OGG\oggmsql\dirdat*,usecheckpoints, minkeepdays 2
ACCESSRULE, PROG *, IPADDR 172.16.94.14, ALLOW

3、启动MGR管理器进程:start mgr

GGSCI (DESKTOP-LDTMM0I) 2> start mgr
Starting Manager as service ('OGGMGR')...
Service started.

4、查看MGR管理器进程:info mgr

GGSCI (DESKTOP-LDTMM0I) 3> info mgr
Manager is running (IP port DESKTOP-LDTMM0I.7809, Process ID 10488).

5、创建接收进程:add replicat RJWINIT,specialrun

GGSCI (DESKTOP-LDTMM0I) 4> add replicat RJWINIT,specialrun

6、查看创建的进程:INFO REPLICAT *, TASKS

GGSCI (DESKTOP-LDTMM0I) 5> INFO REPLICAT *, TASKS

REPLICAT   RJWINIT   Initialized   2019-02-03 10:07   Status STOPPED
Checkpoint Lag       00:00:00 (updated 03:59:44 ago)
Log Read Checkpoint  Not Available
Task                 SPECIALRUN

7、编辑配置文件:edit params RJWINIT

GGSCI (DESKTOP-LDTMM0I) 6> edit params RJWINIT

8、填写内容

REPLICAT RJWINIT
targetdb [email protected]:3306 userid projectTarget password projectTarget
ASSUMETARGETDEFS
DISCARDFILE D:\OGG\oggmsql\dirrpt\RJWINIT.dsc, PURGE
MAP project.NBArankings2013, TARGET project_target.NBArankings2013;

说明
targetdb:目标端数据库连接信息
DISCARDFILE:初始化文件存放位置
MAP:源端需要同步的表
TARGET:目标端相对应的备份表
表名可以使用通配符,如MAP project.* , target ggs.*

9、启动应用进程:START REPLICAT RJWINIT

GGSCI (custom04) 7> START REPLICAT RJWINIT

注意:只需要在首次配置时执行本操作,之后将由源端投递进程自动调用

10、查看运行情况 :VIEW REPORT RJWINIT

GGSCI (DESKTOP-LDTMM0I) 8> VIEW REPORT RJWINIT

***********************************************************************
                 Oracle GoldenGate Delivery for MySQL
      Version 12.3.0.1.2 OGGCORE_12.3.0.1.0_PLATFORMS_171208.0005
   Windows x64 (optimized), MySQL Enterprise on Dec  8 2017 12:31:57

Copyright (C) 1995, 2017, Oracle and/or its affiliates. All rights reserved.


                    Starting at 2019-02-03 14:00:38
***********************************************************************

Operating System Version:
Microsoft Windows 10, on x64
Version 10.0 (Build 10586)

Process id: 11764

Description:

***********************************************************************
**            Running with the following parameters                  **
***********************************************************************

2019-02-03 14:00:44  INFO    OGG-03059  Operating system character set identified as GBK.

2019-02-03 14:00:44  INFO    OGG-02695  ANSI SQL parameter syntax is used for parameter parsing.

2019-02-03 14:00:44  INFO    OGG-01360  REPLICAT is running in Remote Task mode.REPLICAT RJWINIT
targetdb [email protected]:3306 userid projectTarget password ***
ASSUMETARGETDEFS
DISCARDFILE D:\OGG\oggmsql\dirrpt\RJWINIT.dsc, PURGE
MAP project.NBArankings2013, target project_target.NBArankings2013;

2019-02-03 14:00:44  INFO    OGG-01815  Virtual Memory Facilities for: COM
    anon alloc: MapViewOfFile  anon free: UnmapViewOfFile
    file alloc: MapViewOfFile  file free: UnmapViewOfFile
    target directories:
    D:\OGG\oggmsql\dirtmp.

Database Version:
MySQL
Server Version: 8.0.13
Client Version: 5.6.14
Host Connection: 127.0.0.1 via TCP/IP
Protocol Version: 10

Database Language and Character Set:
CLIENT CHARACTER SET         = "gbk"
SERVER CHARACTER SET         = "utf8mb4"
DATABASE CHARACTER SET       = "utf8mb4"
-- More  --

三、注意事项

1、 在大量数据初始化的时候,注意目标端的归档日志空间大小。如果数据源为100G,理论上目标端的归档日志空间也至少大于100G才行。

如果归档日志满了将会报错:ORA-00257: archiver error. Connect internal only, until freed,解决方法:
https://blog.csdn.net/cw370008359/article/details/51023794
https://jingyan.baidu.com/article/29697b911dde4bab21de3c4d.html

2、需要注意的是目标端与源端的OGG版本最后保持一致。如何查看OGG版本?进入ggsci即可查看:
image.png
3、数据表中无主键需要在目标端设置:APPLYNOOPUPDATES。

该参数的含义就是不忽略出现的NO-OP操作,而是在目标数据库强制执行UPDATE修改操作,且只更新键值数据(主键或KEYCOLS指定的键值),如果表没有主键,也没有使用KEYCOLS关键字指定字段,那么将更新表数据的所有字段,如果没有相应记录,将INSERT新插入一条。

4、在操作ggsci时,一定要注意权限组是否一致,否则导致mgr等进程无法查看正常的运行状态,也不能启动停止。

ERROR:opening port for MGR MGR (Connection refused).

image.png

相关解释:http://blog.itpub.net/29047826/viewspace-1808538/

5、OGG-01194错误

OGG-01194 Oracle GoldenGate Capture for Oracle, ext_sc0.prm: EXTRACT task REP_SC0 abended : File InitialLoad, with compatibility level 6, is not compatible with the current software version's compatibility level of 5. Modify the file writer's parameter file to generate the appropriate format using the FORMAT LEVEL 5 option.

在抽取进程中设置:

RMTTASK REPLICAT, GROUP REP_SC0,FORMAT LEVEL 5

EXTTRAIL /OGG/dirdat/e1,FORMAT LEVEL 5

还有一种情况,如果目标端是低版本,将不会支持FORMAT。所有你还是将版本更换一致最佳。

四、GoldenGate 相关资料

  • 在Windows中 基于Oracle GoldenGate (OGG)进行Oracle->Oracle数据库同步配置(超详细)

  • OGG Oracle -> Oracle 初始化同步数据

  • 【官方文档】使用 Oracle GoldenGate 在 Microsoft SQL Server 和 Oracle Database 之间复制事务

你可能感兴趣的:(Oracle GoldenGate 之 MySQL -> MySQL 初始化同步数据)