1.编写脚本,支持让用户自主选择,使用mysqldump还是xtraback全量备份。
[root@centosmin7 ~]# vim mysql_backup.sh
#!/bin/bash
BACKUP_DIR=/data/backup
USER=root
PASSWD=root
[ -d $BACKUP_DIR ] || mkdir $BACKUP_DIR
while true;do
cat <<EOF
Please input a number to choice you back up tool:
1.mysqldump
2.xtrabackup
3.quit
EOF
read -p "Your choose: " choose
case "$choose" in
1)
mysqldump -u$USER -p$PASSWD -A -F -E -R --single-transaction --master-data=1 --flush-privileges --triggers --default-character-set=utf8 --hex-blob > $BACKUP_DIR/fullbak_$(date +%F_%T).sql
;;
2)
innobackupex --user=$USER --password=$PASSWD $BACKUP_DIR
;;
3)
echo "Bye!" && exit 2
;;
*)
echo "Choose Error !" && exit 3
;;
esac
done
2.配置Mysql主从同步
https://www.jianshu.com/p/d46909014cf3
3.使用MHA实现Mysql高可用
https://www.jianshu.com/p/fc0682c628e5
网友评论