TiCDC简单使用

1、将ticdc节点172.16.1.13 加入到集群中去,创建配置文件

[root@root ~]# cat scale-out.yaml
cdc_servers:
- host: 172.16.1.13
port: 8300
deploy_dir: "/tidb-deploy/cdc-8300"
log_dir: "/tidb-deploy/cdc-8300/log"

 


2、扩容集群
tiup cluster scale-out tidb-test scale-out.yaml -uroot -p

启动CDC的时候启不来,通过排查发现tz参数需要手动处理下
https://asktug.com/t/topic/35085

 

[root@mysql-4 system]# cat /tidb-deploy/cdc-8300/scripts/run_cdc.sh
#!/bin/bash
set -e

# WARNING: This file was auto-generated. Do not edit!
# All your edit might be overwritten!
DEPLOY_DIR=/tidb-deploy/cdc-8300
cd "${DEPLOY_DIR}" || exit 1
exec bin/cdc server \
--addr "0.0.0.0:8300" \
--advertise-addr "172.16.1.13:8300" \
--pd "http://172.16.1.10:2379,http://172.16.1.11:2379,http://172.16.1.12:2379" \
--tz "Asia/Shanghai" \
--data-dir="/tidb-data/cdc-8300" \
--config conf/cdc.toml \
--log-file "/tidb-deploy/cdc-8300/log/cdc.log" 2>> "/tidb-deploy/cdc-8300/log/cdc_stderr.log"

 

3、

然后正常启动 systemctl start cdc-8300.service
再查看集群状态就是ok的了

 

4、检查CDC状态

[root@root ~]# tiup ctl:v5.0.0 cdc capture list --pd=http://172.16.1.10:2379
Starting component `ctl`: /root/.tiup/components/ctl/v5.0.0/ctl cdc capture list --pd=http://172.16.1.10:2379
[
{
"id": "98235d84-8169-43da-aae2-ad9f211512a9",
"is-owner": true,
"address": "172.16.1.13:8300"
}
]

 

5、进入到CDC节点,开启同步数据

cd /tidb-deploy/cdc-8300/bin/
[root@mysql-4 bin]# ./cdc cli changefeed create --pd=http://172.16.1.10:2379 --sink-uri="mysql://root:c123456@172.16.1.10:3306/" --changefeed-id="replication-task-1" --sort-engine="unified" --tz "Asia/Shanghai"
Create changefeed successfully!
ID: replication-task-1
Info: {"sink-uri":"mysql://root:c123456@172.16.1.10:3306/","opts":{"_changefeed_id":"cli-verify"},"create-time":"2022-10-12T21:42:14.162331259+08:00","start-ts":436622362967277569,"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}},"state":"normal","history":null,"error":null,"sync-point-enabled":false,"sync-point-interval":600000000000,"creator-version":"v5.1.1"}

 

6、查询刚创建的同步任务

[root@mysql-4 bin]# ./cdc cli changefeed list --pd=http://172.16.1.10:2379
[
  {
    "id": "replication-task-1",
    "summary": {
      "state": "normal",
      "tso": 436622392825479169,
      "checkpoint": "2022-10-12 21:44:08.022",
      "error": null
    }
  }
]

 

7、此时源端写入数据,已经可以正常同步到目标端。

 

posted on 2022-10-13 11:06  柴米油盐酱醋  阅读(187)  评论(0编辑  收藏  举报

导航