1、mysqldump 备份并压缩输出到sql文件
#编辑脚本
vim backup1.sh
#直接备份
/usr/bin/mysqldump -hdatabase-03-read.cn4lujzijsav.ap-east-1.rds.amazonaws.com -P33068 -uroot -p701Xinmima --set-gtid-purged=OFF pool_big > /data/pool_big_slave2_$(date "+%Y%m%d_%H%M%S").sql
#备份压缩
#/usr/bin/mysqldump -hdatabase-03-read.cn4lujzijsav.ap-east-1.rds.amazonaws.com -P33068 -uroot -p701Xinmima --set-gtid-purged=OFF pool_big | gzip > /data/pool_big_slave2_$(date "+%Y%m%d_%H%M%S").sql.gz
#后台执行
chmod 777 backup1.sh
nohup ./backup1.sh &
#编辑脚本
vim backup2.sh
#直接备份
/usr/bin/mysqldump -hdatabse-04-read.cn4lujzijsav.ap-east-1.rds.amazonaws.com -P33068 -uroot -p701Xinmima --set-gtid-purged=OFF pool_big > /data/pool_big_slave3_$(date "+%Y%m%d_%H%M%S").sql
#备份压缩
#/usr/bin/mysqldump -hdatabse-04-read.cn4lujzijsav.ap-east-1.rds.amazonaws.com -P33068 -uroot -p701Xinmima --set-gtid-purged=OFF pool_big | gzip > /data/pool_big_slave3_$(date "+%Y%m%d_%H%M%S").sql.gz
#后台执行
chmod 777 backup2.sh
nohup ./backup2.sh &
2、mysql数据恢复
#登录数据库 mysql -hx.x.x.x -P33068 -uroot -pmima
mysql -u root -p
#如果导出的脚本有创建数据库的则不需要use数据库了
mysql>use 数据库;
#导入数据
mysql>source /data/pool_big.sql;
压缩备份的恢复
gunzip < pool_big.sql.gz | mysql -uroot -proot databasename
3、关闭binlog
vim /etc/my.cnf
关闭,添加以下
disable_log_bin
systemctl restart mysqld
开启:
注释以上添加的内容