1.22支持,实验功能,用于数据追平
    使用前请使用下面语句检查涉及的数据源连接mysql开启binlog,而且是row格式,需要开启GTID
    同步的表要求有主键

    1. SHOW VARIABLES LIKE 'log_bin'

    清理BINLOG同步任务

    1. /*+ mycat:BINLOG_CLEAR{
    2. } */;

    记录所有数据源的binlog文件以及位置并显示出来

    1. /*+ mycat:BINLOG_SNAPSHOT{
    2. "name":"testBinlogSnapshot"
    3. } */;

    testBinlogSnapshot:用于区分快照,该信息会被记录到mycat.ds_binlog表

    1. CREATE TABLE `ds_binlog` (
    2. `Id` text,
    3. `Name` text,
    4. `Datasource` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci,
    5. `File` text,
    6. `Position` bigint(20) DEFAULT NULL,
    7. `Binlog_Ignore_DB` text,
    8. `Binlog_Do_DB` text,
    9. `Executed_Gtid_Set` text,
    10. `CreateDatetime` datetime DEFAULT NULL
    11. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci

    binlog同步

    1. /*+ mycat:BINLOG_SYNC{
    2. "connectTimeout":0,//binlog连接超时时间
    3. "inputTableNames":[
    4. "db1.travelrecord_input"
    5. ],
    6. "name":"test0",
    7. "outputTableNames":[
    8. "db1.travelrecord_output"
    9. ]
    10. } */;

    把逻辑表db1.travelrecord_input的binlog变成SQL语句,并应用到到逻辑表db1.travelrecord_output

    使用snapshotId查询mycat.ds_binlog得到快照信息,然后使用它的binlog文件和位置开始同步

    1. /*+ mycat:BINLOG_SYNC{
    2. "connectTimeout":0,
    3. "inputTableNames":[
    4. "db1.travelrecord_input"
    5. ],
    6. "name":"testBinlogGlobalToNormal",
    7. "outputTableNames":[
    8. "db1.travelrecord_output"
    9. ],
    10. "snapshotId":"94516452-6151-433c-8890-071e43f618e0"
    11. } */;

    停止binlog同步

    1. /*+ mycat:BINLOG_STOP{
    2. "id":"ae1b8375-3e60-4152-be98-3792a59c5609"
    3. } */;

    列出binlog同步任务

    1. /*+ mycat:BINLOG_LIST{
    2. } */;