当前位置:网站首页>TiCDC Migration - TiDB to MySQL Test
TiCDC Migration - TiDB to MySQL Test
2022-07-29 12:19:00 【InfoQ】
1、前言
2、信息
3、部署 TiCDC
vim add.yml
cdc_servers:
- host: 10.1.1.1
port: 777
deploy_dir: /opt/tidb666/deploy/cdc-777
data_dir: /opt/tidb666/data/cdc-777
log_dir: /opt/tidb666/log/cdc-777
- host: 10.1.1.2
port: 777
deploy_dir: /opt/tidb666/deploy/cdc-777
data_dir: /opt/tidb666/data/cdc-777
log_dir: /opt/tidb666/log/cdc-777
- host: 10.1.1.3
port: 777
deploy_dir: /opt/tidb666/deploy/cdc-777
data_dir: /opt/tidb666/data/cdc-777
log_dir: /opt/tidb666/log/cdc-777
tiup cluster scale-out 666_TEST add.yml
4、导出数据
cd tidb-toolkit-v5.2.2-linux-amd64/bin
./dumpling -udba -pxxx -h10.x.x.x -P666 --status-addr 999 -F 64MiB -t 2 -o 666_dump -B dba_test >> 666_dump_log
[tidb() bin]$ ll 666_dump/
total 24
-rw-rw-r-- 1 tidb tidb 146 Jul 24 11:34 metadata
-rw-rw-r-- 1 tidb tidb 109 Jul 24 11:34 dba_test-schema-create.sql
-rw-rw-r-- 1 tidb tidb 112 Jul 24 11:34 dba_test.test.000000000.sql
-rw-rw-r-- 1 tidb tidb 66 Jul 24 11:34 dba_test.test2.000000000.sql
-rw-rw-r-- 1 tidb tidb 266 Jul 24 11:34 dba_test.test2-schema.sql
-rw-rw-r-- 1 tidb tidb 265 Jul 24 11:34 dba_test.test-schema.sql
cat metadata
Started dump at: 2022-07-24 11:34:31
SHOW MASTER STATUS:
Log: tidb-binlog
Pos: 434800865229668357
GTID:
Finished dump at: 2022-07-24 11:34:31
(dba:666)@[(none)]>use dba_test
Database changed
(dba:666)@[dba_test]>show tables;
+------------------------------+
| Tables_in_dba_test |
+------------------------------+
| test |
| test2 |
+------------------------------+
2 rows in set (0.00 sec)
(dba:666)@[dba_test]>select * from test;
+----+------+
| id | name |
+----+------+
| 1 | aa |
| 33 | ccc |
| 44 | ddd |
| 55 | eee |
| 66 | ff |
+----+------+
5 rows in set (0.00 sec)
(dba:666)@[dba_test]>insert into test values (77,'gg');
Query OK, 1 row affected (0.01 sec)
(dba:666)@[dba_test]>insert into test values (88,'re');
Query OK, 1 row affected (0.00 sec)
(dba:666)@[dba_test]>select * from test;
+----+------+
| id | name |
+----+------+
| 1 | aa |
| 33 | ccc |
| 44 | ddd |
| 55 | eee |
| 66 | ff |
| 77 | gg |
| 88 | re |
+----+------+
7 rows in set (0.00 sec)
5、MySQL 导入数据
5.1、Copy the exported backup to MySQL The machine of the master instance
scp -r 666_dump 10.5.5.5:/data/
5.2、执行导入
ssh The master instance machine
登录mysql
([email protected](none))>show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| sys |
| performance_schema |
+--------------------+
9 rows in set (0.00 sec)
([email protected](none))>source /data/666_dump/dba_test-schema-create.sql
Query OK, 0 rows affected (0.00 sec)
Query OK, 1 row affected (0.00 sec)
([email protected](none))>show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| dba_test |
+--------------------+
10 rows in set (0.00 sec)
([email protected](none))>use dba_test
Database changed
([email protected]_test)>source /data/666_dump/dba_test.test2-schema.sql
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
([email protected]_test)>source /data/666_dump/dba_test.test-schema.sql
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
([email protected]_test)>show tables;
+------------------------------+
| Tables_in_dba_test |
+------------------------------+
| test |
| test2 |
+------------------------------+
2 rows in set (0.00 sec)
([email protected]_test)>select * from test;
Empty set (0.00 sec)
([email protected]_test)>select * from test2;
Empty set (0.00 sec)
([email protected]_test)>source /data/666_dump/dba_test.test.000000000.sql
Query OK, 0 rows affected (0.00 sec)
Query OK, 5 rows affected (0.00 sec)
Records: 5 Duplicates: 0 Warnings: 0
([email protected]_test)>source /data/666_dump/dba_test.test2.000000000.sql
Query OK, 0 rows affected (0.00 sec)
Query OK, 1 row affected (0.00 sec)
([email protected]_test)>select * from test;
+----+------+
| id | name |
+----+------+
| 1 | aa |
| 33 | ccc |
| 44 | ddd |
| 55 | eee |
| 66 | ff |
+----+------+
5 rows in set (0.00 sec)
([email protected]_test)>select * from test2;
+----+------+
| id | name |
+----+------+
| 2 | bb |
+----+------+
1 row in set (0.00 sec)
6、实时同步
ssh 10.4.4.4
[root()@name-2-2 ~]# su - tidb
Last login: Sun Jul 24 11:28:38 CST 2022 on pts/0
[tidb()@name-2-2 ~]$ tiup ctl:v5.2.2 cdc capture list --pd=http://10.3.3.3:678
Starting component `ctl`: /home/tidb/.tiup/components/ctl/v5.2.2/ctl cdc capture list --pd=http://10.3.3.3:678
[
{
"id": "42492be0-dd2b-49da-9562-86ba5feff288",
"is-owner": false,
"address": "10.1.1.1:567"
},
{
"id": "5543f93e-e0c8-4e91-a468-88362454b958",
"is-owner": false,
"address": "10.1.1.2:567"
},
{
"id": "6688a5c7-0779-487e-86f6-46b068743652",
"is-owner": true,
"address": "10.1.1.3:567"
}
]
[tidb()@name-2-2 666_ticdc]$ cd /data/tidb/666_ticdc
[tidb()@name-2-2 666_ticdc]$ cat 666_888_ticdc_config.toml
case-sensitive = true
enable-old-value = true
[filter]
rules = ['dba_test.*']
[mounter]
worker-num = 8
【创建同步任务】:
[tidb()@name-2-2 666_ticdc]$ tiup ctl:v5.2.2 cdc changefeed create --pd=http://10.3.3.3:678 --sink-uri="mysql://dba:[email protected]:888/?worker-count=16&max-txn-row=5000&time-zone=SYSTEM" --changefeed-id="666-888-20220724-task" --sort-engine="unified" --start-ts=434800865229668357 --config 666_888_ticdc_config.toml
Starting component `ctl`: /home/tidb/.tiup/components/ctl/v5.2.2/ctl cdc changefeed create --pd=http://10.3.3.3:678 --sink-uri=mysql://dba:[email protected]:888/?worker-count=16&max-txn-row=5000&time-zone=SYSTEM --changefeed-id=666-888-20220724-task --sort-engine=unified --start-ts=434800865229668357 --config 666_888_ticdc_config.toml
Create changefeed successfully!
ID: 666-888-20220724-task
Info: {"sink-uri":"mysql://dba:[email protected]:888/?worker-count=16\u0026max-txn-row=5000\u0026time-zone=SYSTEM","opts":{"_changefeed_id":"cli-verify"},"create-time":"2022-07-24T12:20:45.606052447+08:00","start-ts":434800865229668357,"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":["dba_test.*"],"ignore-txn-start-ts":null},"mounter":{"worker-num":8},"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.2.2"}
【查看所有任务】:
tiup ctl:v5.2.2 cdc changefeed list --pd=http://10.3.3.3:678
[tidb()@name-2-2 666_ticdc]$ tiup ctl:v5.2.2 cdc changefeed list --pd=http://10.3.3.3:678
Starting component `ctl`: /home/tidb/.tiup/components/ctl/v5.2.2/ctl cdc changefeed list --pd=http://10.3.3.3:678
[
{
"id": "666-888-20220724-task",
"summary": {
"state": "normal",
"tso": 434801605865111553,
"checkpoint": "2022-07-24 12:21:36.983",
"error": null
}
}
]
【View assigned tasks】:
[tidb()@name-2-2 666_ticdc]$ tiup ctl:v5.2.2 cdc changefeed query -s --pd=http://10.3.3.3:678 --changefeed-id=666-888-20220724-task
Starting component `ctl`: /home/tidb/.tiup/components/ctl/v5.2.2/ctl cdc changefeed query -s --pd=http://10.3.3.3:678 --changefeed-id=666-888-20220724-task
{
"state": "normal",
"tso": 434801616101834753,
"checkpoint": "2022-07-24 12:22:16.033",
"error": null
}
【View task details信息】:[tidb()@name-2-2 666_ticdc]$ tiup ctl:v5.2.2 cdc changefeed query --pd=http://10.3.3.3:678 --changefeed-id=666-888-20220724-task
Starting component `ctl`: /home/tidb/.tiup/components/ctl/v5.2.2/ctl cdc changefeed query --pd=http://10.3.3.3:678 --changefeed-id=666-888-20220724-task
{
"info": {
"sink-uri": "mysql://dba:[email protected]:888/?worker-count=16\u0026max-txn-row=5000\u0026time-zone=SYSTEM",
"opts": {
"_changefeed_id": "cli-verify"
},
"create-time": "2022-07-24T12:20:45.606052447+08:00",
"start-ts": 434800865229668357,
"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": [
"dba_test.*"
],
"ignore-txn-start-ts": null
},
"mounter": {
"worker-num": 8
},
"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.2.2"
},
"status": {
"resolved-ts": 434801631581437953,
"checkpoint-ts": 434801631581437953,
"admin-job-type": 0
},
"count": 0,
"task-status": [
{
"capture-id": "42492be0-dd2b-49da-9562-86ba5feff288",
"status": {
"tables": null,
"operation": null,
"admin-job-type": 0
}
},
{
"capture-id": "5543f93e-e0c8-4e91-a468-88362454b958",
"status": {
"tables": {
"878": {
"start-ts": 434800865229668357,
"mark-table-id": 0
}
},
"operation": {},
"admin-job-type": 0
}
},
{
"capture-id": "6688a5c7-0779-487e-86f6-46b068743652",
"status": {
"tables": {
"880": {
"start-ts": 434800865229668357,
"mark-table-id": 0
}
},
"operation": {},
"admin-job-type": 0
}
}
]
}
([email protected]_test)>select * from test;
+----+------+
| id | name |
+----+------+
| 1 | aa |
| 33 | ccc |
| 44 | ddd |
| 55 | eee |
| 66 | ff |
| 77 | gg |
| 88 | re |
+----+------+
7 rows in set (0.00 sec)
【TiDB666-1】:写入数据
(dba:666)@[dba_test]>insert into test values (99,'we');
Query OK, 1 row affected (0.00 sec)
(dba:666)@[dba_test]>select * from test;
+----+------+
| id | name |
+----+------+
| 1 | aa |
| 33 | ccc |
| 44 | ddd |
| 55 | eee |
| 66 | ff |
| 77 | gg |
| 88 | re |
| 99 | we |
+----+------+
8 rows in set (0.00 sec)
【MySQL888-1】:查看数据
([email protected]_test)>select * from test;
+----+------+
| id | name |
+----+------+
| 1 | aa |
| 33 | ccc |
| 44 | ddd |
| 55 | eee |
| 66 | ff |
| 77 | gg |
| 88 | re |
| 99 | we |
+----+------+
8 rows in set (0.00 sec)
综上:同步正常
【TiDB666-1】:dba_test2 库写入数据
(dba:666)@[dba_test]>use dba_test2
Database changed
(dba:666)@[dba_test2]>show tables;
+-------------------------+
| Tables_in_dba_test2 |
+-------------------------+
| tb_test |
+-------------------------+
1 row in set (0.00 sec)
(dba:666)@[dba_test2]>select * from tb_test;
+----+------+------------+
| id | age | statDate |
+----+------+------------+
| 1 | 2 | 2021-12-22 |
| 2 | 2 | 2021-12-22 |
+----+------+------------+
2 rows in set (0.00 sec)
(dba:666)@[dba_test2]>insert into tb_test values (3,1,'2022-07-24');
Query OK, 1 row affected (0.00 sec)
(dba:666)@[dba_test2]>select * from tb_test;
+----+------+------------+
| id | age | statDate |
+----+------+------------+
| 1 | 2 | 2021-12-22 |
| 2 | 2 | 2021-12-22 |
| 3 | 1 | 2022-07-24 |
+----+------+------------+
3 rows in set (0.00 sec)
(dba:666)@[dba_test2]>use dba_test
Database changed
(dba:666)@[dba_test]>insert into test values (100,'ee');
Query OK, 1 row affected (0.00 sec)
【MySQL888-1】:查看同步
([email protected]_test)>select * from test;
+-----+------+
| id | name |
+-----+------+
| 1 | aa |
| 33 | ccc |
| 44 | ddd |
| 55 | eee |
| 66 | ff |
| 77 | gg |
| 88 | re |
| 99 | we |
| 100 | ee |
+-----+------+
9 rows in set (0.00 sec)
综上:Explain library filteringok
[tidb()@name-2-2 666_ticdc]$ tiup ctl:v5.2.2 cdc changefeed remove --pd=http://10.3.3.3:678 --changefeed-id 666-888-20220724-task
Starting component `ctl`: /home/tidb/.tiup/components/ctl/v5.2.2/ctl cdc changefeed remove --pd=http://10.3.3.3:678 --changefeed-id 666-888-20220724-task
[tidb()@name-2-2 666_ticdc]$ tiup ctl:v5.2.2 cdc changefeed query --pd=http://10.3.3.3:678 --changefeed-id=666-888-20220724-task
Starting component `ctl`: /home/tidb/.tiup/components/ctl/v5.2.2/ctl cdc changefeed query --pd=http://10.3.3.3:678 --changefeed-id=666-888-20220724-task
[2022/07/24 12:29:30.408 +08:00] [WARN] [cli_changefeed_query.go:100] ["This changefeed has been deleted, the residual meta data will be completely deleted within 24 hours."] [changgefeed=666-888-20220724-task]
[2022/07/24 12:29:30.409 +08:00] [ERROR] [cli_changefeed_query.go:109] ["This changefeed does not exist"] [changefeed=666-888-20220724-task]
Error: [CDC:ErrChangeFeedNotExists]changefeed not exists, key: /tidb/cdc/job/666-888-20220724-task
Usage:
cdc cli changefeed query [flags]
Flags:
-c, --changefeed-id string Replication task (changefeed) ID
-h, --help help for query
-s, --simple Output simplified replication status
Global Flags:
--ca string CA certificate path for TLS connection
--cert string Certificate path for TLS connection
-i, --interact Run cdc cli with readline
--key string Private key path for TLS connection
--log-level string log level (etc: debug|info|warn|error) (default "warn")
--pd string PD address, use ',' to separate multiple PDs (default "http://127.0.0.1:2379")
[CDC:ErrChangeFeedNotExists]changefeed not exists, key: /tidb/cdc/job/666-888-20220724-task
Error: exit status 1
Error: run `/home/tidb/.tiup/components/ctl/v5.2.2/ctl` (wd:/home/tidb/.tiup/data/TCTXh8X) failed: exit status 1
[tidb()@name-2-2 666_ticdc]$ tiup ctl:v5.2.2 cdc changefeed query -s --pd=http://10.3.3.3:678 --changefeed-id=666-888-20220724-task
Starting component `ctl`: /home/tidb/.tiup/components/ctl/v5.2.2/ctl cdc changefeed query -s --pd=http://10.3.3.3:678 --changefeed-id=666-888-20220724-task
{
"state": "",
"tso": 0,
"checkpoint": "",
"error": null
}
边栏推荐
- 【一起学Rust | 基础篇】Rust基础——变量和数据类型
- 我和 TiDB 的故事 | TiDB 对我不离不弃,我亦如此
- Wu En teacher machine learning course notes 6 logistic regression
- 网络层和传输层限制
- Recursion - Eight Queens Problem
- 公司出了一款新产品,要不要招代理商?
- WordPress 主题和插件
- DAY 25 daily SQL clock 】 【 丨 different sex daily score a total difficulty moderate 】 【
- 2.1冒泡排序(Bubble Sorting)
- How is the JVM memory model allocated?
猜你喜欢

【第三次自考】——总结

峰米V10、极米Rs Pro2及当贝X3 Pro究竟孰优孰劣?

GDB使用详解

爱可可AI前沿推介(7.29)

TiFlash 源码阅读(五) DeltaTree 存储引擎设计及实现分析 - Part 2

我和 TiDB 的故事 | 缘份在,那就终是能相遇的

国内首秀元宇宙Live House圆满收官,百事可乐虚拟偶像真的好会!!

Kubernetes基本概念

Paddle frame experience evaluation and exchange meeting, the use experience of the product is up to you!

MarkDown Advanced Syntax Manual
随机推荐
报表查询字段集sql摘记
DAY 25 daily SQL clock 】 【 丨 different sex daily score a total difficulty moderate 】 【
WPF 截图控件之绘制方框与椭圆(四) 「仿微信」
2.2选择排序
Pangolin库链接库问题
shell if else 使用
公司出了一款新产品,要不要招代理商?
Distributed Configuration Center of Infrastructure
金仓数据库KingbaseES客户端编程接口指南-ODBC(9. 疑难解答)
最简单的共享列表服务器KissLists
宝塔快速搭建自适应咖啡网站模板与管理系统源码实测
TiDB升级与案例分享(TiDB v4.0.1 → v5.4.1)
365 days challenge LeetCode1000 topic - Day 043 square mathematics effectively
网络层和传输层限制
WordPress 重置密码
峰米V10、极米Rs Pro2及当贝X3 Pro究竟孰优孰劣?
Codeforces Round #797 (Div. 3)个人题解
【每日SQL打卡】DAY 27丨列出指定时间段内所有的下单产品【难度简单】
第十章 发现和记录 REST API
Js array commonly used API