Percona xtrabackup 安装与使用
admin
2023-04-30 19:23:51
0次

Backup一直是数据库最重要的环节,mysql也比例外。而mysql最好的备份工具就是Percona xtrabackup和Mysql Enterprise backup(官方收费版)。


Xtrabackup中主要包含两个工具:


xtrabackup:是用于热备份innodb, xtradb表中数据的工具,不能备份其他类型的表(Myisam表),也不能备份数据表结构。

innobackupex:是将xtrabackup进行封装的perl脚本,可以备份和恢复MyISAM表以及数据表结构。

但是针对myisam的备份是需要加读锁的,多少会对线上业务影响。但是当前绝大部分Mysql用户,都是用innodb,所以,myisam只是系统表使用,锁的影响,也就可以忽略了。

一段官方文档的说明:

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. 下载软件,进入下载链接

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)

到下面网址,下载对应系统的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包到本地,然后安装,发现和现有的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. 备份与恢复测试

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已经正常工作了。


mysql备份恢复测试,请参考:

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


相关内容

热门资讯

空调连续工作多久需要停机休息 空调连续工作的时间取决于多个因素,包括空调的型号、功率、使用环境和维护情况等。一般来说,空调可以连续...
空调哪个符号是除湿的 空调除湿功能通常用一个水滴形状的符号表示。不同品牌和型号的空调遥控器可能会有所差异,但一般来说,除湿...
格力空调多长时间加一次氟利昂 1、一般情况下,空调对氟利昂的使用量是非常小的,所以在空调使用了四年左右的时候再考虑加也没问题。2、...
空调用多长时间需要加氟一次 一般情况下是五年。当出现以下这几种情况时,空调才需要加氟。1、空调的室内机和室外机各有两个接口,当接...
格调生活·C标思享荟:卡萨帝在... 9月12日的郑州龙湖金融岛,夜风轻拂,灯光璀璨。“C标时刻共传奇——卡萨帝思享荟暨20周年品牌盛典郑...
品牌价值破千亿、高端份额持续领... 9月12日,“C标时刻共传奇——卡萨帝思享荟暨20周年品牌盛典郑州站”在郑州龙湖金融岛举办。2026...
空调主板坏了修800还是换新的 空调主板坏了是修还是换新,需要考虑多个因素,以下是一些建议:1. 维修成本:如果维修费用较低,比如 ...
空调开多久需要休息多长时间 问题:空调开多久需要休息多长时间回答:1、在使用空调的过程中,一般空调开7~8个小时左右需要休息2~...
中央空调多长时间清洗一次 1、一般空调开机前清洗一次即可,空调开机中间时段再清洗一次,空调关机时清洗一次,这样比较合理。2、空...
中央空调氟利昂多久加一次 看空调制热和制冷程度,很多人的观点认为氟利昂必须一年放一次,其实这个观点是错误的,理解上面有点偏差,...