mydumper备份恢复

    mydumper优点总结:多线程备份工具,支持文件压缩功能,支持多线程恢复,保证数据的一致性,比mysqldump要快。

https://launchpad.net/mydumper/+download
yum install glib2-devel mysql-devel zlib-devel pcre-devel openssl-devel
mysql> select version();
±-----------+
| version() |
±-----------+
| 5.6.37-log |
±-----------+
备份test全库:
-bash-4.1 m y d u m p e r − u r o o t − p r o o t − S / g g / m y s q l / d a t a / m y s q l . s o c k − B t e s t − o / g g / m y s q l / b a c k u p − b a s h − 4.1 mydumper -u root -p root -S /gg/mysql/data/mysql.sock -B test -o /gg/mysql/backup -bash-4.1 mydumperurootprootS/gg/mysql/data/mysql.sockBtesto/gg/mysql/backupbash4.1 cd /gg/mysql/backup
-bash-4.1$ ll
总用量 16
-rw-rw-r-- 1 mysql mysql 174 3月 19 09:51 metadata
-rw-rw-r-- 1 mysql mysql 65 3月 19 09:51 test-schema-create.sql
-rw-rw-r-- 1 mysql mysql 154 3月 19 09:51 test.t-schema.sql
-rw-rw-r-- 1 mysql mysql 140 3月 19 09:51 test.t.sql

-bash-4.1$ cat metadata
Started dump at: 2019-03-19 09:51:16
SHOW MASTER STATUS:
Log: bin.000016
Pos: 1136
GTID:f96a00e1-f1e8-11e7-81a5-000c2957b7f4:1-3905
Finished dump at: 2019-03-19 09:51:16
-bash-4.1$ cat test-schema-create.sql
CREATE DATABASE test /!40100 DEFAULT CHARACTER SET latin1 /;
-bash-4.1$
-bash-4.1$ cat test.t-schema.sql
/
!40101 SET NAMES binary
/;
/!40014 SET FOREIGN_KEY_CHECKS=0/;
CREATE TABLE t (
id int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-bash-4.1$ cat test.t.sql
/!40101 SET NAMES binary/;
/!40014 SET FOREIGN_KEY_CHECKS=0/;
/*!40103 SET TIME_ZONE=’+00:00’ */;
INSERT INTO t VALUES
(1),
(2),
(3);
恢复数据:
myloader -u root -p root -S /gg/mysql/data/mysql.sock - B test -o t -d /gg/mysql/backup

备份单表:
mydumper -u root -p root -S /gg/mysql/data/mysql.sock -B test -T t -o /gg/mysql/backup

你可能感兴趣的:(mysql)