Friday, January 16, 2015

Kamailio v4.1 Install Guide for CentOS 6


Source: http://dopensource.com/kamailio-quick-install-guide/

Prerequisites

  • CentOS 6.x (we built this using CentOS 6.5 64 bit)

 Installation

You can install Kamailio from source or from packages.  I decided to install via yum because I wanted to show how quick and easy it is to get Kamailio installed and running.

Setup YUM Repository

  1. First let’s download the yum repo file for our Cent OS version. 
# wget http://download.opensuse.org/repositories/home:/kamailio:/telephony/CentOS_CentOS-6/home:kamailio:telephony.repo
2.   Now let’s move it to the yum repo directory so we can use it.
# mv home:kamailio:telephony.repo /etc/yum.repos.d/
3.   Make sure the system is up to date before we start installing things.
# yum update
4.   You can look at the Kamailio packages in the YUM repository by typing:
# yum search *Kam*
Install Kamailio and Required Database Modules
# yum install -y kamailio kamailio-mysql kamailio-debuginfo kamailio-unixodbc kamailio-utils

Install MySQL

1.   Since we plan on using MySQL, we will need to instal the MySQL server as well as the client.
# yum install -y mysql-server mysql
2.   Next we need to start up MySQL:
# service mysqld start
3.   Now we can set a root password for mysql:
# mysqladmin -u root password 

Configure Kamailio to use MySQL

By default, Kamailio does not use MySQL. To change this we need to edit one of Kamailio’s configuration files.
# vi /etc/kamilio/kamctlrc
1.   Uncomment the DBENGINE parameter by removing the pound symbol and make sure the value equals MYSQL.  The parameter should look like this afterwards:
DBENGINE=MYSQL

Create the Kamailio Database Schema

The command will create all of the users and tables need by Kamailio.  You will be prompted to put in the MySQL root password that you created in the Install MySQL section of this document.  You will be asked if you want to install different tables – just say “yes” to all the questions.
# /usr/sbin/kamdbctl create
Below are all the prompts you will be presented:
MySQL password for root: ‘
Install presence related tables? (y/n):
Install tables for imc cpl siptrace domainpolicy carrierroute userblacklist htable purple uac pipelimit mtree sca mohqueue rtpproxy? (y/n):
Install tables for uid_auth_db uid_avp_db uid_domain uid_gflags uid_uri_db? (y/n):
The following MySQL users and passwords are created (please change these in a production environment).
  • kamailio - (with default password ‘kamailiorw’) – user which has full access rights to ‘kamailio’ database
  • kamailioro - (with default password ‘kamailioro’) – user which has read-only access rights to ‘kamailio’ database

Start the Kamailio Server

# service kamailio start

Test Kamailio

In order to test that Kamailio is working correctly, I’m going to create a SIP user account and register that account using a softphone such as X-Lite or Zoiper.

Creating SIP User Accounts

The following command will create a new SIP User.  Note, that the domain portion has to be specified unless you export the SIP_DOMAIN environment variable.
# kamctl add  
Here is what I created
# kamctl add 1001@lextertech.com easypassword123

Registering a SIP Softphone

I configured X-Lite with the following information:
User ID: 1001
Domain: 
Password: o
Make a Test Call
You can call yourself by entering 1001 in the X-Lite phone.  If it rings then you have a basic Kamailio server installed and ready to be configured to provide load balancing, failover, accounting, etc.  As an exercise, you should create another SIP user account and register that user using another softphone such as Zoiper and try calling between the two SIP users.