For larger libraries, native mysqldump export, mysql command import, this process is too long, mydumper is a multi-threaded import and export tool.
Export:
mydumper --user=user \ # 数据库用户
--password=user_password \ # 登录密码
--port=3306 \ # 端口
--host=127.0.0.1 \ # 主机地质
--threads=32 \ # 导出线程数
--compress-protocol \ # 启用压缩协议
--trx-consistency-only \ # 事务一致性
--complete-insert \ # 使用完整的包含列名的插入语句
--use-savepoints \ # 使用savepoints以降低metadata锁的影响
--chunk-filesize=256 \ # 文件块大小,单位M字节
# 或者可以使用--rows
--kill-long-queries \ # 终止长查询,默认60秒
--regex '^(?!(mysql|test|percona))' \ # 忽略的库
--events \ #
--triggers \ #
--routines \ #
--daemon \ # 后台运行
--outputdir=/data/backup/export-20180210 \ # 输出
--logfile=/data/backup/md.log # 日志
import:
myloader --user=user \ # 数据库用户
--password=user_password \ # 登录密码
--port=3306 \ # 端口
--host=127.0.0.1 \ # 主机地址
--threads=64 \ # 导入线程数
--compress-protocol \ # 启用压缩协议
--overwrite-tables \ # 覆盖原有表
--directory=/data/backup/export-20180210/0/ # 数据文件
In addition, I found a version of the go language, https://github.com/XeLabs/go-mydumper, which seems to have not been developed for a long time, and its function, performance and stability need to be further tested. The usage is basically the same, and I will write the specific usage when I have time to try it out.