thinkingqi / mysql-master-ha

Automatically exported from code.google.com/p/mysql-master-ha
0 stars 0 forks source link

Do mysql master failover only when there are more than one slaves #107

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hi

I have a mysql cluster with one master node and two hot standby slave nodes. 
All reads and writes go to master. The three node cluster is managed by 
corosync pacemaker that has a VIP for the master node. At any given time at 
least two nodes should be up and running for the VIP to be online. Is there a 
possibility to do mysql master failover only when there are two slaves in the 
mha config. In case of only one slave there should be no mysql failover 
performed. One work around could be setting --last_failover_minute to a higher 
value for example 1440 minutes but that still wont ensure that the failover 
will not happen again when the new master node goes down after 
last_failover_minute had passed. 

OS: Debian GNU/Linux 7.8 (wheezy)
mysql-server: 5.6.19-1~exp1-log (Debian) 
mha4mysql-manager: 0.53-3
mha4mysql-node: 0.53-1

Your response would be greatly appreciated.
- Omair

Original issue reported on code.google.com by khanomai...@gmail.com on 18 Feb 2015 at 2:40

GoogleCodeExporter commented 9 years ago
The initial mha config is given below. db01 is master. db02 and db03 are its 
slaves.

[server default]
#log_level=debug
manager_log=/var/log/masterha/mysqlcluster.log
manager_workdir=/var/log/masterha/
master_ip_failover_script=/etc/mha/master_ip_failover
password=232aAA
ping_interval=3
remote_workdir=/var/log/masterha
ssh_user=ssh_user
user=repl

[server1]
hostname=db01
[server2]
hostname=db02
[server3]
hostname=db03

After failover happens for the first time, mha config will be shown as given 
below. db02 will become master and db03 its slave

[server default]
#log_level=debug
manager_log=/var/log/masterha/mysqlcluster.log
manager_workdir=/var/log/masterha/
master_ip_failover_script=/etc/mha/master_ip_failover
password=232aAA
ping_interval=3
remote_workdir=/var/log/masterha
ssh_user=ssh_user
user=repl

[server2]
hostname=db02
[server3]
hostname=db03

There should be no more fail over happens because there is only one slave db03.

Original comment by khanomai...@gmail.com on 18 Feb 2015 at 2:58

GoogleCodeExporter commented 9 years ago
If you keep "[server1]" entry, after failover MHA does not start because 
server1 does not exist, which means failover does not happen. Does not meet 
your requirement?

Original comment by Yoshinor...@gmail.com on 19 Feb 2015 at 6:41

GoogleCodeExporter commented 9 years ago
Many thanks for the reply. Yes for the moment that would work. I had one more 
question not directly to mha but you probably have encountered it many times. 
If the previous master was down for one hour and I want to add it as a slave of 
the new master. Data until the failover in the new master and previous master 
would be the same (More than 80% of our database activity is read only). What 
would be the quickest way to do it without stopping/locking the new master. 
Should I use rsync from the new master. I am using mha 0.56 version with gtid 
support now.

Original comment by khanomai...@gmail.com on 20 Feb 2015 at 12:14