Tuesday, December 6, 2011

How to build an Asterisk Cluster

How to build an Asterisk Cluster


Intuit is conducting a first online-workshop via WebEx about building a Asterisk-Cluster.
This first workshop focuses on a Active-Passive setup.
(The next workshop will cover a large Active-Active setup with multiple Asterisk, DB and Load Balance servers.)

Details:

Date/Time: Friday, 20. May 2009 at 8 AM, GMT +8 (Kuala Lumpur Time... )
Duration: 2 hours (depends on how many questions we have..)
Topics covered:
- How to choose your hardware (Servers and PSTN equipment, we will use a FoneBridge from Redfone)
- How to prepare your OS for cluster (we use Debian 5 in the workshop)
- Asterisk standard vanilla installation (we will use our install script)
- Explain the concept of DRBD and Heartbeat
- Configure DRBD and Heartbeat
- Test the cluster
- Discussion
Cost: FOC (you can buy me a beer if you are in Kuala Lumpur)
Please e-mail me or Marco if you want to join the seminar and we will send you the meeting-invite!
Marco: marco@intuitinnovations.com
Daniel: daniel@intuitinnovations.com
Cheers
Daniel



Asterisk High Availability HOWTO with Heartbeat and Redfone fonebridge

Overview
The following is a brief HOWTO for installing High-Availability Asterisk using Open Source tools combined with fail-over capable & intelligent hardware (the fonebridge).
The heartbeat utility is used in a 'Passive-Active' scenario but could easily be modified to do 'Active-Active'.

Background
Some of our more demanding customers in the Call Center and Banking Industry are loathe to accept an implementation with no mechanism for fail-over and high-availability so this is the hardware/software combination we are using to meet their demands.

Client Background
The following scenario was used for a medium sized call center operation with about 60 analog stations, and a single T1 PRI.

Hardware
  • 2 x 1U Supermicro Servers (P4, 512Mb, Dual Gig Eth, Dual SATA with RAID 0)
  • 1 x Redfone Quad T1 fonebridge to terminate PRI connectivity, power channel banks and provide fail-over capability between the two Supermicros.
  • 1 x T1 PRI
  • 3 x Adtran 750 FXS channel banks to drive analog phones
  • 2 x UPS/Surge Protectors

Software
  • Fedora Core 4
  • Asterisk, zaptel, libpri from CVS head
  • Linux HA software suite from Ultramonkey. They have RPMs for RHE3 that install fine on Fedora Core 4
  • Each server is a mirror image of the other in terms of Asterisk configs and software.

Software Install
After a standard install of FC4, Asterisk, zaptel, libpri we installed all of the packages from Ultramonkey pretty much following their guidelines: http://www.ultramonkey.org/3/installation-rh.el.3.html
You may have a few dependencies issues, mainly perl libs, but we were able to satisfy all of them by using Yum. If you are running Apt you should be able to accomplish the same thing.

Configuring Hearbeat
After installing heartbeat there are only three files that need to be modified for your environment. They are ha.cf, haresources and authkeys. They should all be placed in the /etc/ha.d/ directory. The files should be absolutely identical on all machines that are part of your Asterisk high-availability cluster. We only have two servers running but you could easily scale to more using the exact same configurations. These are our config files. All comment lines have been removed but as you can see they are short and simple.

ha.cf
debugfile /var/log/ha-debug
logfile /var/log/ha-log
logfacility local0
keepalive 200ms
deadtime 2
warntime 1
initdead 120
udpport 694
bcast eth0
node asterisk1
node asterisk2

haresources
asterisk1 10.10.10.110 fonulator asterisk

authkeys
auth 1
1 sha1 SuPerS&cretP@$$werd

Operation
Each Asterisk server has a unique IP address which is part of the LAN segment. This could be a NATed network or Internet facing with public IP addresses. Heartbeat manages the monitoring of the hardware state of each machine over Ethernet or serial port or a combination of both (recommended) and assigns the Virtual IP to the Asterisk server which is currently in an active state. Example;

Asterisk1= 10.10.10.100
Asterisk2= 10.10.10.120
Virtual IP= 10.10.10.110 (see haresources)

With Heartbeat it is important that your node names are identical to the host names reflected in #uname -n. You also may need to manually add IP/hosts statements to your /etc/hosts file so each machine knows how to reach the other via IP.

Following the rules in haresources, Heartbeat will assign machine name asterisk1 as the primary server when both systems start up. It will then start the following scripts; fonulator (this is the little script that configures the fonebridge) and asterisk which starts the Asterisk server. These are both standard startup scripts placed in /etc/init.d/ .
If the Primary server suffers a hardware fault or simply stops responding to the heartbeats going between the two nodes asterisk2 will execute /etc/init.d/fonulator start to reconfigure the fonebridge on the fly and begin redirecting traffic to asterisk2 followed by /etc/init.d/asterisk start to start the Asterisk server.

Results
With heartbeat, IP takeover occurs in under a second. The fonulator utility re-configures the fonebridge in just about the same amount of time and then depending on your hardware platform and the complexity of apps running in Asterisk it can take between 5-15 seconds for Asterisk to start up on your secondary server, load all config files, clear alarms and be ready to process calls. Total fail-over time about 15-20 seconds.

Resources
Ultramonkey http://www.ultramonkey.org (High Avail software packages)
Linux HA http://www.linux-ha.org (The High Availability Linux Project)
Redfone http://www.red-fone.com (Maker of the Quad T1/E1 fonebridge)

2 comments:

  1. This article is obviously 4 years old....redfone is bankrupt and Asterisk has changed a lot. More options now: http://www.voip-info.org/wiki/view/Asterisk+High+Availability+Solutions

    ReplyDelete
  2. it's possible to make a cluster where two servers asterisk function at the same time by using a load balancer

    ReplyDelete