创建同步任务
# tiup cdc cli changefeed create --pd="http://XX.XX.XX.XX:2379" --sink-uri="mysql://wang:Wangwang_01@XX.XX.XX.XX:3358"
fail to open MySQL connection: [CDC:ErrMySQLConnectionError]Error 1298: Unknown or incorrect time zone: 'Asia/Shanghai': Error 1298: Unknown or incorrect time zone: 'Asia/Shanghai'
执行报错,这是因为下游 MySQL 没有加载时区,可以通过 mysql_tzinfo_to_sql 命令加载时区,加载后就可以正常创建任务或同步任务。
mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql -p
登陆到TiCDC节点,在TiCDC部署目录下的bin目录中有cdc工具,执行创建任务
bin]# ./cdc cli changefeed create --pd="http://xx.xx.xx.xx:2379" --sink-uri="mysql://wang:Wangwang_01@xx.xx.xx.xx:3358"
[WARN] some tables are not eligible to replicate, []model.TableName{model.TableName{Schema:"user", Table:"hero", TableID:0, IsPartition:false}}
Could you agree to ignore those tables, and continue to replicate [Y/N]
y
Create changefeed successfully!
ID: 47b8cd74-9069-40b2-b316-12ddd9ab03e6
Info: {"sink-uri":"mysql://wang:Wangwang_01@xx.xx.xx.xx:3358","opts":{"_changefeed_id":"sink-verify"},"create-time":"2022-02-25T18:08:34.997446645+08:00","start-ts":431432325685575681,"target-ts":0,"admin-job-type":0,"sort-engine":"unified","sort-dir":"","config":{"case-sensitive":true,"enable-old-value":true,"force-replicate":false,"check-gc-safe-point":true,"filter":{"rules":["*.*"],"ignore-txn-start-ts":null},"mounter":{"worker-num":16},"sink":{"dispatchers":null,"protocol":"default"},"cyclic-replication":{"enable":false,"replica-id":0,"filter-replica-ids":null,"id-buckets":0,"sync-ddl":false},"scheduler":{"type":"table-number","polling-time":-1},"consistent":{"level":"none","max-log-size":64,"flush-interval":1000,"storage":""}},"state":"normal","history":null,"error":null,"sync-point-enabled":false,"sync-point-interval":600000000000,"creator-version":"v5.3.0"}
查看任务状态
bin]# ./cdc cli changefeed list --pd="http://XX.XX.XX.XX:2379"
[
{
"id": "18d668a0-b6fa-480b-8a79-88d64cc32aa9",
"summary": {
"state": "normal",
"tso": 431432255286804481,
"checkpoint": "2022-02-25 18:04:04.545",
"error": null
}
}
注: TiCDC只能增量同步,即指定的TSO时间内同步; 是无法全量表中的历史数据;