背景:从一个TiDB需要迁移数据到另外一个TiDB。
mysql -uroot -p'123456_fan' -h '10.21.108.174' -P4036
mysql -uroot -p'4rfv1az' -h '10.21.108.174' -P 4136
1 全量数据迁移:
导出全量数据
/root/tidb-toolkit-v5.4.3-linux-amd64/bin/dumpling -u root -P 4036 -p '123456_fan' -h 10.21.108.174 --filetype sql -t 4 -o /data/backup_data/ -r 200000 -F 256MiB -B sysbench_test
/root/tidb-toolkit-v5.4.3-linux-amd64/bin/tidb-lightning -config tidb-lightning.toml
cdc cli changefeed create --pd=http://10.21.108.174:2379 --sink-uri="mysql://root:4rfv&UJM@10.21.108.174:4136/" --changefeed-id="449265069501972483" --sort-engine="unified"
/root/.tiup/components/cdc/v5.3.3/cdc cli changefeed create --pd=http://10.21.108.174:2379 --sink-uri="mysql://root:4rfv&UJM@10.21.108.174:4136/" --changefeed-id="449248458749247490" --sort-engine="unified"
/root/.tiup/components/cdc/v5.3.3/cdc cli changefeed create --pd=http://10.21.108.174:2379 --sink-uri="mysql://root:4rfv&UJM@10.21.108.174:4136/" --changefeed-id="simple-replication-task" --sort-engine="unified" --start-ts=“477517256” --config=changefeed_tidb.toml
/root/.tiup/components/cdc/v5.3.3/cdc cli changefeed list --pd=http://10.21.108.174:2379
/root/.tiup/components/cdc/v5.3.3/cdc cli changefeed query -s --pd=http://10.21.108.174:2379 --changefeed-id=replication-1
/root/.tiup/components/cdc/v5.3.3/cdc cli changefeed query --pd=http://10.21.108.174:2379 --changefeed-id=replication-1
/root/.tiup/components/cdc/v5.3.3/cdc cli changefeed pause --pd=http://10.21.108.174:2379 --changefeed-id simple-replication-task
/root/.tiup/components/cdc/v5.3.3/cdc cli changefeed remove --pd=http://10.21.108.174:2379 --changefeed-id replication-1
完美:
/root/.tiup/components/cdc/v5.3.3/cdc cli changefeed create --pd=http://10.21.108.174:2379 --sink-uri="mysql://root:4rfv&UJM@10.21.108.174:4136/" --changefeed-id="replication-1" --sort-engine="unified" --start-ts=449265069501972483 --config=changefeed_tidb.toml
校验:
/root/.tiup/components/cdc/v5.3.3/cdc cli changefeed create --pd=http://10.21.108.174:2379 --sink-uri="mysql://root:4rfv&UJM@10.21.108.174:4136/" --changefeed-id="replication-1" --sort-engine="unified" --start-ts=449265069501972483 --config=changefeed_tidb.toml --sync-point=true --sync-interval=5m
SELECT * FROM tidb_cdc.syncpoint_v1 WHERE cf = 'replication-1' ORDER BY primary_ts DESC LIMIT 1;
--sync-point=true --sync-interval=5m create
--
然后按照 sync-diff-inspector 的 Datasource 配置,在上下游的 snapshot 配置项中填写相应值。
./sync_diff_inspector --config=./config_1.toml
######################### Datasource config ########################
[data-sources.uptidb]
host = "10.21.108.174"
port = 4036
user = "root"
password = ""
snapshot = "449249965710508032"
[data-sources.downtidb]
host = "10.21.108.174"
port = 4136
user = "root"
password = ""
snapshot = "449263587201122305"