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 mysql1.idaho.cbts.net mysql2.idaho.cbts.net
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 pcmk_host_list=mysql1.domain.net
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 pcmk_host_list=mysql2.domain.net
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-172.16.56.228 – 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 device=nfs.domain.net:/mysqlnfs directory=/var/lib/mysql fstype=nfs options=v3 --clone
pcs resource create ip-172.16.56.228 IPaddr2 ip=172.16.56.228
pcs resource create mysql-db mysql config=/var/lib/mysql/my.cnf enable_creation=1
pcs resource group add mysql-group ip-172.16.56.228 nfs-mysql mysql-db ip-172.16.56.228

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 mysql1.domain.net
Stack: cman
Current DC: mysql1.domain.net - partition with quorum
Version: 1.1.10-14.el6_5.2-368c726
2 Nodes configured
6 Resources configured
Online: [ mysql1.domain.net mysql2.domain.net ]

Full list of resources:

fence_mysql1 (stonith:fence_vmware_soap): Started mysql1.domain.net
fence_mysql2 (stonith:fence_vmware_soap): Started mysql2.domain.net
Clone Set: nfs-mysql-clone [nfs-mysql]
Started: [ mysql1.domain.net mysql2.domain.net ]
ip-172.16.56.228 (ocf::heartbeat:IPaddr2): Started mysql1.domain.net
mysql-db (ocf::heartbeat:mysql): Started mysql1.domain.net

Search

Categories