xtrabackup 恢复单个表【转】
一、安裝與備份
1. 下載安裝XtraBackup
$wget?http://www.percona.com/redir/downloads/XtraBackup/LATEST/binary/tarball/percona-xtrabackup-2.2.5-5027-Linux-x86_64.tar.gz
$tar xf percona-xtrabackup-2.2.5-5027-Linux-x86_64.tar.gz
#cd percona-xtrabackup-2.2.5-Linux-x86_64/bin
#cp * /usr/bin
2. 創建XtraBackup備份用戶,只需要RELOAD, LOCK TABLES, REPLICATION CLIENT權限即可
mysql> CREATE USER??'bkpuser'@'localhost'?IDENTIFIED BY 's3cret';
Query OK, 0 rows affected (0.00 sec)
mysql> GRANT RELOAD, LOCK TABLES, REPLICATION CLIENT ON *.* TO?'bkpuser'@'localhost';
Query OK, 0 rows affected (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql> use test;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
3.建表
Database changed
mysql>? CREATE TABLE `export_test` (
??? ->??? `a` int(11) NOT NULL,
??? ->??? `b` int(11) DEFAULT NULL,
??? ->??? `c` int(11) DEFAULT NULL,
??? ->??? PRIMARY KEY (`a`),
??? ->??? UNIQUE KEY `b` (`b`)
??? ->? ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Query OK, 0 rows affected (0.01 sec)
mysql> insert into export_test values(1,3,5);
Query OK, 1 row affected (0.00 sec)
mysql> select * from export_test;
+---+------+------+
| a | b??? | c??? |
+---+------+------+
| 1 |??? 3 |??? 5 |
+---+------+------+
1 row in set (0.00 sec)
?
4.innobackupex備份
$innobackupex --defaults-file=/db/mysql5.6/my.cnf -user=bkpuser? -password=s3cret?? -socket=/db/mysql5.6/logs/mysql.sock /home/mysqlweb
?
5. 查看備份大小
$du -sh 2014-10-23_10-23-36/
402M??? 2014-10-23_10-23-36/
6.準備apply-log
apply-log前的情況
$find . -name 'export_test*'
./export_test.frm
./export_test.ibd
$innobackupex --apply-log --export /home/mysqlweb/2014-10-23_10-23-36
apply-log后,多了exp和cfg文件
$find . -name 'export*'
./export_test.frm
./export_test.ibd
./export_test.exp
./export_test.cfg
?
二、單表恢復
1.新建表export_test
mysql>? CREATE TABLE `export_test` (
??? ->???????? `a` int(11) NOT NULL,
??? ->???????? `b` int(11) DEFAULT NULL,
??? ->???????? `c` int(11) DEFAULT NULL,
??? ->???????? PRIMARY KEY (`a`),
??? ->???????? UNIQUE KEY `b` (`b`)
??? ->?????? ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Query OK, 0 rows affected (0.02 sec)
2.丟棄表空間
mysql> ALTER TABLE export_test DISCARD TABLESPACE;??????
Query OK, 0 rows affected (0.00 sec)
3.拷貝備份目錄中的ibd,cfg,exp 到mysql的datadir目錄
mysql> system cp /home/mysqlweb/2014-10-23_10-23-36/test/export_test.{ibd,exp,cfg} /db/mysql5.6/data/test
mysql> system ls /db/mysql5.6/data/test/export_test*
/db/mysql5.6/data/test/export_test.cfg? /db/mysql5.6/data/test/export_test.ibd
/db/mysql5.6/data/test/export_test.frm
4.導入表空間
mysql> ALTER TABLE export_test IMPORT TABLESPACE;
Query OK, 0 rows affected (0.01 sec)
mysql> system ls /db/mysql5.6/data/test/export_test*
/db/mysql5.6/data/test/export_test.cfg? /db/mysql5.6/data/test/export_test.ibd
/db/mysql5.6/data/test/export_test.frm
mysql> select * from export_test;
+---+------+------+
| a | b??? | c??? |
+---+------+------+
| 1 |??? 3 |??? 5 |
+---+------+------+
1 row in set (0.00 sec)
?
轉自
xtrabackup 恢復單個表 - CSDN博客
https://blog.csdn.net/lwei_998/article/details/40394339
Percona XtraBackup的部分備份與恢復/單庫備份/單表備份/指定庫備份/指定表備份 - CSDN博客
https://blog.csdn.net/zhu19774279/article/details/49681767
Partial Backups
https://www.percona.com/doc/percona-xtrabackup/2.4/innobackupex/partial_backups_innobackupex.html
Restoring Individual Tables
https://www.percona.com/doc/percona-xtrabackup/2.4/innobackupex/restoring_individual_tables_ibk.html
轉載于:https://www.cnblogs.com/paul8339/p/8821416.html
總結
以上是生活随笔為你收集整理的xtrabackup 恢复单个表【转】的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 博客园添加访问人数统计超详细教程
- 下一篇: 机器学习—SVM