MySQL数据迁移TiDB卡住不动

使用dumpling导出MySQL指定表指定分区的数据后,使用tidb-lightning导入时,一直卡住。请问是什么原因导致的?具体日志如下:

[2021/08/17 12:16:18.366 +08:00] [INFO] [restore.go:1409] [“import and cleanup engine start”] [engineTag=lqcv_analysis.lqcv_distribute_speed_rpm_interval:-1] [engineUUID=3175871d-3f52-5389-8d33-42c7b87ce0c1]
[2021/08/17 12:16:18.366 +08:00] [INFO] [backend.go:327] [“import start”] [engineTag=lqcv_analysis.lqcv_distribute_speed_rpm_interval:-1] [engineUUID=3175871d-3f52-5389-8d33-42c7b87ce0c1] [retryCnt=0]
[2021/08/17 12:17:30.353 +08:00] [INFO] [restore.go:508] [progress] [files=“21/21 (100.0%)”] [tables=“0/14 (0.0%)”] [speed(MiB/s)=7.567673228192433] [state=post-processing] []
[2021/08/17 12:17:50.411 +08:00] [INFO] [backend.go:330] [“import completed”] [engineTag=lqcv_analysis.lqcv_distribute_speed_rpm_interval:-1] [engineUUID=3175871d-3f52-5389-8d33-42c7b87ce0c1] [retryCnt=0] [takeTime=1m32.044166027s] []
[2021/08/17 12:17:50.411 +08:00] [INFO] [backend.go:342] [“cleanup start”] [engineTag=lqcv_analysis.lqcv_distribute_speed_rpm_interval:-1] [engineUUID=3175871d-3f52-5389-8d33-42c7b87ce0c1]
[2021/08/17 12:17:50.776 +08:00] [INFO] [backend.go:344] [“cleanup completed”] [engineTag=lqcv_analysis.lqcv_distribute_speed_rpm_interval:-1] [engineUUID=3175871d-3f52-5389-8d33-42c7b87ce0c1] [takeTime=365.14612ms] []
[2021/08/17 12:17:50.776 +08:00] [INFO] [restore.go:1416] [“import and cleanup engine completed”] [engineTag=lqcv_analysis.lqcv_distribute_speed_rpm_interval:-1] [engineUUID=3175871d-3f52-5389-8d33-42c7b87ce0c1] [takeTime=1m32.409655916s] []
[2021/08/17 12:17:50.776 +08:00] [INFO] [tidb.go:273] [“alter table auto_increment start”] [table=lqcv_analysis.lqcv_distribute_speed_rpm_interval] [auto_increment=341567952]
[2021/08/17 12:17:54.203 +08:00] [INFO] [tidb.go:275] [“alter table auto_increment completed”] [table=lqcv_analysis.lqcv_distribute_speed_rpm_interval] [auto_increment=341567952] [takeTime=3.4270573s] []
[2021/08/17 12:17:54.204 +08:00] [INFO] [restore.go:1109] [“local checksum”] [table=lqcv_analysis.lqcv_distribute_speed_rpm_interval] [checksum="{cksum=7289430076257367577,size=14574107703,kvs=152476964}"]
[2021/08/17 12:17:54.359 +08:00] [INFO] [restore.go:1483] [“remote checksum start”] [table=lqcv_analysis.lqcv_distribute_speed_rpm_interval]
[2021/08/17 12:18:10.730 +08:00] [INFO] [restore.go:1497] [“remote checksum completed”] [table=lqcv_analysis.lqcv_distribute_speed_rpm_interval] [takeTime=16.370584186s] []
[2021/08/17 12:18:32.221 +08:00] [INFO] [restore.go:1446] [“checksum pass”] [table=lqcv_analysis.lqcv_distribute_speed_rpm_interval] [local="{cksum=7289430076257367577,size=14574107703,kvs=152476964}"]
[2021/08/17 12:18:32.222 +08:00] [INFO] [restore.go:1451] [“analyze start”] [table=lqcv_analysis.lqcv_distribute_speed_rpm_interval]
[2021/08/17 12:22:30.359 +08:00] [INFO] [restore.go:508] [progress] [files=“21/21 (100.0%)”] [tables=“0/14 (0.0%)”] [speed(MiB/s)=5.675731591520226] [state=post-processing] []
[2021/08/17 12:27:30.352 +08:00] [INFO] [restore.go:508] [progress] [files=“21/21 (100.0%)”] [tables=“0/14 (0.0%)”] [speed(MiB/s)=4.540612777774897] [state=post-processing] []
[2021/08/17 12:32:30.364 +08:00] [INFO] [restore.go:508] [progress] [files=“21/21 (100.0%)”] [tables=“0/14 (0.0%)”] [speed(MiB/s)=3.7838200135634175] [state=post-processing] []
[2021/08/17 12:37:30.355 +08:00] [INFO] [restore.go:508] [progress] [files=“21/21 (100.0%)”] [tables=“0/14 (0.0%)”] [speed(MiB/s)=3.243291278598113] [state=post-processing] []
[2021/08/17 12:42:30.354 +08:00] [INFO] [restore.go:508] [progress] [files=“21/21 (100.0%)”] [tables=“0/14 (0.0%)”] [speed(MiB/s)=2.8378809956098703] [state=post-processing] []
[2021/08/17 12:47:30.362 +08:00] [INFO] [restore.go:508] [progress] [files=“21/21 (100.0%)”] [tables=“0/14 (0.0%)”] [speed(MiB/s)=2.522553551647636] [state=post-processing] []
[2021/08/17 12:52:30.355 +08:00] [INFO] [restore.go:508] [progress] [files=“21/21 (100.0%)”] [tables=“0/14 (0.0%)”] [speed(MiB/s)=2.2703044344160492] [state=post-processing] []
[2021/08/17 12:57:30.361 +08:00] [INFO] [restore.go:508] [progress] [files=“21/21 (100.0%)”] [tables=“0/14 (0.0%)”] [speed(MiB/s)=2.0639096991516532] [state=post-processing] []
[2021/08/17 13:02:30.400 +08:00] [INFO] [restore.go:508] [progress] [files=“21/21 (100.0%)”] [tables=“0/14 (0.0%)”] [speed(MiB/s)=1.8918971830285196] [state=post-processing] []
[2021/08/17 13:07:30.354 +08:00] [INFO] [restore.go:508] [progress] [files=“21/21 (100.0%)”] [tables=“0/14 (0.0%)”] [speed(MiB/s)=1.7463892278329525] [state=post-processing] []
[2021/08/17 13:12:30.353 +08:00] [INFO] [restore.go:508] [progress] [files=“21/21 (100.0%)”] [tables=“0/14 (0.0%)”] [speed(MiB/s)=1.6216478064396633] [state=post-processing] []
[2021/08/17 13:17:30.351 +08:00] [INFO] [restore.go:508] [progress] [files=“21/21 (100.0%)”] [tables=“0/14 (0.0%)”] [speed(MiB/s)=1.5135383613189966] [state=post-processing] []
[2021/08/17 13:22:30.353 +08:00] [INFO] [restore.go:508] [progress] [files=“21/21 (100.0%)”] [tables=“0/14 (0.0%)”] [speed(MiB/s)=1.418941717402689] [state=post-processing] []
[2021/08/17 13:27:30.354 +08:00] [INFO] [restore.go:508] [progress] [files=“21/21 (100.0%)”] [tables=“0/14 (0.0%)”] [speed(MiB/s)=1.335474395955742] [state=post-processing] []
[2021/08/17 13:32:30.356 +08:00] [INFO] [restore.go:508] [progress] [files=“21/21 (100.0%)”] [tables=“0/14 (0.0%)”] [speed(MiB/s)=1.2612809606678184] [state=post-processing] []
[2021/08/17 13:37:30.470 +08:00] [INFO] [restore.go:508] [progress] [files=“21/21 (100.0%)”] [tables=“0/14 (0.0%)”] [speed(MiB/s)=1.194873790149806] [state=post-processing] []
[2021/08/17 13:42:30.354 +08:00] [INFO] [restore.go:508] [progress] [files=“21/21 (100.0%)”] [tables=“0/14 (0.0%)”] [speed(MiB/s)=1.1351533580336057] [state=post-processing] []
[2021/08/17 13:47:30.354 +08:00] [INFO] [restore.go:508] [progress] [files=“21/21 (100.0%)”] [tables=“0/14 (0.0%)”] [speed(MiB/s)=1.0810984840998163] [state=post-processing] []
[2021/08/17 13:52:30.353 +08:00] [INFO] [restore.go:508] [progress] [files=“21/21 (100.0%)”] [tables=“0/14 (0.0%)”] [speed(MiB/s)=1.0319577400862627] [state=post-processing] []
[2021/08/17 13:57:30.353 +08:00] [INFO] [restore.go:508] [progress] [files=“21/21 (100.0%)”] [tables=“0/14 (0.0%)”] [speed(MiB/s)=0.9870900320004632] [state=post-processing]

1 个赞

请问 tidb-lightning 和 下游 tidb 版本是多少?麻烦提供下 tidb-lightning 的配置文件。

1 个赞

speed 好慢啊 公网导入的么

1 个赞

4.0.4
[lightning]

日志

level = “info”
file = “tidb-lightning.log”

[tikv-importer]

tikv-importer 的监听地址,需改成 tikv-importer 服务器的实际地址。

addr = “172.16.11.81:8287”

[mydumper]

Mydumper 源数据目录。

data-source-dir = “/opt/sql/202103/3”

[tidb]

目标集群的信息。tidb-server 的监听地址,填一个即可。

host = “172.16.11.75”
port = 4000
user = “root”
password = xxxx"

表架构信息在从 TiDB 的“状态端口”获取。

status-port = 10080

[checkpoint]

enable = false
dsn = “/tmp/tidb_lightning_checkpoint.pb”

还有一个问题想顺便问下,我按照官网的文档,指定输出文件大小为256MB,但是输出的文件是328MB一个。
./dumpling -h 10.0.11.3 -uroot -p xxx -P 3306 --filetype sql --filesize 256MiB -T lqcv_analysis.lqcv_behavior_breakdown_data -o /data1/analysis/

备注:上游数据mysql,使用dumping导出10G数据 耗时约5分钟,下游数据tidb,导入 数据超过2小时。。。

1 个赞

mysql版本5.7.31 (腾讯云主机 磁盘IO 350M)
tidb版本 v4.0.0 (公司内网 OpenStack虚拟机)
dumping和lightning 版本 4.0.4

单表约110G,做了分区,导出的分区大概6G

集群和 Lightning 工具版本过旧,建议将集群升级到最新版本后再测试下,另外 lightning 和 tikv 对磁盘性能均有一定要求,最好为 SSD 盘,如果不满足要求的话可以考虑使用 lightning 的 tidb-backend 模式

就是用的backend。。
是因为版本问题,才导致速度慢吗?
我们是打算把腾讯云MySQL一个库的数据迁移到tidb(大约220G),
云主机MySQL 磁盘IO是350MB,TIDB准备买600MB的增强型SSD
目前在公司openstack虚拟机上测试,导入速度极慢……

只是说新版本会更稳定点,导入速度慢感觉是你虚拟机的磁盘性能不行

index-concurrency = 2
table-concurrency = 6
io-concurrency = 5

我没有配置并发数,调整这些配置会不会有效果?

把MySQL数据导出,导入TiDB,要不要制定文件大小为256MB?

如果磁盘性能很差的话,调整这些参数的作用估计也不会很大,另外导入的时候不需要指定文件大小。

请问,我备份的之后指定了文件大小为256M,但是为什么备份出来的却是300多M
./dumpling -h 10.0.11.3 -uroot -p xxx -P 3306 -t 16 -F 256m -T lqcv_analysis.lqcv_distribute_speed_rpm_interval --where “stat_day >= 20210301 and stat_day <= 20210330” -o /data1/202103/

请问 dumpling 和 集群的版本是一致的吗?如果不一致的话可以调整为一致后再试下。

我是从MySQL导出数据。。

忘了上游是 MySQL :sweat_smile: 我再确认下

你可以试下新版本的 dumpling ,老版本选项 “-F” 控制的不是很准确。

5.0版本吗?控制文件大小,对数据的恢复速度有影响吗?
集群版本是4.0.0的dumping版本4.0.4

v4.0.0 集群的版本太旧了,而且相关的 bug 也比较多,强烈建议先升级到 v4.0.14 ,方便的话也可以考虑使用 v5.1.1 最新版本;另外感觉你的虚机磁盘性能很差,测试性能的话请换成 SSD 磁盘

4.0.0和4.0.14之间差别大吗,我们之前安装好像默认就是4.0.0,而且用的这个版本对接的jjava程序