mydumper是针对mysql数据库备份的一个轻量级第三方的开源工具,备份方式为逻辑备份。它支持多线程,备份速度远高于原生态的mysqldump以及众多优异特性。与其相配套的恢复工具则是myloader,主要用于将dump出来的sql以并行的方式进行恢复。本文主要描述myloader的使用方法并给出示例。
myloader还原恢复详解
1、单库的备份与恢复
首先需要备份的数据库:
详见:
1、备份test数据库:
mydumper -u root -p jsb -B test -0 /mydumper/
找到你的mydumper备份集
2、还原test数据库:
myloader -u root -p jsb -B test -d /mydumper
3、备份表
mkdir /mysql/dumper/table -p
mydumper -u root -p jsb -B test -T jsb2 -o /mysql/dumper/table
还原表(只能使用soure):
mysql -uroot -pjsb
mysql> source test.jsb2-schema.sql 还原对象表
mysql> source test.jsb2.sql 还原数据表
4、数据库被全部删除,数据库实例被全部删除。
首先进行全备份,找到你的全部备份集。
mkdir /mysql/dumper/full
mydumper -u root -p jsb -o /mysql/dumper/full/
全部恢复:
myloader -u root -p jsb -v 3 -o -d /mysql/dumper/full
赠送:
myloader帮助:[root@app ~]# myloader --help
Usage:
myloader [OPTION...] multi-threaded MySQL loader
Help Options:
-?, --help Show help options
Application Options:
-d, --directory Directory of the dump to import
-q, --queries-per-transaction Number of queries per transaction, default 1000
还原期间每个事务insert的数目,缺省是1k
-o, --overwrite-tables Drop tables if they already exist(表存在即覆盖)
-B, --database An alternative database to restore into
-e, --enable-binlog Enable binary logging of the restore data
-h, --host The host to connect to
-u, --user Username with privileges to run the dump
-p, --password User password
-P, --port TCP/IP port to connect to
-S, --socket UNIX domain socket file to use for connection
-t, --threads Number of threads to use, default 4
-C, --compress-protocol Use compression on the MySQL connection
-V, --version Show the program version and exit
-v, --verbose Verbosity of output, 0 = silent, 1 = errors, 2 = warnings, 3 = info, default2
参考:
http://blog.csdn.net/leshami/article/details/46817937