码迷,mamicode.com
首页 > 其他好文 > 详细

MHA主库宕机,binlog保存

时间:2020-07-28 22:48:32      阅读:107      评论:0      收藏:0      [点我收藏+]

标签:query   数据   cal   conf   pass   over   amp   base   bin   

1.配置MHA实时备份binlog

[root@db03 ~]# vim /service/mha/app1.cnf
[root@db03 ~]# vim /service/mha/app1.cnf
......
[binlog1] # 把主库的binlog日志备份到本地
no_master=1
hostname=172.16.1.53 # 主库的ip
# 不能跟当前机器数据库的binlog存放目录一样
master_binlog_dir=/root/binlog/

2.创建binlog存放目录

# 进入该目录
[root@db03 ~]# cd /root/binlog/
# 备份binlog
[root@db03 binlog]# mysqlbinlog  -R --host=172.16.1.52 --user=mha --password=mha --raw --stop-never mysql-bin.000001 &

3.手动执行备份binlog

# 进入该目录
[root@db03 ~]# cd /root/binlog/
#备份binlog
[root@db03 binlog]# mysqlbinlog  -R --host=172.16.1.52 --user=mha --password=mha --raw --stop-never mysql-bin.000001 &

4.重启MHA

[root@db03 binlog]# masterha_stop --conf=/service/mha/app1.cnf
Stopped app1 successfully.

[root@db03 binlog]# nohup masterha_manager --conf=/service/mha/app1.cnf --remove_dead_master_conf --ignore_last_failover < /dev/null > /service/mha/manager.log 2>&1 &

5.主库添加数据查看binlog

# 主库
mysql> create database mha;
Query OK, 1 row affected (0.01 sec)

[root@db02 ~]# ll /usr/local/mysql/data/mysql-bin.000008 
-rw-rw---- 1 mysql mysql 67576 Jul 28 10:33 /usr/local/mysql/data/mysql-bin.000008

# MHA机器查看binlog
[root@db03 binlog]# ll
total 96
-rw-rw---- 1 root root   852 Jul 28 10:30 mysql-bin.000001
-rw-rw---- 1 root root   214 Jul 28 10:30 mysql-bin.000002
-rw-rw---- 1 root root   214 Jul 28 10:30 mysql-bin.000003
-rw-rw---- 1 root root   214 Jul 28 10:30 mysql-bin.000004
-rw-rw---- 1 root root   465 Jul 28 10:30 mysql-bin.000005
-rw-rw---- 1 root root   214 Jul 28 10:30 mysql-bin.000006
-rw-rw---- 1 root root   214 Jul 28 10:30 mysql-bin.000007
-rw-rw---- 1 root root 67576 Jul 28 10:33 mysql-bin.000008

MHA主库宕机,binlog保存

标签:query   数据   cal   conf   pass   over   amp   base   bin   

原文地址:https://www.cnblogs.com/Applogize/p/13393824.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!