your home for end-user virtualization!

Installing a active/passive MySQL database cluster for OpenStack Havana on RHEL 6.5

Since RHEL 6.5 does not ship with an Active/Active version of MySQL, you’re limited to using an Active/Passive configuration out of the box. There are other alternate methods, however; this is the supported configuration from RedHat.

The requirements for creating an Active/Passive MySQL cluster are quite simple. You simply need shared storage. In this case, NFS will be sufficient as the database is not all that transaction heavy. So from here out, I’m assuming that you’re running a registered version of RHEL 6.5 on two servers with a common NFS mount on both servers under /var/lib/mysql and that your MySQL servers are virtual machines running on an ESX cluster.

First step, set up the RHEL HA channel:

rhn-channel --user username--password password -a -c rhel-x86_64-server-ha-6

Then install the Pacemaker and MySQL packages that are needed:
yum install -y pacemaker pcs cman resource-agents fence-agents mysql mysql-server

Now set pacemaker to start at boot and mysql to not start at boot on both nodes:

chkconfig pacemaker on
chkconfig mysqld off

Now, start mysqld and set the root password for mysqld

service mysqld start
mysqladmin -u root password password
service mysqld stop

Now we need to create the cluster on both nodes:

pcs cluster setup --name mysql-cluster
pcs cluster start

The next step is to create the stonith resources… Shoot The Other Node In The Head :P These stonith resources are used to fence the cluster nodes. Fencing is used to prevent “split-brain” cluster issues.

pcs stonith create fence_mysql1 fence_vmware_soap login=root passwd=vmware action=reboot ipaddr=vcenterip port=/vmdatacenter/vm/mysql1 ssl=1
pcs cluster start
pcs stonith create fence_mysql2 fence_vmware_soap login=root passwd=vmware action=reboot ipaddr=vcenterip port=/vmdatacenter/vm/mysql2 ssl=1
pcs cluster start

The next step is to create the cluster resources. We’re going to create the following cluster resources:

  • nfs-mysql – this will be a cluster resource to mount the NFS filesystem on the active MySQL node.
  • ip- – this is the MySQL instance Virtual IP
  • mysql-db – this is the actual MySQL instance
  • mysql-group – this is the group of the above resources, used to keep the services together on the same node.
pcs resource create nfs-mysql Filesystem directory=/var/lib/mysql fstype=nfs options=v3 --clone
pcs resource create ip- IPaddr2 ip=
pcs resource create mysql-db mysql config=/var/lib/mysql/my.cnf enable_creation=1
pcs resource group add mysql-group ip- nfs-mysql mysql-db ip-

You should now be able to see the cluster resources online using the pcs status command:

[root@mysql1 ~]# pcs status
Cluster name: mysql-cluster
Last updated: Fri Jan 24 13:30:58 2014
Last change: Wed Jan 22 12:59:33 2014 via crm_resource on
Stack: cman
Current DC: - partition with quorum
Version: 1.1.10-14.el6_5.2-368c726
2 Nodes configured
6 Resources configured
Online: [ ]

Full list of resources:

fence_mysql1 (stonith:fence_vmware_soap): Started
fence_mysql2 (stonith:fence_vmware_soap): Started
Clone Set: nfs-mysql-clone [nfs-mysql]
Started: [ ]
ip- (ocf::heartbeat:IPaddr2): Started
mysql-db (ocf::heartbeat:mysql): Started