Asterisk High Availability coming to the Pacemaker cluster stack

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="" cidr_netmask="24" \
  op monitor interval="10s"
primitive p_asterisk ocf:heartbeat:asterisk \
  params realtime="true" monitor_sipuri="sip:42@" \
  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-dev and linux-ha mailing lists.

hastexo will of course offer installation support, consulting and training for Pacemaker-based Asterisk PBX high availability as soon as the release happens.

6 Responses to Asterisk High Availability coming to the Pacemaker cluster stack

  1. Graham Donaldson says:

    I’m seeing

    crm(live)configure# primitive p_asterisk ocf:heartbeat:asterisk
    ERROR: ocf:heartbeat:asterisk: could not parse meta-data:
    ERROR: ocf:heartbeat:asterisk: no such resource agent

    I installed the agent in /usr/lib/ocf/resource.d/heartbeat/asterisk with permissions identical to the other scripts (root:root, 755)

    Is this down to the version of resource agents? Debian Squeeze.

    • Florian Haas says:

      My guess is that your RA fails to execute because you’ve got an old version of resource-agents that puts its shell function library in a different path from what the asterisk RA expects. Please install the resource-agents package from squeeze-backports.

  2. charaffy says:


    I tested on vmware follow your guide it works but I need start some services that involve with asterisk service. Such as start Mysql service after pacemaker mounted filesystem then start Asterisk service and then start httpd service. How can I do this ?

  3. Riley says:

    Very nice but one irritation … lots of “INFO: 0 active channels 0 …” output in /var/log/messages – was this intentional? It is caused by the asterisk_rx() function calling “ocf_run” without a ‘-q’ flag when you do a ‘core show channels count’. As you only seem to be interested in the return code of the command it would seem sensible not to generate output unless there is an error. [I created an extra function, asterisk_rxq() that uses “ocf_run -q …” and use this … not that it matters much as you only use asterisk_rx() in one place].

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: