ticdc 同步失败

[root@server11 ~]# cat tidb_mysql.conf

指定配置文件中涉及的库名、表名是否为大小写敏感

该配置会同时影响 filter 和 sink 相关配置,默认为 true

case-sensitive = true

是否输出 old value,从 v4.0.5 开始支持,从 v5.0 开始默认为 true

enable-old-value = true

忽略指定 start_ts 的事务

[mounter]
worker-num=4

[filter]
rules = [‘employees.','db1.’]

[root@server11 ~]# tiup cdc cli changefeed create --server=http://192.168.180.11:8300 --sink-uri=“mysql://root:123456@192.168.180.11:3306/?time-zone=Asia%2FShanghai” --changefeed-id=“tidb-to-mysql” --config /root/tidb_mysql.conf --sort-engine=“unified”
tiup is checking updates for component cdc …
Starting component cdc: /root/.tiup/components/cdc/v7.5.0/cdc cli changefeed create --server=http://192.168.180.11:8300 --sink-uri=mysql://root:123456@192.168.180.11:3306/?time-zone=Asia%2FShanghai --changefeed-id=tidb-to-mysql --config /root/tidb_mysql.conf --sort-engine=unified
Create changefeed successfully!
ID: tidb-to-mysql
Info: {“upstream_id”:7457911212182801978,“namespace”:“default”,“id”:“tidb-to-mysql”,“sink_uri”:“mysql://root:xxxxx@192.168.180.11:3306/?time-zone=Asia%2FShanghai”,“create_time”:“2025-01-10T21:26:22.433914829+08:00”,“start_ts”:455217140785217553,“config”:{“memory_quota”:1073741824,“case_sensitive”:true,“force_replicate”:false,“ignore_ineligible_table”:false,“check_gc_safe_point”:true,“enable_sync_point”:false,“bdr_mode”:false,“sync_point_interval”:600000000000,“sync_point_retention”:86400000000000,“filter”:{“rules”:[“employees.","db1.”]},“mounter”:{“worker_num”:4},“sink”:{“csv”:{“delimiter”:“,”,“quote”:“"”,“null”:“\N”,“include_commit_ts”:false,“binary_encoding_method”:“base64”},“encoder_concurrency”:32,“terminator”:“\r\n”,“date_separator”:“day”,“enable_partition_separator”:true,“enable_kafka_sink_v2”:false,“only_output_updated_columns”:false,“delete_only_output_handle_key_columns”:false,“advance_timeout”:150},“consistent”:{“level”:“none”,“max_log_size”:64,“flush_interval”:2000,“meta_flush_interval”:200,“encoding_worker_num”:16,“flush_worker_num”:8,“use_file_backend”:false},“scheduler”:{“enable_table_across_nodes”:false,“region_threshold”:100000,“write_key_threshold”:0},“integrity”:{“integrity_check_level”:“none”,“corruption_handle_level”:“warn”},“changefeed_error_stuck_duration”:1800000000000,“sql_mode”:“ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION”},“state”:“normal”,“creator_version”:“v7.5.0”,“resolved_ts”:455217140785217553,“checkpoint_ts”:455217140785217553,“checkpoint_time”:“2025-01-10 21:26:22.219”}
[root@server11 ~]# tiup cdc cli changefeed query --server=http://192.168.180.11:8300 --changefeed-id=“tidb-to-mysql”
tiup is checking updates for component cdc …
Starting component cdc: /root/.tiup/components/cdc/v7.5.0/cdc cli changefeed query --server=http://192.168.180.11:8300 --changefeed-id=tidb-to-mysql
{
“upstream_id”: 7457911212182801978,
“namespace”: “default”,
“id”: “tidb-to-mysql”,
“sink_uri”: “mysql://root:xxxxx@192.168.180.11:3306/?time-zone=Asia%2FShanghai”,
“config”: {
“memory_quota”: 1073741824,
“case_sensitive”: true,
“force_replicate”: false,
“ignore_ineligible_table”: false,
“check_gc_safe_point”: true,
“enable_sync_point”: false,
“bdr_mode”: false,
“sync_point_interval”: 600000000000,
“sync_point_retention”: 86400000000000,
“filter”: {
“rules”: [
“employees.",
"db1.

]
},
“mounter”: {
“worker_num”: 4
},
“sink”: {
“delete_only_output_handle_key_columns”: null,
“advance_timeout”: 150
},
“consistent”: {
“level”: “none”,
“max_log_size”: 64,
“flush_interval”: 2000,
“meta_flush_interval”: 200,
“encoding_worker_num”: 16,
“flush_worker_num”: 8,
“use_file_backend”: false
},
“scheduler”: {
“enable_table_across_nodes”: false,
“region_threshold”: 100000,
“write_key_threshold”: 0
},
“integrity”: {
“integrity_check_level”: “none”,
“corruption_handle_level”: “warn”
},
“changefeed_error_stuck_duration”: 1800000000000,
“sql_mode”: “ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION”
},
“create_time”: “2025-01-10 21:26:22.433”,
“start_ts”: 455217140785217553,
“resolved_ts”: 455217147928641538,
“target_ts”: 0,
“checkpoint_tso”: 455217147823783939,
“checkpoint_time”: “2025-01-10 21:26:49.069”,
“state”: “normal”,
“creator_version”: “v7.5.0”,
“task_status”: [
{
“capture_id”: “5df0defa-7858-4b66-a0c1-be29799a780e”,
“table_ids”: [
122,
110,
114
]
},
{
“capture_id”: “f55c5233-46d2-427f-a2c9-0c48754d22e9”,
“table_ids”: [
112,
116,
104
]
},
{
“capture_id”: “80bebddd-d844-40c1-b4ae-e2c3237ef881”,
“table_ids”: [
106,
108,
118
]
}
]
}
[root@server11 ~]#
为什么检查mysql 没有同步的数据库表啊

确保 MySQL 目标端的连接信息正确无误,并且 TiCDC 有权限写入数据。
你可以尝试手动连接到 MySQL 服务器,确保连接没有问题

mysql 有库名字一样,有相同表结构是前提吗

从你上面的截图没有看到所谓的报错信息?

1、cdc 侧看 checkpoint_time 是否在推进并且看到state 是nornal的话就是正常推进
2、目标端确定存在同名库,然后确认cdc里面配置连接的账号密码都正确

如果报错,最好能给出具体的错误信息才可以分析问题出现在哪里

[root@server11 ~]# cat tidb_mysql.conf

指定配置文件中涉及的库名、表名是否为大小写敏感

该配置会同时影响 filter 和 sink 相关配置,默认为 true

case-sensitive = true

是否输出 old value,从 v4.0.5 开始支持,从 v5.0 开始默认为 true

enable-old-value = true

忽略指定 start_ts 的事务

[mounter]
worker-num=4

[filter]
rules = [‘employees.*’]

[root@server11 ~]#

alter USER ‘test’@‘%’ IDENTIFIED WITH mysql_native_password BY ‘123456’;

GRANT INSERT, UPDATE, DELETE, CREATE, DROP, ALTER, LOCK TABLES ON . TO ‘test’@‘%’;
FLUSH PRIVILEGES;

tiup cdc cli changefeed remove --changefeed-id=“tidb-to-mysql” --server=http://192.168.180.11:8300

#192.168.180.12 tidb 数据同步到 192.168.180.11 上
tiup cdc cli changefeed create --server=http://192.168.180.11:8300
–sink-uri=“mysql://test:123456@192.168.180.11:3306/?time-zone=Asia%2FShanghai”
–changefeed-id=“tidb-to-mysql” --config /root/tidb_mysql.conf --sort-engine=“unified”

tiup cdc cli changefeed resume --server=http://192.168.180.11:8300 --changefeed-id=“tidb-to-mysql”

tiup cdc cli changefeed query --server=http://192.168.180.11:8300 --changefeed-id=“tidb-to-mysql”

还是不行 ,是什么问题

同步的表有主键或者唯一索引吗?没有的话需要配置force-replicate参数 https://docs.pingcap.com/zh/tidb/stable/ticdc-manage-changefeed#同步没有有效索引的表