master_auto_position自动判断错误
前置条件
gtid-mode = on
数据库没有任何库 show master status; =>`Executed_Gtid_Set` 为空
第一次配置从节点使用如下方式 ,此时master_auto_position=0;
change master to master_host='192.168.1.5',master_port =3309,master_user='repluser',master_password='repluser',
master_log_file='mysql-bin.000002',master_log_pos=463;
当发生主从自动切换时,由于gtid-mode = on,此时master_auto_position=1
change master to master_host='192.168.1.5',master_port =3309,master_user='repluser',master_password='repluser',master_auto_position=1;
当第三次切换时,会失败,因为MHA调用 use_gtid_auto_pos自动判断 ,当 Executed_Gtid_Set为空时,会认为当前是master_auto_position=0模式,由于数据库已经切换成``master_auto_position=1`,这时会使用如下语句,切换master会失败,而且无错误提示
change master to master_host='192.168.1.5',master_port =3309,master_user='repluser',master_password='repluser',
master_log_file='mysql-bin.000002',master_log_pos=463;
- MHA三个节点时,masterha_master_switch指定new_master_host 无效
masterha_master_switch --conf=/etc/mha/app1.cnf --master_state=alive --new_master_host=192.168.1.2 --orig_master_is_new_slave --running_updates_limit=10000 --interactive=0
masterha_master_switch --conf=/etc/mha/app1.cnf --master_state=alive --orig_master_is_new_slave --running_updates_limit=10000 --interactive=0
nohup操作不规范-导致masterha_manager退出
Thu Jul 30 11:59:08 2019 - [info] Ping(SELECT) succeeded, waiting until MySQL doesn't respond..
Thu Jul 30 11:59:12 2019 - [info] Got terminate signal. Exit.
在当shell中提示了nohup成功后,还需要按终端上键盘任意键退回到shell输入命令窗口,然后通过在shell中输入exit来退出终端;如果在nohup执行成功后直接点关闭程序按钮关闭终端的话,这时候会断掉该命令所对应的session,导致nohup对应的进程被通知需要一起shutdown,起不到关掉终端后调用程序继续后台运行的作用。
两种避免方式:
1.脚本start_monitor.sh如下:
#!/bin/bash
/usr/bin/nohup /usr/local/bin/masterha_manager --conf=/data/mha/3306/mha.cnf --ignore_last_failover > /data/mha/3306/log/manager.log 2>&1 &
启动监控:
/bin/bash start_monitor.sh
2.使用daemon的方式运行,这个是为了避免MHA切换以后进程退出的方法。
daemontools 或 supervisord