限制备份速度防止网卡打满

限制备份速度防止网卡打满

最近在做拆库, 于是就做了很多表迁移工作, 需要使用mysqldump远程备份数据, 然后发现备份时很容易就把源库网卡打满了. 想过用tc命令限速, 发现有点复杂. 今天无意间看xtrabackup文档发现一个方法

Throttling the throughput to 10MB/sec. This requires the ‘pv’ tools; you can find them at the official site or install it from the distribution package (“apt-get install pv”)

1
2
$ innobackupex --stream=tar ./ | pv -q -L10m \
| ssh user@desthost "cat - > /data/backups/backup.tar"

Make a Streaming Backup
https://www.percona.com/doc/percona-xtrabackup/2.4/howtos/recipes_ibkx_stream.html

查看pv的介绍, 主要是辅助查看一些进度 progressbar ETA什么的:

在google搜索mysqldump pv 基本也是些查看进度的文章

http://landcareweb.com/questions/6489/you-mei-you-ban-fa-rang-mysqldumpjin-du-tiao-xian-shi-yong-hu-de-bei-fen-zhuang-tai
https://www.2cto.com/database/201310/248423.html
https://stackoverflow.com/questions/4852933/does-mysqldump-support-a-progress-bar

我们这里主要目的是限速, 照猫画虎, 可以这样实现

导出限速

1
mysqldump | pv -q -L10m > xx.sql

限速导入

1
cat xx.sql | pv -q -L10m | mysql

导入查看进度

1
pv xx.sql | mysql

Powered by Hexo and Hexo-theme-hiker

Copyright © 2013 - 2019 Fan() All Rights Reserved.

访客数 : | 访问量 :

#