1、mysqldump 备份并压缩输出到sql文件

    1. #编辑脚本
    2. vim backup1.sh
    3. #直接备份
    4. /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
    5. #备份压缩
    6. #/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
    7. #后台执行
    8. chmod 777 backup1.sh
    9. nohup ./backup1.sh &
    1. #编辑脚本
    2. vim backup2.sh
    3. #直接备份
    4. /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
    5. #备份压缩
    6. #/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
    7. #后台执行
    8. chmod 777 backup2.sh
    9. nohup ./backup2.sh &

    2、mysql数据恢复

    1. #登录数据库 mysql -hx.x.x.x -P33068 -uroot -pmima
    2. mysql -u root -p
    3. #如果导出的脚本有创建数据库的则不需要use数据库了
    4. mysql>use 数据库;
    5. #导入数据
    6. mysql>source /data/pool_big.sql;

    压缩备份的恢复

    1. gunzip < pool_big.sql.gz | mysql -uroot -proot databasename

    3、关闭binlog

    1. vim /etc/my.cnf
    2. 关闭,添加以下
    3. disable_log_bin
    4. systemctl restart mysqld
    5. 开启:
    6. 注释以上添加的内容