Thursday, July 5, 2012

OpenSIPS/Kamailio High Availability Clustering - 1

Using Heartbeat

I've been implementing SIP proxies (Either Kamailio or OpenSIPS) for some time now. These SIP proxies were mainly used to Load-balance the Media-Servers (Asterisks, FreeSWITCH mainly) and detect if any of the Media-Server is down and send its calls to some other available media-server. Thus we don;t need to worry about any of the Asterisk or FreeSWITCH crashes anymore.

But now the Single Point of Failure is the SIP proxy. If our SIP proxy application crashes or the server drops dead then we're nowhere !

In this post we will create a High-Available cluster of SIP proxy. There will be minimum of two SIP proxy servers (Physically unique) in one cluster.

One of the node will be defined as the primary node and our set of applications will run on the primary server. If the application set fails on primary node then our HearBeat will first try to restart it. If the restarting retries fails then it migrates the group of applications to the secondary node or any other node in the cluster.

HA Resources

The Set/Group of services which run on the any node in cluster are as follows (Priority in the order written)

1- Floating/Virtual IP
This IP is basically the only Public IP assigned on the cluster node. SIP proxy Listens to this address.

2- Linux Default Route

This will use Virtual IP configurations and use it as only way In&Out of Server to Internet.

3- SIP proxy

kamailio or OpenSIPSThis is the primary application which will be monitored for any crashes.

4- Add on Applications

Any other applications which are required in combination with SIP proxy and need to be started along with the SIP proxy i.e RTPproxy or Media-Proxy or any other application.


Setup Details
What this setup requires is atleast two physically unique serverswith atleast two NICs. eth0 IP of each server will have a unique Private IP, eth1 of both will be unused. The most important thing to mention here is that we don't set default-gateway on these machines. We can only access these machine from anyother third machine on Private IPs.

The only way these machines connect to internet is that they become primary node. When they become primary node the Public IP is assigned on eth1 and then default-gateway is set by the heartbeat application.
Once the default-gateway is set on primary node only then internet is accessible.


Setup Diagram

SIP proxy HA design

We have a separate independent Database for SIP proxy servers to save the User-Location Records. In case of primary server failure the secondary servers connects to the same DB and have all the registered users and active calls record in DB already. This is the key for this setup to work.

Read on to this blog's Second part on creating such a setup.

3 comments:

  1. Hi,

    i think you should also mention configuration of stonith which is maybe the most importent thing in HA configuration. Whitout it is just not right HA ;)

    ReplyDelete
    Replies
    1. Thanks for your valuable comment; I suggest you to please go thought the second part which has everything you need to setup HA.
      http://saevolgo.blogspot.com/2013/05/opensipskamailio-high-availability.html
      Let me know if that is the right HA or not!!?

      Delete
  2. The only one Database for User-Location Records may fail.

    ReplyDelete