Oracle GoldenGate 之 MySQL -> MySQL DDL 同步(win10)

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

下列操作默认已配置 OGG DML

Oracle GoldenGate Windows平台MySQL->MySQL DDL同步,试验环境:
源端软件版本 目标端软件版本 Oracle GoldenGate 12.3.0.1.2 for MySQL on Windows (64bit) (72 MB) Oracle GoldenGate 12.3.0.1.2 for MySQL on Windows (64bit) (72 MB) dirdat目录 D:\OGG\oggmsql\dirdat F:\OGG\oggmsql\dirdat

注意:DDL 目前只支持 mysql 5.7 版本
mysql 5.7下载地址: https://dev.mysql.com/downloads/windows/installer/5.7.html

一、【配置】

1、修改 MySQL 配置文件 my.ini

  • mysql 配置文件 my.ini 中找到 [mysqld] 添加以下内容:
  • binlog-ignore-db=oggddl
    binlog_format=row

    my.ini文件位置(Windows): https://jingyan.baidu.com/article/7e4409531f75292fc0e2efe7.html

    2、安装 DDL 插件

  • 在ogg安装目录执行 : ddl_install.cmd install project "project" 3306
  • D:\OGG\oggmsql>ddl_install.cmd install project "project" 3306
    You have selected the option: "install"
    checking MySQL version number
    DDL is supported for your installed MySQL version.
    plugin_dir: C:\Program Files\MySQL\MySQL Server 5.7\lib\plugin\
    The metadata_server started successfully.
    Copying ddl_rewriter plugin
    已复制         1 个文件。
    copying of ddl_rewriter.dll succeeded
    Copying ddl_metadata plugin
    已复制         1 个文件。
    copying of ddl_metadata.dll succeeded
    Plugins installation was successful.
    Installation was successful.
    

    ddl插件命令指南
    ddl_install.cmd start project "project" 3306 > 启动ddl插件
    ddl_install.cmd stop project "project" 3306 > 停止ddl插件
    ddl_install.cmd restart project "project" 3306 > 重启ddl插件
    ddl_install.cmd status project "project" 3306 > 查询ddl插件状态
    ddl_install.cmd install project "project" 3306 > 安装ddl插件
    ddl_install.cmd uninstall project "project" 3306 > 卸载ddl插件

    注意这里完成后需要重启mysql服务,使参数生效

    3、配置extract抽取进程,输入edit params eora将会弹出文本编辑器并写入:

    GGSCI (SC-201708231409 DBLOGIN as project) 15> edit params eora
    

    以下是添加内容:

    extract eora
    sourcedb project@127.0.0.1:3306 userid project password project
    TranLogOptions AltLogDest D:\OGG\mysqlbin\binlog.index
    exttrail D:\OGG\oggmsql\dirdat\et
    ddl include mapped
    table project.*;

    输入命令:alter extract eora, tranlog, begin now

    GGSCI (SC-201708231409 DBLOGIN as project) 15> alter extract eora, tranlog, begin now
    

    4、重启各进程,修改表结构,检测是否修改成功

    二、【GoldenGate 错误解决方案】

    1、问题:'cp' 不是内部或外部命令,也不是可运行的程序或批处理文件、找不到 C:\Program Files\MySQL\MySQL Server 5.7\lib\plugin\ddl_rewriter.dll、找不到 C:\Program Files\MySQL\MySQL Server 5.7\lib\plugin\ddl_metadata.dll

    D:\OGG\oggmsql>ddl_install.cmd install project "project" 3306
    You have selected the option: "install"
    checking MySQL version number
    DDL is supported for your installed MySQL version.
    plugin_dir: C:\Program Files\MySQL\MySQL Server 5.7\lib\plugin\
    The metadata_server started successfully.
    Copying ddl_rewriter plugin
    'cp' 不是内部或外部命令,也不是可运行的程序
    或批处理文件。
    找不到 C:\Program Files\MySQL\MySQL Server 5.7\lib\plugin\ddl_rewriter.dll
    找不到 C:\Program Files\MySQL\MySQL Server 5.7\lib\plugin\ddl_metadata.dll
    成功: 给进程 "metadata_server.exe" 发送了终止信号,进程的 PID 为 4948。
    "ERROR: The copy of the ddl_rewriter.dll failed."
    We encounter problem while installation. Run install again to set up the ddl replication.
    

    原因:ddl_install.cmd 脚本使用了 linux 命令“cp”

    解决方法:使用编辑器打开 ddl_install.cmd 脚本,将修改 “cp” 为 “copy”