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   柴米油盐酱醋  阅读(198)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示