Corosync is an open source group messaging system typically used in clusters, cloud computing, and other high availability environments.
The project, at it's core, provides four C api features:
- A closed process group communication model with virtual synchrony guarantees for creating replicated state machines.
- A simple availability manager that restarts the application process when it has failed.
- A configuration and statistics in-memory database that provide the ability to set, retrieve, and receive change notifications of information.
- A quorum system that notifies applications when quorum is achieved or lost.
Corosync and Asterisk
Using Corosync together with res_corosync allows events to be shared amongst a local cluster of Asterisk servers. Specifically, the types of events that may be shared include:
- Device state
- Message Waiting Indication, or MWI (to allow voicemail to live on a server that is different from where the phones are registered)
Setup and Configuration
AuthkeyTo create an authentication key for secure communications between your nodes you need to do this on, what will be, the active node. This creates a key in /etc/corosync/authkey. Now, on the standby node, you'll need to stick the authkey in it's new home and fix it's permissions / ownership.
/etc/corosync/corosync.confThe interface section under the totem block defines the communication path(s) to the other Corosync processes running on nodes within the cluster. These can be either IPv4 or IPv6 ip addresses but can not be mixed and matched within an interface. Adjustments can be made to the cluster settings based on your needs and installation environment.
Active Node Example
Standby Node Example
InstallationIn your Asterisk source directory:
/etc/asterisk/res_corosync.confIn the general section of the res_corosync.conf file we are specifying which events we'd like to publish and subscribe to (at the moment this is either device_state or mwi).
Verifying InstallationIf everything is setup correctly, you should see this output after executing a 'corosync show members' on the Asterisk CLI.
After starting Corosync and Asterisk on your second node, the 'corosync show members' output should look something like this: