$doc = $_SERVER['DOCUMENT_ROOT']; ?>$title = "";$metad = "";$metak = "";$closing = "";$h1 = "";$h2 = "";$template = "";$section = "";echo "Document: ".$doc;?> include("$doc/includes/header.php");?>
firstname.lastname@example.org (you can contact me anytime :-) )
Document Version: 1.0 Date: 30. May 2007
This tutorial will help you to build a cluster with two Asterisk server, two Redfone FoneBridges with one PRI (E1) each. The idea behind this cluster is if one of the server’s and one of the FoneBridge’s fails the user is still able to conduct phone calls.
The fail-over will happen automatically within a couple of seconds. The Asterisk servers are in an active-passive cluster relationship.
For this tutorial we will name the two servers:
Everything written on the Master or Slave server will be immediately replicated to the other machine. Therefore if you cerate a extension on the master the extension will be automatically “created” on the slave, and so on… For this synchronization we will use DRBD, which will help us to build a network RAID 1. To monitor our servers if there are up and running we will use Heartbeat, a Linux tool to build high availability systems. In our scenario each of the Asterisk servers has two network cards (NIC’s). The second network card (ETH1) on both
servers is connected to a switch. This NIC’s will handle the normal traffic between IP phones and the Asterisk server. You can give them the following IP-Addresses:
We will need a third IP address in the 192.168.0.201.xxx range this will be our floating or virtual IP-Address. Our floating IP-Address is:
The two other NIC’s (ETH0) on both Asterisk servers are connected via crossover cable. Please be aware that if you use 100Mbit NIC’s you effective shared drive speed will not be more than 10 MBit/s. So if you like to synchronize a large RAID 1 it can initially take a long while to do that. I recommend that you use GBit NIC’s for the DRBD synchronization.
Pitifully, Trixbox 1.2.3 doesn’t allow user to setup partition during the installation process. The default installation will create the following partitions:
For our synchronization we need a additional dedicated partition, therefore we need to crate a new one and re-partition our current systems (AsteriskMaster and AsteriskSlave).
After that, you should get a shell prompt.
A little remark: commands may differ depending on type of HDD. If you have SATA or SCSI drive installed, then do as said. For IDE drive, substitute “hda”<->“sda” everywhere.
So, the math is easy. For example, you have a 8.5Gb hard drive. You decide to create 512Mb of swap, 4Gb DRBD and rest of the drive for main partition. So, main partition should be 4Gb. But due to bug(or feature) in resize2fs(or fdisk?), multiply main partition size by 0.75 , and that will be our file system size. For our example, you need to resize fs to 3000M.
• When done, you should see something like that: ? Now we run run fdisk /dev/sda. Press “p” and enter. You should see the following output. Pls. write down on which cylinder sda2 starts! In this case it’s cylinder 14.
In this step we will create the swap and DRB partition.
You can reboot your machines now, and boot back into “normal” mode.
The software package provided from my blog with this tutorial is preconfigured. You need to adjust some of the configuration files for your environment.
Download the ha.tar.gz2 file from my blog.
If you use a single CPU machine download this file
If you use a multi CPU machine download this file
Create a new directory in your root directory. # mkdir ha Download, and Unpack the downloaded files into this new ha directory.
# cd ha
# wget http://www.danielaliaman.com/blog/files/phonecube/cluster/onecpu/ha.tar.bz2
# tar –xvfj http://www.danielaliaman.com/blog/files/phonecube/cluster/onecpu/ha.tar.bz2
Attention: you must create the ha directory in the root directory of your servers, if not the installation scripts will not work! The scripts will only work with a Trixbox 1.2.3 installation. If you install on a later Trixbox or plain Asterisk installation, you need to modify the scripts.
Before we can install these packages you need to do some “pre-flight” checks.
192.168.0.1. You want to change that, so edit ha.d/haresources .
7) When synchronization is finished, you’ll see the following on the primary server:
DRBD is up and working! Let’s install HeartBeat.
If you run a ifconfig eth1:0 you should see the floating IP-address 192.168.0.203 bounf to the eth1 of the primary server.
• Now, let’s test the cluster! Just turn power off the Primary node. In a couple of seconds all the services and ethernet interface alias on Secondary node should be up. Now start Primary node. After it boots, all services on Secondary node should go down, and come up on Primary node.
The ha-cluster is ready for work.
Make sure that your FoneBridge’s are isolated in a VLAN (at least for the production environment).
Rules: VLAN1 can communicate with VLAN2 and vice-versa VLAN1 can not communicate / broadcast into VLAN3 VLAN2 and VLAN3 can communicate with each other
The main goal is to isolate the FoneBridge TDMoE-Traffic from the rest of the network.
To run TDMoE with the Redfone FoneBridge’s we need to patch a small bug in the kernel-source code.
To that you need to install the kernel source first.
If you use a single CPU machine download this file:
If you use a multi CPU machine download this file:
Copy this file on both servers into the /tmp directory.
Install the file with the RMP command: # rmp –ihv [filename] In case of a single CPU machine it would be like # rpm –ihv kernel-devel-2.6.9-34.0.2.EL.i686.rpm No we need to patch the kernel-source. # cd /usr/src/kernels/2.6.9-34.0.2.EL-i686/include/linux
(you need to adjust the path if you use multi cpu)
# mv spinlock.h spinlock.h.orig
# sed "s/rw_lock_t/rwlock_t/" < spinlock.h.orig > spinlock.h
Now we can re-install and re-compile the Zaptel driver.
Download the Zaptel-1.2.12 driver for FoneBridge from:
Copy this file into the tmp directory and untar it.
# tar –xzvf zaptel-1.2.12
# cd /usr/src/zaptel1.2.12
# make clean # make linux26 # make install # modprobe Zaptel Do this step on both machines, when done reboot the machines. # shutdown –r now
To make the FoneBrigdes boxes work, you need to do a couple of installation steps. In a first step you need to download, compile and install the Fonulator software. This software will basically
send the configuration information (from the redfone.conf files) to the Redfone box. As soon the Redfone box receives it’s configuration file it will start fonulating back to server. The communication is based on TDMoE (Time Division Multiplexing over Ethernet) via MAC-addresses. But first you download the fonulator software from here:
Unpack the archive #tar -xzvf fonulator-0.2.4d.tar.gz Change to fonulator-0.2.4d directory #cd fonulator-0.2.4d Configure and build fonulator
#CFLAGS=-static ./configure #make clean #make #make install
This last step will place the fonulator in the /usr/local/bin/ directory Make sure that fonulator is executable # cd /usr/local/bin
# chmod a+x fonulator This installation needs to be done on both machines
Download the fonulator startup script
copy this file into /etc/init.d/ directory on both machines
Make sure the file can be executed
# cd /etc/init.d
# chmod a+x fonulator
Next you need to download the two redfone.conf files:
Copy this two files into /etc/ directory on both machines
You need to adjust this two files to fit your hardware.
[globals] fb1=00:50:C2:65:D1:62 fb2=00:50:C2:65:D1:63 server1=00:1A:64:11:3B:76 card=eth1,fb1
[span1] span=1,0,0,ccs,hdb3,crc4 server1 fb1 pri
Change fb1 and fb2 to the MAC address written on the back of your first FoneBridge. Change server1 to the MAC address of your eth1 network card Attention: the server1 parameter on the slave will have different MAC address, therefore redfone1.conf and redfone2.conf are different on the master and slave!
fb1=00:50:C2:65:D1:6A fb2=00:50:C2:65:D1:6B server1=00:1A:64:11:3B:76 card=eth1,fb1
[span1] span=1,0,0,ccs,hdb3,crc4 server1 fb1 pri
Change fb1 and fb2 to the MAC address written on the back of your second FoneBridge. Change server1 to the MAC address of your eth1 network card Attention: the server1 parameter on the slave will have different MAC address, therefore redfone1.conf and redfone2.conf are different on the master and slave!
The fonulator script in /etc/init.d will use this two config files to initialize the fonebridges.
Download the zaptel.conf from here:
and copy it into /etc/ directory
This zaptel.conf is configured for two fonebridges with one E1 line each.
# 2 X E1 PRIs, on 2 separate fonebridges # # fonebridge No. 1 # dynamic=eth,eth1/00:50:C2:65:D1:62/0,31,1 # # fonebridge No. 2 # dynamic=eth,eth1/00:50:C2:65:D1:6A/0,31,1 # bchan=1-15,17-31 dchan=16 alaw=1-15,17-31 bchan=32-46,48-62 dchan=47 alaw=32-46,48-62
# Global data
loadzone = us defaultzone = us
Please adjust the MAC addresses according to your FoneBridge MAC addresses. You only need to configure the MAC address of the FB1 interface of each FoneBridge. Now you need to download the Zapata.conf file from: http://www.danielaliaman.com/blog/files/phonecube/cluster/zapata.conf Copy zapata.conf into the /etc/asterisk/ directory You need to do that on both machines.
No you need to edit the haresources file on both machines. # vi /etc/ha.d/haresources
asteriskmaster.local 192.168.0.203/24/eth1 drbddisk::shared Filesystem::/dev/drbd0::/share::ext3 drbdlinks mysqld sendmail asterisk httpd munin-node vsftpd ircd xplhub amportal xinetd
change this file to
asteriskmaster.local 192.168.0.203/24/eth1 drbddisk::shared Filesystem::/dev/drbd0::/share::ext3 drbdlinks mysqld sendmail fonulator asterisk httpd munin-node vsftpd ircd xplhub amportal xinetd This will start the fonulator script via the cluster software.
Power-Up the FoneBridge’s and make sure they are connected to the switch. The restart both machines. If the servers are restarted login into the master server and run the following
command: # zttool
You should see the two SPAN and the alarms should be cleared.