Mysql – Need help configuring pacemaker

clusterconfigurationMySQLpacemaker

I'm trying to configure a 2-node openais / pacemaker cluster, and finding information / tutorials very difficult to come by.

My goal is to set up 2 MySQL servers in a master-slave replication scenerio, where I can read from both servers, but only write to the "master" server.

As such, I have the replication and manual failover working by swapping secondary IP addresses, and reconfiguring the new slave with the "read-only" option in my.cnf. I would now like to automate this with pacemaker. Basically I want the master IP to always be on the server that I can write to, and the slave IP to always be on the other one. I would like failover to occur when mysql on the master fails to respond.

Here is the configuration I have so far. Is there somebody that could check my work (which I'm sure is incomplete), and give me some pointers about what I'm doing wrong? (note: the mysql-master script is a custom script under /etc/init.d that sets/clears the read-only option, and restarts mysql)

primitive virtual_master_ip ocf:heartbeat:IPaddr2 \
    params ip=192.168.250.xxx.xxx \
    op monitor interval=10s
primitive virtual_slave_ip ocf:heartbeat:IPaddr2 \
    params ip=192.168.xxx.yyy
primitive mysql_service ocf:heartbeat:mysql
    params binary="/usr/bin/mysqld_safe" config="/etc/mysql/my.cnf" \
    op minitor interval="60s" timeout="30s" \
    meta target-role="Started"
primitive mysql_master_role lsb:mysql-master

group mysql virtual_master_ip mysql_master virtual_slave_ip
colocation ms_ip inf: virtual_master_ip virtual_slave_ip score="-INFINITY"

Best Answer

Knowing what the problem actually is would, as Kamil says, be awfully useful information. However, I've got a few problems for you straight off the bat:

  • Your IP address has five octets: 192.168.250.xxx.xxx
  • I'm not aware of an operation called 'minitor': op minitor interval="60s" timeout="30s"
  • I use the lsb:mysql class, rather than ocf:heartbeat:mysql; if you're having problems with that part of things, it might be worth giving it a go.
  • You probably don't want virtual_master_ip and virtual_slave_ip in the same group if you've got a -INF colocation constraint. That'll give pacemaker an arrythmia.

I'm not even sure that you want to be doing what you think you're doing, though. I'd be more inclined to setup two resources, mysql_as_master and mysql_as_slave, which makes sure that MySQL is running in the appropriate mode on the machine (I'd be starting MySQL with the read-only option set on the command line, rather than jiggering with the config file, and using the mysql client to query the running server to ensure that it's running read-only or read-write, as required), and then grouping them with the associated IP address.