hacluster #14

Supports: precise




The hacluster subordinate charm provides corosync and pacemaker cluster configuration for principle charms which support the hacluster, container scoped relation.

The charm will only configure for HA once more that one service unit is present.


NOTE: The hacluster subordinate charm requires multicast network support, so this charm will NOT work in ec2 or in other clouds which block multicast traffic. Its intended for use in MAAS managed environments of physical hardware.

To deploy the charm:

juju deploy hacluster mysql-hacluster

To enable HA clustering support (for mysql for example):

juju deploy -n 2 mysql
juju deploy -n 3 ceph
juju set mysql vip=""
juju add-relation mysql ceph
juju add-relation mysql mysql-hacluster

The principle charm must have explicit support for the hacluster interface in order for clustering to occur - otherwise nothing actually get configured.

Usage for Charm Authors

The hacluster interface supports a number of different cluster configuration options.

Mandatory Relation Data

All principle charms must provide basic corosync configuration:

corosync\_bindiface: The network interface to use for cluster messaging.
corosync\_mcastport: The multicast port to use for cluster messaging.

Resource Configuration

The hacluster interface provides support for a number of different ways of configuring cluster resources. All examples are provided in python.

NOTE: The hacluster charm interprets the data provided as python dicts; so it is also possible to provide these as literal strings from charms written in other languages.


Services which will be managed by pacemaker once the cluster is created:

init_services = {

These services will be stopped prior to configuring the cluster.


Resources are the basic cluster resources that will be managed by pacemaker. In the mysql charm, this includes a block device, the filesystem, a virtual IP address and the mysql service itself:

resources = {


Parameters which should be used when configuring the resources specified:

resource_params = {
    'res_mysql_rbd':'params name="%s" pool="images" user="%s" secret="%s"' % \
                    (config['rbd-name'], SERVICE_NAME, KEYFILE),
    'res_mysql_fs':'params device="/dev/rbd/images/%s" directory="%s" '
                   'fstype="ext4" op start start-delay="10s"' % \
                    (config['rbd-name'], DATA_SRC_DST),
    'res_mysql_vip':'params ip="%s" cidr_netmask="%s" nic="%s"' %\
                    (config['vip'], config['vip_cidr'], config['vip_iface']),
    'res_mysqld':'op start start-delay="5s" op monitor interval="5s"',


Resources which should be managed as a single set of resource on the same service unit:

groups = {
    'grp_mysql':'res_mysql_rbd res_mysql_fs res_mysql_vip res_mysqld',


Resources which should run on every service unit participating in the cluster:

clones = {
    'cl_haproxy': 'res_haproxy_lsb'


(int) Number of peer units required to bootstrap cluster services.
(string) This value will become the Corosync authentication key. To generate a suitable value use: . sudo corosync-keygen sudo cat /etc/corosync/authkey | base64 -w 0 . This configuration element is mandatory and the service will fail on install if it is not provided. The value must be base64 encoded.
(string) Multicast IP address to use for exchanging messages over the network. If multiple clusters are on the same bindnetaddr network, this value can be changed.
(int) Service version for the Pacemaker service version. This will tell Corosync how to start pacemaker
(string) MAAS credentials (required for STONITH).
(string) MAAS API endpoint (required for STONITH).
(string) One or more IPs, separated by space, that will be used as a saftey check for avoiding split brain situations. Nodes in the cluster will ping these IPs periodicaly. Node that can not ping monitor_host will not run shared resources (VIP, shared disk...).
(string) Time period between checks of resource health. It consists of a number and a time factor, e.g. 5s = 5 seconds. 2m = 2 minutes.
(string) Enable resource fencing (aka STONITH) for every node in the cluster. This requires MAAS credentials be provided and each node's power parameters are properly configured in its invenvory.