<html>
<head>
<base href="https://wiki.asterisk.org/wiki">
<link rel="stylesheet" href="/wiki/s/2030/1/7/_/styles/combined.css?spaceKey=TOP&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/TOP/Failover+-+Linux">Failover - Linux</a></h2>
<h4>Page <b>edited</b> by <a href="https://wiki.asterisk.org/wiki/display/~dsessions@digium.com">Darren Sessions</a>
</h4>
<br/>
<h4>Changes (12)</h4>
<div id="page-diffs">
<table class="diff" cellpadding="0" cellspacing="0">
<tr><td class="diff-unchanged" >h2. Preface <br> <br></td></tr>
<tr><td class="diff-changed-lines" >These instructions cover how to install the IP cluster failover solution (Corosync + Pacemaker) for Asterisk SCF on Unix and Linux <span class="diff-changed-words">variants<span class="diff-added-chars"style="background-color: #dfd;"> (very similar to what was used in the Asterisk SCF demo at Astricon)</span>.</span> These instructions assume that the installation is on a clean installation so that all required components are covered. <br></td></tr>
<tr><td class="diff-unchanged" > <br>h2. Overview <br></td></tr>
<tr><td class="diff-snipped" >...<br></td></tr>
<tr><td class="diff-unchanged" >#* h6.Configs <br>#** h6./etc/corosync/corosync.conf <br></td></tr>
<tr><td class="diff-changed-lines" >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. <span class="diff-added-words"style="background-color: #dfd;">Adjustments can be made to the cluster settings based on your needs and installation environment.</span> <br></td></tr>
<tr><td class="diff-unchanged" >#*** h6.IPv4 <br>h6.Active Node Example <br>{noformat} <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;">totem { <br> version: 2 <br> token: 160 <br> token_retransmits_before_loss_const: 3 <br> join: 30 <br> consensus: 300 <br> vsftype: none <br> max_messages: 20 <br> threads: 0 <br> nodeid: 1 <br> rrp_mode: none <br></td></tr>
<tr><td class="diff-unchanged" > interface { <br> ringnumber: 0 <br></td></tr>
<tr><td class="diff-snipped" >...<br></td></tr>
<tr><td class="diff-unchanged" > mcastport: 5405 <br> } <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;">} <br></td></tr>
<tr><td class="diff-unchanged" >{noformat} <br>h6.Standby Node Example <br>{noformat} <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;">totem { <br> version: 2 <br> token: 160 <br> token_retransmits_before_loss_const: 3 <br> join: 30 <br> consensus: 300 <br> vsftype: none <br> max_messages: 20 <br> threads: 0 <br> nodeid: 2 <br> rrp_mode: none <br></td></tr>
<tr><td class="diff-unchanged" > interface { <br> ringnumber: 0 <br></td></tr>
<tr><td class="diff-snipped" >...<br></td></tr>
<tr><td class="diff-unchanged" > mcastport: 5405 <br> } <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;">} <br></td></tr>
<tr><td class="diff-unchanged" >{noformat} <br>#*** h6.IPv6 <br></td></tr>
<tr><td class="diff-snipped" >...<br></td></tr>
<tr><td class="diff-unchanged" >h6.Active Node Example <br>{noformat} <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;">totem { <br> version: 2 <br> token: 160 <br> token_retransmits_before_loss_const: 3 <br> join: 30 <br> consensus: 300 <br> vsftype: none <br> max_messages: 20 <br> threads: 0 <br> nodeid: 1 <br> rrp_mode: none <br></td></tr>
<tr><td class="diff-unchanged" > interface { <br> ringnumber: 0 <br></td></tr>
<tr><td class="diff-snipped" >...<br></td></tr>
<tr><td class="diff-unchanged" > mcastport: 5405 <br> } <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;">} <br></td></tr>
<tr><td class="diff-unchanged" >{noformat} <br>h6.Standby Node Example <br>{noformat} <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;">totem { <br> version: 2 <br> token: 160 <br> token_retransmits_before_loss_const: 3 <br> join: 30 <br> consensus: 300 <br> vsftype: none <br> max_messages: 20 <br> threads: 0 <br> nodeid: 2 <br> rrp_mode: none <br></td></tr>
<tr><td class="diff-unchanged" > interface { <br> ringnumber: 0 <br></td></tr>
<tr><td class="diff-snipped" >...<br></td></tr>
<tr><td class="diff-unchanged" > mcastport: 5405 <br> } <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;">} <br></td></tr>
<tr><td class="diff-unchanged" >{noformat} <br> <br></td></tr>
<tr><td class="diff-snipped" >...<br></td></tr>
<tr><td class="diff-unchanged" > expected-quorum-votes="2" <br>{noformat} <br></td></tr>
<tr><td class="diff-changed-lines" >Now we're going to turn of the stonith support since we don't need it at the moment and it generates a lot of warnings. <span class="diff-added-words"style="background-color: #dfd;">We'll also be setting resource stickiness, quorum policy, and resource preference to the first node.</span> <br></td></tr>
<tr><td class="diff-unchanged" >{noformat} <br>crm(live)configure# property stonith-enabled=false <br></td></tr>
<tr><td class="diff-added-lines" style="background-color: #dfd;">crm(live)configure# property no-quorum-policy="ignore" <br>crm(live)configure# property default-resource-stickiness="infinity" <br>crm(live)configure# location cli-prefer-failover-ip failover-ip rule $id="cli-prefer-rule-failover-ip" inf: #uname eq node1 <br></td></tr>
<tr><td class="diff-unchanged" >{noformat} <br>#* h6.Configuring the shared IP address <br></td></tr>
<tr><td class="diff-snipped" >...<br></td></tr>
</table>
</div> <h4>Full Content</h4>
<div class="notificationGreySide">
<h2><a name="Failover-Linux-Preface"></a>Preface</h2>
<p>These instructions cover how to install the IP cluster failover solution (Corosync + Pacemaker) for Asterisk SCF on Unix and Linux variants (very similar to what was used in the Asterisk SCF demo at Astricon). These instructions assume that the installation is on a clean installation so that all required components are covered.</p>
<h2><a name="Failover-Linux-Overview"></a>Overview</h2>
<p><span class="image-wrap" style=""><a class="confluence-thumbnail-link 528x541" href='https://wiki.asterisk.org/wiki/download/attachments/5243852/ip failover diagram.jpg'><img src="/wiki/download/thumbnails/5243852/ip failover diagram.jpg" style="border: 0px solid black" /></a></span></p>
<h2><a name="Failover-Linux-Installation"></a>Installation</h2>
<ol>
        <li><h6><a name="Failover-Linux-Addadditionalrequiredrepositories"></a>Add additional required repositories</h6>
        <ul>
                <li>CentOS / RHEL 5.5
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
wget -O /etc/yum.repos.d/pacemaker.repo http://clusterlabs.org/rpm/epel-5/clusterlabs.repo
yum update
</pre>
</div></div></li>
                <li>Debian 5.0
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>echo "deb http://www.backports.org/debian lenny-backports main contrib non-free" >> /etc/apt/sources.list
apt-get update
</pre>
</div></div></li>
                <li>Ubuntu 10.04</li>
        </ul>
        </li>
        <li><h6><a name="Failover-Linux-InstallCorosync"></a>Install Corosync</h6>
        <ul>
                <li>CentOS / RHEL 5.5
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>yum install corosync
</pre>
</div></div></li>
                <li>Debian 5.0 and Ubuntu 10.04
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>apt-get install corosync
</pre>
</div></div></li>
        </ul>
        </li>
        <li><h6><a name="Failover-Linux-InstallPacemaker"></a>Install Pacemaker</h6>
        <ul>
                <li>CentOS / RHEL 5.5
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>yum install pacemaker
</pre>
</div></div></li>
                <li>Debian 5.0 and Ubuntu 10.04
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>apt-get install pacemaker
</pre>
</div></div></li>
        </ul>
        </li>
        <li><h6><a name="Failover-Linux-Installadditionalmodules"></a>Install additional modules</h6>
        <ul>
                <li>Debian 5.0 and Ubuntu 10.04
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>apt-get install ssh
</pre>
</div></div></li>
        </ul>
        </li>
</ol>
<h2><a name="Failover-Linux-Configuration"></a>Configuration</h2>
<ol>
        <li><h6><a name="Failover-Linux-HostConfiguration"></a>Host Configuration</h6>
        <ul>
                <li>The /etc/hosts files on both the active and standby servers must have host names specified (with IPv4 or IPv6 addresses to be used later in the Corosync configuration file) that match each of the individual servers (uname -n). In addition to being a requirement for Corosync, this allows for continued communication should there be a problem resolving dns names for whatever reason.</li>
        </ul>
        </li>
        <li><h6><a name="Failover-Linux-CorosyncConfiguration"></a>Corosync Configuration</h6>
        <ul>
                <li><h6><a name="Failover-Linux-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-scf_active:~# scp /etc/corosync/authkey asterisk-scf_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-scf_standby:~# mv ~/authkey /etc/corosync/authkey
asterisk-scf_standby:~# chown root:root /etc/corosync/authkey
asterisk-scf_standby:~# chmod 400 /etc/corosync/authkey
</pre>
</div></div></li>
                <li><h6><a name="Failover-Linux-Configs"></a>Configs</h6>
                <ul>
                        <li><h6><a name="Failover-Linux-%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="Failover-Linux-IPv4"></a>IPv4</h6>
<h6><a name="Failover-Linux-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="Failover-Linux-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>
                                <li><h6><a name="Failover-Linux-IPv6"></a>IPv6</h6>
<p>In this example, the bindnetaddr option is the actual IPv6 address you'd like Corosync to bind to on the host machine (IPv6 does not use broadcast addresses) and the address used for the mcastaddr option is a IPv6 site-local address used for all nodes in the local network site.</p>
<h6><a name="Failover-Linux-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: fc00:1::1
mcastaddr: ff05::1
mcastport: 5405
}
}
</pre>
</div></div>
<h6><a name="Failover-Linux-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: fc00:1::2
mcastaddr: ff05::1
mcastport: 5405
}
}
</pre>
</div></div></li>
                        </ul>
                        </li>
                </ul>
                </li>
        </ul>
        </li>
</ol>
<h2><a name="Failover-Linux-Running"></a>Running</h2>
<ol>
        <li><h6><a name="Failover-Linux-FirewallCheck"></a>Firewall Check</h6>
        <ul>
                <li>CentOS / RHEL 5.5<br/>
Edit the /etc/selinux/config file and change the 'SELINUX=' option to 'permissive'. To avoid restarting, you can use the following command to disable SELinux.
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>echo 0 > /selinux/enforce
</pre>
</div></div></li>
        </ul>
        </li>
        <li><h6><a name="Failover-Linux-EnablingServices"></a>Enabling Services</h6>
        <ul>
                <li><h6><a name="Failover-Linux-Corosync"></a>Corosync</h6>
                <ul>
                        <li><h6><a name="Failover-Linux-Debian5.0andUbuntu10.04"></a>Debian 5.0 and Ubuntu 10.04</h6>
<p>Corosync is disabled by default and starting it with the init script will not work. To enable Corosync, you need to change '=no' to 'START=yes' in /etc/default/corosync.</p></li>
                </ul>
                </li>
        </ul>
        </li>
        <li><h6><a name="Failover-Linux-RunningServices"></a>Running Services</h6>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>/etc/init.d/corosync start
</pre>
</div></div></li>
</ol>
<h2><a name="Failover-Linux-PacemakerConfiguration"></a>Pacemaker Configuration</h2>
<ol>
        <li>
        <ul>
                <li><h6><a name="Failover-Linux-Configuringthecluster"></a>Configuring the cluster</h6>
<p>First we start the cluster resource manager command line tool.</p>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>asterisk-scf_active:~# crm
crm(live)#
</pre>
</div></div>
<p>Next, we'll go into configuration mode and check out our current config. If the hosts file and such has been setup properly, there should only be two nodes listed. If there is more than two, you'll need to go back and run through the setup steps again.</p>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>crm(live)# configure
crm(live)configure# show
node asterisk-scf_active
node asterisk-scf_standby
property $id="cib-bootstrap-options" \
dc-version="1.0.9-cebe2b6ff49b36b29a3bd7ada1c4701c7470febe"
cluster-infrastructure="openais" \
expected-quorum-votes="2"
</pre>
</div></div>
<p>Now we're going to turn of the stonith support since we don't need it at the moment and it generates a lot of warnings. We'll also be setting resource stickiness, quorum policy, and resource preference to the first node.</p>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>crm(live)configure# property stonith-enabled=false
crm(live)configure# property no-quorum-policy="ignore"
crm(live)configure# property default-resource-stickiness="infinity"
crm(live)configure# location cli-prefer-failover-ip failover-ip rule $id="cli-prefer-rule-failover-ip" inf: #uname eq node1
</pre>
</div></div></li>
                <li><h6><a name="Failover-Linux-ConfiguringthesharedIPaddress"></a>Configuring the shared IP address</h6>
                <ul>
                        <li><h6><a name="Failover-Linux-IPv4sharedipaddress"></a>IPv4 shared ip address</h6>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>crm(live)configure# primitive failover-ip ocf:heartbeat:IPaddr params ip=<shared ip goes here> op monitor interval=2s
</pre>
</div></div></li>
                        <li><h6><a name="Failover-Linux-IPv6sharedipaddress"></a>IPv6 shared ip address</h6>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>crm(live)configure# primitive failover-ip ocf:heartbeat:IPv6addr params ip=<shared ip goes here> op monitor interval=2s
</pre>
</div></div></li>
                </ul>
                </li>
                <li><h6><a name="Failover-Linux-Verifyourconfigurationandsave"></a>Verify our configuration and save</h6>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>crm(live)configure# verify
</pre>
</div></div>
<p>Assuming all is good, we'll exit and save.</p>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>crm(live)configure# end
There are changes pending. Do you want to commit them? y
crm(live)# quit
bye
asterisk-scf_active:~#
</pre>
</div></div></li>
                <li><h6><a name="Failover-Linux-Checkourclusterstatus"></a>Check our cluster status</h6>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>asterisk-scf_active:~# crm_mon --one-shot
============
Last updated: Fri Sep 24 14:05:51 2010
Stack: openais
Current DC: asterisk-scf_active - partition with quorum
Version: 1.0.9-cebe2b6ff49b36b29a3bd7ada1c4701c7470febe
2 Nodes configured, 2 expected votes
1 Resources configured.
============
Online: [ asterisk-scf_active asterisk-scf_standby ]
failover-ip (ocf::heartbeat:IPaddr): Started asterisk-scf_active
</pre>
</div></div></li>
        </ul>
        </li>
</ol>
<h2><a name="Failover-Linux-Credits%2FReferences"></a>Credits / References</h2>
<p>Cluster Labs - <a href="http://www.clusterlabs.org/wiki/Debian_Lenny_HowTo" class="external-link" rel="nofollow">http://www.clusterlabs.org/wiki/Debian_Lenny_HowTo</a></p>
</div>
<div id="commentsSection" class="wiki-content pageSection">
<div style="float: right;">
<a href="https://wiki.asterisk.org/wiki/users/viewnotifications.action" class="grey">Change Notification Preferences</a>
</div>
<a href="https://wiki.asterisk.org/wiki/display/TOP/Failover+-+Linux">View Online</a>
|
<a href="https://wiki.asterisk.org/wiki/pages/diffpagesbyversion.action?pageId=5243852&revisedVersion=15&originalVersion=14">View Changes</a>
|
<a href="https://wiki.asterisk.org/wiki/display/TOP/Failover+-+Linux?showComments=true&showCommentArea=true#addcomment">Add Comment</a>
</div>
</div>
</div>
</div>
</div>
</body>
</html>