elitechen 2020-07-28
[ ~]# vim /service/mha/app1.cnf [ ~]# vim /service/mha/app1.cnf ...... [binlog1] # 把主库的binlog日志备份到本地 no_master=1 hostname=172.16.1.53 # 主库的ip # 不能跟当前机器数据库的binlog存放目录一样 master_binlog_dir=/root/binlog/
# 进入该目录 [ ~]# cd /root/binlog/ # 备份binlog [ binlog]# mysqlbinlog -R --host=172.16.1.52 --user=mha --password=mha --raw --stop-never mysql-bin.000001 &
# 进入该目录 [ ~]# cd /root/binlog/ #备份binlog [ binlog]# mysqlbinlog -R --host=172.16.1.52 --user=mha --password=mha --raw --stop-never mysql-bin.000001 &
[ binlog]# masterha_stop --conf=/service/mha/app1.cnf Stopped app1 successfully. [ binlog]# nohup masterha_manager --conf=/service/mha/app1.cnf --remove_dead_master_conf --ignore_last_failover < /dev/null > /service/mha/manager.log 2>&1 &
# 主库 mysql> create database mha; Query OK, 1 row affected (0.01 sec) [ ~]# 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 [ 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