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"
  • You didn't mention what the actual problem with the configuration is this time. Is nothing working at all? Or partially working? or? Oct 9 '09 at 0:05
  • Haven't tried it yet, as I don't think it's complete.
    – Brent
    Oct 9 '09 at 15:16

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.

  • I agree with the two resources bit 100%. Having another LSB init script to switch one of the instances to master is just asking for trouble. Good catch on the typos, I didn't even bother looking yet :) Oct 9 '09 at 1:45
  • Thanks - sorry about the typos - your last point is quite helpful, as are your comments. I am finding that I haven't quite got a grasp of how this is supposed to be working, so I'm just combining bits and pieces of examples right now. I'm finding the official documentation very hard to comprehend. Can you recommend a better resource for me?
    – Brent
    Oct 9 '09 at 15:21
  • The one question I've asked on the pacemaker mailing list has been helpfully answered; apart from that, I just read the docs and applied common sense, and it's working fairly well in a large-scale deployment (200+ resources)
    – womble
    Oct 10 '09 at 6:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.