Perconaxtrabackup安裝與使用

Backup一直是數(shù)據(jù)庫最重要的環(huán)節(jié),MySQL也比例外。而mysql最好的備份工具就是Percona xtrabackup和Mysql Enterprise backup(官方收費版)。

成都創(chuàng)新互聯(lián)專業(yè)為企業(yè)提供沿灘網(wǎng)站建設(shè)、沿灘做網(wǎng)站、沿灘網(wǎng)站設(shè)計、沿灘網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計與制作、沿灘企業(yè)網(wǎng)站模板建站服務(wù),十載沿灘做網(wǎng)站經(jīng)驗,不只是建網(wǎng)站,更提供有價值的思路和整體網(wǎng)絡(luò)服務(wù)。

Xtrabackup中主要包含兩個工具:

xtrabackup:是用于熱備份innodb, xtradb表中數(shù)據(jù)的工具,不能備份其他類型的表(Myisam表),也不能備份數(shù)據(jù)表結(jié)構(gòu)。

innobackupex:是將xtrabackup進(jìn)行封裝的perl腳本,可以備份和恢復(fù)MyISAM表以及數(shù)據(jù)表結(jié)構(gòu)。

但是針對myisam的備份是需要加讀鎖的,多少會對線上業(yè)務(wù)影響。但是當(dāng)前絕大部分Mysql用戶,都是用innodb,所以,myisam只是系統(tǒng)表使用,鎖的影響,也就可以忽略了。

一段官方文檔的說明:

http://www.percona.com/doc/percona-xtrabackup/2.1/manual.html

It is possible to use the xtrabackup binary alone, however, the recommend way is using it through the innobackupex wrapper script and let it execute xtrabackup for you. It might be helpful to first learn how to use innobackupex, and then learn how to use xtrabackup for having a better low-level understanding or control of the tool if needed.

這里,我們就用Percona Xtrabackup來備份Mysql。

1. 下載軟件,進(jìn)入下載鏈接

https://www.percona.com/downloads/

2. 選擇xtrabackup

Percona xtrabackup 安裝與使用Percona xtrabackup 安裝與使用

3. 選擇OS版本,下載

wget https://www.percona.com/downloads/XtraBackup/Percona-XtraBackup-2.4.11/binary/redhat/6/x86_64/percona-xtrabackup-24-2.4.11-1.el6.x86_64.rpm

Percona xtrabackup 安裝與使用

Percona xtrabackup 安裝與使用4. 安裝中可能會遇到缺少下面包的問題:

--> Processing Dependency: libev.so.4()(64bit) for package: percona-xtrabackup-24-2.4.10-1.el6.x86_64
--> Finished Dependency Resolution
Error: Package: percona-xtrabackup-24-2.4.10-1.el6.x86_64 (percona-release-x86_64)
Requires: libev.so.4()(64bit)

到下面網(wǎng)址,下載對應(yīng)系統(tǒng)的rpm包,并安裝

http://rpm.pbone.net/index.php3/stat/3/srodzaj/1/search/libev.so.4

下載

wget 
ftp://ftp.pbone.net/mirror/ftp5.gwdg.de/pub/opensuse/repositories/home:/rudi_m:/devel-snap/CentOS_CentOS-6/x86_64/libev4-4.15-7.1.x86_64.rpm

安裝

rpm -ivh 
libev4-4.15-7.1.x86_64.rpm

5. 下載rpm包到本地,然后安裝,發(fā)現(xiàn)和現(xiàn)有的mysql沖突conflicts with file from package mysql-community-server

# yum -y localinstall percona-xtrabackup-24-2.4.11-1.el6.x86_64.rpm
......
Transaction Check Error:
file /etc/my.cnf from install of Percona-Server-shared-51-5.1.73-rel14.12.625.rhel6.x86_64 conflicts with file from package mysql-community-server-5.6.39-2.el6.x86_64

6. 先安裝一個

# yum install MySQL-shared-compat*

7. 然后再次安裝,就解決沖突問題了

# yum localinstall percona-xtrabackup-24-2.4.10-1.el6.x86_64.rpm
......
Installed:
percona-xtrabackup-24.x86_64 0:2.4.10-1.el6
Dependency Installed:
perl-DBD-MySQL.x86_64 0:4.013-3.el6                            rsync.x86_64 0:3.0.6-12.el6
Complete!

8. 備份與恢復(fù)測試

innobackupex --defaults-file=/etc/my.cnf --user=root --password='password' /backup/20180423/

手動刪除文件

/mysql/help_topic.frm
rm: remove regular file `events_stages_current.frm'? y
rm: remove regular file `events_stages_history.frm'? y
rm: remove regular file `events_stages_history_long.frm'? y
rm: remove regular file `events_stages_summary_by_account_by_event_name.frm'?

9. 整合備份文件

innobackupex --defaults-file=/etc/my.cnf  --apply-log /backup/20180423/2018-04-18_00-58-36/

10. 備份還原

innobackupex --defaults-file=/etc/my.cnf  --copy-back /backup/20180423/2018-04-18_00-58-36/

可以看到,xtrabackup已經(jīng)正常工作了。

mysql備份恢復(fù)測試,請參考:

https://blog.51cto.com/hsbxxl/2107383

網(wǎng)站題目:Perconaxtrabackup安裝與使用
標(biāo)題網(wǎng)址:http://muchs.cn/article32/jephsc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供搜索引擎優(yōu)化網(wǎng)站導(dǎo)航、網(wǎng)站排名、品牌網(wǎng)站建設(shè)、微信公眾號全網(wǎng)營銷推廣

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

微信小程序開發(fā)