The Pacemaker based Linux cluster stack is gaining a freshly supported service: the Asterisk open-source PBX. hastexo‘s Martin Loschwitz has contributed a resource agent for the popular telephony stack.
I’ve merged and committed the
ocf:heartbeat:asterisk resource agent to the upstream repository this morning, and it’s going to ship with the next release of the resource-agents package. If you already run a Pacemaker cluster, and your own version of resource-agents is reasonably recent, you can use the agent already: just fetch it from git, and drop it into the
/usr/lib/ocf/resource.d/heartbeat directory on your machines.
The RA supports Asterisk in realtime mode including monitoring via
astcanary, and you can also use Pacemaker’s resource auto-recovery features by specifying a SIP URI to be monitored: if the SIP URI does not respond to an OPTIONS request, then the resource is considered failed, and Pacemaker recovers it either on the same node, or on another (depending on your cluster configuration).
The basic Pacemaker configuration for a highly-available Asterisk PBX is quite simple:
primitive p_asterisk ocf:heartbeat:asterisk
A more realistic real-world example, though, is an Asterisk with a virtual IP address and a DRBD-backed
/var/lib/asterisk filesystem, and automated resource monitoring:
primitive p_drbd_asterisk ocf:linbit:drbd \ params drbd_resource="asterisk" ms ms_drbd_asterisk p_drbd_asterisk \ meta notify=true clone-max=2 primitive p_fs_asterisk ocf:heartbeat:Filesystem \ params device="/dev/drbd0" directory="/var/lib/asterisk" primitive p_ip_asterisk ocf:heartbeat:IPaddr2 \ params ip="192.168.42.42" cidr_netmask="24" \ op monitor interval="10s" primitive p_asterisk ocf:heartbeat:asterisk \ params realtime="true" monitor_sipuri="sip:firstname.lastname@example.org" \ op monitor interval="10s" group g_asterisk p_fs_asterisk p_ip_asterisk p_asterisk colocation c_asterisk_on_drbd_master inf: g_asterisk ms_drbd_asterisk:Master order o_drbd_promote_before_asterisk_start inf: ms_drbd_asterisk:promote g_asterisk:start
Besides this standard HA configuration, you can of course also include a highly-available MySQL database, or an iSCSI backed filesystem (instead of DRBD), multiple Asterisk instances, etc.
Special thanks goes to first-time OCF resource agent reviewer Russell Bryant (of Asterisk fame) and all other reviewers on the
linux-ha mailing lists.