由於之前服務器安裝的xtrabackup比較老的版本,不支持mysql 5.7的熱備,需要升級下版本或新服務器部署2.4.1版本。這裡我們下載官網https://www.percona.com/downloads/XtraBackup/ 最新版2.4.4 工具,安裝並備份mysql 5.7。
一,安裝XtraBackup。這裡不多做解釋了,之前文章有介紹如何安裝。 這裡主要說下常見報錯,比如我這裡今天遇到兩個:
error: Failed dependencies:
libev.so.4()(64bit) is needed by percona-xtrabackup-24-2.4.4-1.el6.x86_64
libnuma.so.1()(64bit) is needed by percona-xtrabackup-24-2.4.4-1.el6.x86_64
(1) libev.so.4()(64bit) is needed by percona-xtrabackup-24-2.4.4-1..el6.x86_64解決辦法:
rpm -ivh ftp://rpmfind.net/linux/dag/redhat/el6/en/x86_64/dag/RPMS/libev-4.15-1.el6.rf.x86_64.rpm
安裝上邊rpm包解決
(2)libnuma.so.1()(64bit) is needed by percona-xtrabackup-24-2.4.4-1.el6.x86_64解決辦法:
rpm -ivh http://mirror.centos.org/centos/6/os/x86_64/Packages/numactl-2.0.9-2.el6.x86_64.rpm
安裝上邊rpm包解決。
二,備份mysql 。這裡我們寫一個shell腳本做備份
#!/bin/bash
# mysql full back
#date 2016.10.18
#author:21yunwei
time=`date +%F`
logfile="/data/bakup/mysql_full_bak_time.log"
fullbakup_logfile="/data/bakup/fullbakup_logfile.log"
mysql_bakdir="/data/bakup"
user=xxxxx
password=xxxxxxx
[ ! -d $mysql_bakdir ] && mkdir -p $mysql_bakdir
[ ! -e $logfile ] && touch $logfile
[ ! -e $fullbakup_logfile ] && touch $fullbakup_logfile
innobackupex --defaults-file=/etc/my.cnf --user=$user --password=$passsword--compress ${mysql_bakdir} 2>&1 >>$fullbakup_logfile
ret=$?
finishtime=`date +%Y%m%d_%H%M%S`
[ $ret -eq 0 ] && echo "Mysql fullbakup finished, time: $finishtime" >> $logfile || echo "Mysql fullbakup failed,please check time:$finishtime" >> $logfile