mydumper備份恢復

深圳gg發表於2019-03-19
    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.1mydumperurootprootS/gg/mysql/data/mysql.sockBtesto/gg/mysql/backupbash4.1mydumper -u root -p root -S /gg/mysql/data/mysql.sock -B test -o /gg/mysql/backup -bash-4.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

相關文章