日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

xtrabackup 恢复单个表【转】

發布時間:2025/4/16 编程问答 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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 恢复单个表【转】的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。