<html>
<head>
<base href="https://wiki.asterisk.org/wiki">
<link rel="stylesheet" href="/wiki/s/en/2176/25/9/_/styles/combined.css?spaceKey=AST&forWysiwyg=true" type="text/css">
</head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
<h2><a href="https://wiki.asterisk.org/wiki/display/AST/Corosync">Corosync</a></h2>
<h4>Page <b>edited</b> by <a href="https://wiki.asterisk.org/wiki/display/~russell">Russell Bryant</a>
</h4>
<br/>
<h4>Changes (2)</h4>
<div id="page-diffs">
<table class="diff" cellpadding="0" cellspacing="0">
<tr><td class="diff-snipped" >...<br></td></tr>
<tr><td class="diff-unchanged" >apt-get install corosync corosync-dev <br>{noformat} <br></td></tr>
<tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">Redhat / Fedora <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;">Red Hat / Fedora <br></td></tr>
<tr><td class="diff-unchanged" >{noformat} <br>yum install corosync corosynclib corosynclib-devel <br></td></tr>
<tr><td class="diff-snipped" >...<br></td></tr>
</table>
</div> <h4>Full Content</h4>
<div class="notificationGreySide">
<h5><a name="Corosync-Corosync"></a>Corosync</h5>
<p><a href="http://www.corosync.org" class="external-link" rel="nofollow">Corosync</a> is an open source group messaging system typically used in clusters, cloud computing, and other high availability environments.</p>
<p>The project, at it's core, provides four C api features:</p>
<ul>
        <li>A closed process group communication model with virtual synchrony guarantees for creating replicated state machines.</li>
        <li>A simple availability manager that restarts the application process when it has failed.</li>
        <li>A configuration and statistics in-memory database that provide the ability to set, retrieve, and receive change notifications of information.</li>
        <li>A quorum system that notifies applications when quorum is achieved or lost.</li>
</ul>
<h5><a name="Corosync-CorosyncandAsterisk"></a>Corosync and Asterisk</h5>
<p>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:</p>
<ul>
        <li>Device state</li>
        <li>Message Waiting Indication, or MWI (to allow voicemail to live on a server that is different from where the phones are registered)</li>
</ul>
<h5><a name="Corosync-SetupandConfiguration"></a>Setup and Configuration</h5>
<h6><a name="Corosync-Corosync"></a>Corosync</h6>
<ul>
        <li><h6><a name="Corosync-Installation"></a>Installation</h6>
<p>Debian / Ubuntu</p>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>apt-get install corosync corosync-dev
</pre>
</div></div>
<p>Red Hat / Fedora</p>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>yum install corosync corosynclib corosynclib-devel
</pre>
</div></div></li>
</ul>
<ul>
        <li><h6><a name="Corosync-Authkey"></a>Authkey</h6>
<p>To create an authentication key for secure communications between your nodes you need to do this on, what will be, the active node.</p>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>corosync-keygen
</pre>
</div></div>
<p>This creates a key in /etc/corosync/authkey.</p>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>asterisk_active:~# scp /etc/corosync/authkey asterisk_standby:
</pre>
</div></div>
<p>Now, on the standby node, you'll need to stick the authkey in it's new home and fix it's permissions / ownership.</p>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>asterisk_standby:~# mv ~/authkey /etc/corosync/authkey
asterisk_standby:~# chown root:root /etc/corosync/authkey
asterisk_standby:~# chmod 400 /etc/corosync/authkey
</pre>
</div></div></li>
        <li><h6><a name="Corosync-%2Fetc%2Fcorosync%2Fcorosync.conf"></a>/etc/corosync/corosync.conf</h6>
<p>The 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.</p>
        <ul>
                <li><h6><a name="Corosync-IPv4"></a>IPv4</h6>
<h6><a name="Corosync-ActiveNodeExample"></a>Active Node Example</h6>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>totem {
version: 2
token: 160
token_retransmits_before_loss_const: 3
join: 30
consensus: 300
vsftype: none
max_messages: 20
threads: 0
nodeid: 1
rrp_mode: none
interface {
ringnumber: 0
bindnetaddr: 192.168.1.0
mcastaddr: 226.94.1.1
mcastport: 5405
}
}
</pre>
</div></div>
<h6><a name="Corosync-StandbyNodeExample"></a>Standby Node Example</h6>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>totem {
version: 2
token: 160
token_retransmits_before_loss_const: 3
join: 30
consensus: 300
vsftype: none
max_messages: 20
threads: 0
nodeid: 2
rrp_mode: none
interface {
ringnumber: 0
bindnetaddr: 192.168.1.0
mcastaddr: 226.94.1.1
mcastport: 5405
}
}
</pre>
</div></div></li>
        </ul>
        </li>
</ul>
<ul>
        <li><h6><a name="Corosync-StartCorosync"></a>Start Corosync</h6>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>service corosync start
</pre>
</div></div></li>
</ul>
<h6><a name="Corosync-Asterisk"></a>Asterisk</h6>
<ul>
        <li><h6><a name="Corosync-Installation"></a>Installation</h6>
<p>In your Asterisk source directory:</p>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>./configure
make
make install
</pre>
</div></div></li>
</ul>
<ul>
        <li><h6><a name="Corosync-%2Fetc%2Fasterisk%2Frescorosync.conf"></a>/etc/asterisk/res_corosync.conf</h6>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>;
; Sample configuration file for res_corosync.
;
; This module allows events to be shared amongst a local cluster of
; Asterisk servers. Specifically, the types of events that may be
; shared include:
;
; - Device State (for shared presence information)
;
; - Message Waiting Indication, or MWI (to allow Voicemail to live on
; a server that is different from where the phones are registered)
;
; For more information about Corosync, see: http://www.corosync.org/
;
[general]
;
; Publish Message Waiting Indication (MWI) events from this server to the
; cluster.
publish_event = mwi
;
; Subscribe to MWI events from the cluster.
subscribe_event = mwi
;
; Publish Device State (presence) events from this server to the cluster.
publish_event = device_state
;
; Subscribe to Device State (presence) events from the cluster.
subscribe_event = device_state
;
</pre>
</div></div>
<p>In 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).</p></li>
</ul>
<ul>
        <li><h6><a name="Corosync-VerifyingInstallation"></a>Verifying Installation</h6>
<p>If everything is setup correctly, you should see this output after executing a 'corosync show members' on the Asterisk CLI.</p>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>*CLI> corosync show members
=============================================================
=== Cluster members =========================================
=============================================================
===
=== Node 1
=== --> Group: asterisk
=== --> Address 1: <host #1 ip goes here>
===
=============================================================
</pre>
</div></div></li>
</ul>
<p>After starting Corosync and Asterisk on your second node, the 'corosync show members' output should look something like this:</p>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>*CLI> corosync show members
=============================================================
=== Cluster members =========================================
=============================================================
===
=== Node 1
=== --> Group: asterisk
=== --> Address 1: <host #1 ip goes here>
=== Node 2
=== --> Group: asterisk
=== --> Address 1: <host #2 ip goes here>
===
=============================================================
</pre>
</div></div>
</div>
<div id="commentsSection" class="wiki-content pageSection">
<div style="float: right;" class="grey">
<a href="https://wiki.asterisk.org/wiki/users/removespacenotification.action?spaceKey=AST">Stop watching space</a>
<span style="padding: 0px 5px;">|</span>
<a href="https://wiki.asterisk.org/wiki/users/editmyemailsettings.action">Change email notification preferences</a>
</div>
<a href="https://wiki.asterisk.org/wiki/display/AST/Corosync">View Online</a>
|
<a href="https://wiki.asterisk.org/wiki/pages/diffpagesbyversion.action?pageId=21463349&revisedVersion=4&originalVersion=3">View Changes</a>
|
<a href="https://wiki.asterisk.org/wiki/display/AST/Corosync?showComments=true&showCommentArea=true#addcomment">Add Comment</a>
</div>
</div>
</div>
</div>
</div>
</body>
</html>