Wednesday, September 7, 2011

Asterisk Failover Solution (IP Failover Solution)

Simplest way to setup a redundant asterisk system is by using UCARP application

If creates a vitual IP that will be assigned for the external world to use.

Here is my setup ,I have two machines on which asterisk is installed.

Master 192.168.0.201

Slave 192.168.0.202

Now I will create Virtual IP 192.168.0.250

Steps :

1.First thing is to install a ucarp packages to both machines this needs

Dependency : needs libpcap and libpcap-devel

Yum install libpcap libpcap-devel

This was the error when I tried to installed ucarp with installing libpcap libraries.

 
clip_image002
This shows pcap.h is missing i.e pcap library not installed.

2.Install UCARP on both machine

wget http://download.pureftpd.org/pub/ucarp/ucarp-1.5.1.tar.bz2

tar xvf ucarp-1.5.1.tar.gz

cd ucarp-1.5.1

./configure
make install-strip
 
Once installed on both the servers ucarp should be available in /usr/local/sbin/ucarp
 
 
3.Now Make Two scripts on both machine that will run whenever a UCARP Detects that other is not available so it should takeover.
/etc/vip-up.sh
#!/bin/bash
/sbin/ip addr add 192.168.0.250/24 dev eth0
arping -U –c 3 -I eth0 192.168.0.250
 
/etc/vip-down.sh
#!/bin/bash

/sbin/ip addr del 192.168.0.200/24 dev eth0
 
Note : 
1.#!/sbin/bash is necessary otherwise it will show exec format error
2.Since Router or pc caches the arp ,they might have old mac address of virtual ip ,so gratuitous arp has to be send to clear arp tables.so added arping on up screen.
 
4.Make them executable 
Chmod +x /etc/vip-up.sh
Chmod +x /etc/vip-down.sh
 
5.Now from Server1 (let it be Master)
/usr/local/sbin/ucarp -v 42 -P -p somepasswd -a  192.168.0.250 –s  192.168.0.201 –-upscript=/etc/vip-up.sh -–downscript=/etc/vip-down.sh  &
  
& From Server 2 run this command
 

No comments:

Post a Comment

Featured Post

XDP - Getting Started with XDP (Linux)