Install And Maintain Kamailio (OpenSER) v3.0.x From GIT

Install And Maintain Kamailio (OpenSER) v3.0.x From GIT

Install And Maintain Kamailio (OpenSER) v3.0.x From GIT

Install And Maintain Kamailio (OpenSER) v3.0.x From GIT

<span style="font-family:Times New Roman;font-size:18px;">Main author:
   Daniel-Constantin Mierla <miconda (at) gmail.com></span>

Thisis a step by step tutorial about how to install and maintain Kamailio(OpenSER) using the sources from GIT. Even it is more complex toinstall, it is easier to maintain. Installation is done once whilemaintenance has to be done each time a new issue was discovered andfixed. Using the GIT, you get access to the latest code very quickly.

This document focuses on Kamailio (OpenSER) v3.0.0 with MySQL support, using a Debian unstable system.

Kamailio 3.0.0 was released on January 11, 2010:

  • release notes are available here
  • what is new:
    • http://www.kamailio.org/dokuwiki/doku.php/features:new-in-3.0.x

1. Prerequisites

To be able to follow the guidelines from this document you need root access.

The following packages are required before proceeding to the next steps.

  • git client:apt-get install git-core - it is recommended to have the latestversion, which might not be part of the distribution yet, but you canget it from: http://git-scm.com/
  • gcc compiler: apt-get install gcc
  • flex - apt-get install flex
  • bison - apt-get install bison
  • libmysqlclient15-dev - apt-get install libmysqlclient15-dev
  • make - apt-get install make
  • libcurl - apt-get install libcurl4-openssl-dev
  • libxml2 - apt-get install libxml2-dev
  • libpcre3 - apt-get install libpcre3-dev

2. Getting sources from GIT

First of all, you have to create a directory on the file system where the sources will be stored.

<span style="font-family:Times New Roman;font-size:18px;">  mkdir -p /usr/local/src/kamailio-3.0.0
  cd /usr/local/src/kamailio-3.0.0</span>

Download the sources from GIT using the following commands.

<span style="font-family:Times New Roman;font-size:18px;">  git clone --depth 1 git://git.sip-router.org/sip-router kamailio
  cd kamailio
  git checkout -b kamailio_3.0 origin/kamailio_3.0</span>

3.Tuning Makefiles

Next step is to enable the MySQL module.

<span style="font-family:Times New Roman;font-size:18px;">  make cfg
  nano -w modules.lst</span>

Remove db_mysql from the variable exclude_modules.

Save the modules.lst and exit.

NOTE:this is the mechanism to enable modules which are not compiled bydefault, such as lcr, dialplan, presence – remove the module from exclude_modules variable inside themodules.lst file.

Alternative is to use 'include_modules' variable to specify what extra modules to be included for compilation:

<span style="font-family:Times New Roman;font-size:18px;">make include_modules="db_mysql dialplan" cfg</span>

If you want to install everything in one directory, say /usr/local/kamailio-3.0, then use:

<span style="font-family:Times New Roman;font-size:18px;">make prefix="/usr/local/kamailio-3.0" include_modules="db_mysql dialplan" cfg</span>

More hints about Makefile system at:

  • http://sip-router.org/wiki/tutorials/makefile-system

4. Compile Kamailio (OpenSER)

Once the mysql module was removed from excluded modules list, you can compile Kamailio (OpenSER).

<span style="font-family:Times New Roman;font-size:18px;">  make all</span>

You can get a nicer output of the compilation process using:

<span style="font-family:Times New Roman;font-size:18px;">  make Q=1 all</span>

5. Install Kamailio (OpenSER)

When the compilation is ready, install Kamailio (OpenSER) with the following command:

<span style="font-family:Times New Roman;font-size:18px;">  make install</span>

6. What and where was installed

The binaries and executable scripts were installed in:

<span style="font-family:Times New Roman;font-size:18px;">  /usr/local/sbin</span>

These are:

  • kamailio - Kamailio (OpenSER) server
  • kamdbctl - script to create and manage the Databases
  • kamctl - script to manage and control Kamailio (OpenSER) server
  • sercmd - CLI - command line tool to interface with Kamailio (OpenSER) server

Tobe able to use the binaries from command line, make sure that'/usr/local/sbin' is set in PATH environment variable. You can checkthat with 'echo $PATH'. If not and you are using 'bash', open'/root/.bash_profile' and at the end add:

<span style="font-family:Times New Roman;font-size:18px;">  PATH=$PATH:/usr/local/sbin
  export PATH</span>

Kamailio (OpenSER) modules are installed in:

<span style="font-family:Times New Roman;font-size:18px;">  /usr/local/lib/kamailio/modules/
  /usr/local/lib/kamailio/modules_k/</span>

The documentation and readme files are installed in:

<span style="font-family:Times New Roman;font-size:18px;">  /usr/local/share/doc/kamailio/</span>

The man pages are installed in:

<span style="font-family:Times New Roman;font-size:18px;">  /usr/local/share/man/man5/
  /usr/local/share/man/man8/</span>

The configuration file was installed in:

<span style="font-family:Times New Roman;font-size:18px;">  /usr/local/etc/kamailio/kamailio.cfg</span>

7. Create MySQL database

To create the MySQL database, you have to use the database setup script:

<span style="font-family:Times New Roman;font-size:18px;">  /usr/local/sbin/kamdbctl create</span>

In order to create the database you need to specify the wanted db type (DBENGINE=MYSQL) in the

<span style="font-family:Times New Roman;font-size:18px;">  /usr/local/etc/kamailio/kamctlrc</span>

file.Call this script without any parameter to get some help for the usage.You will be asked for the domain name Kamailio (OpenSER) is going toserve (e.g., mysipserver.com) and the password of the 'root' MySQLuser. The script will create a database named 'openser' containing thetables required by Kamailio (OpenSER). You can change the defaultsettings in the kamctlrc file mentioned above.

The script will add two users in MySQL:

openser - having the password 'openserrw', user which has full access rights to 'openser' database

openserro - having the password 'openserro', user which has read-only access rights to 'openser' database

Do change the passwords for these two users immediately after the database is created.

8. Edit configuration file

To fit your requirements for the VoIP platform, you have to edit the configuration file.

<span style="font-family:Times New Roman;font-size:18px;">  /usr/local/etc/kamailio/kamailio.cfg</span>

Followthe instruction in the comments to enable usage of MySQL. Basically youhave to add several lines at the top of config file, like:

<span style="font-family:Times New Roman;font-size:18px;">#!define WITH_MYSQL
#!define WITH_AUTH
#!define WITH_USRLOCDB</span>

If you changed the password for the 'openser' user of MySQL, you have to update the value for 'db_url' parameters.

You can browse kamailio.cfg online on GIT repository.

9. The init.d script

Theinit.d script can be used to start/stop the Kamailio (OpenSER) serverin a nicer way. A sample of init.d script for Kamailio (OpenSER) isprovided at:

<span style="font-family:Times New Roman;font-size:18px;">  /usr/local/src/kamailio-3.0.0/pkg/kamailio/debian/kamailio.init</span>

Just copy the init file into the /etc/init.d/kamailio. Then change the permisions:

<span style="font-family:Times New Roman;font-size:18px;">  chmod 755 /etc/init.d/kamailio </span>

then edit the file updating the $DAEMON value:

<span style="font-family:Times New Roman;font-size:18px;">  DAEMON=/usr/local/sbin/kamailio</span>

You need also setup a configuration file in the /etc/default/ directory. This file can be found at:

<span style="font-family:Times New Roman;font-size:18px;">  /usr/local/src/kamailio-3.0.0/pkg/kamailio/debian/kamailio.default</span>

Youneed to rename the file to 'kamailio' after you've copied it. Then editthis file and set RUN_KAMAILIO=yes. Edit the other options at yourconvenience.

Create the directory for pid file:

<span style="font-family:Times New Roman;font-size:18px;">mkdir -p /var/run/kamailio</span>

Default setting is to run Kamailio as user “kamailio” and group “kamailio”. For that you need to create the user:

<span style="font-family:Times New Roman;font-size:18px;">adduser --quiet --system --group --disabled-password \
        --shell /bin/false --gecos "Kamailio" \
        --home /var/run/kamailio kamailio

# set ownership to /var/run/kamailio
chown kamailio:kamailio /var/run/kamailio</span>

Then you can start/stop Kamailio (OpenSER) using the following commands:

<span style="font-family:Times New Roman;font-size:18px;">  /etc/init.d/kamailio start
  /etc/init.d/kamailio stop</span>

10. Ready to rock

Now everything is in place. You can start the VoIP service, creating new accounts and setting the phones.

Anew account can be added using 'kamctl' tool via 'kamctl add<username> <password> <email>'. (or try without theemail)

<span style="font-family:Times New Roman;font-size:18px;">kamctl add test testpasswd [email protected]</span>

If you are asked for SIP_DOMAIN environment variable do one of the following option.

<span style="font-family:Times New Roman;font-size:18px;">  1.
  export SIP_DOMAIN=mysipserver.com

  2.
  edit '/root/.kamctlrc' and add:
  SIP_DOMAIN=mysipserver.com</span>

11. Maintenance

The maintenance process is very simple right now. You have to be user 'root' and execute following commands:

<span style="font-family:Times New Roman;font-size:18px;">  cd /usr/local/src/kamailio-3.0.0/kamailio
  git pull origin
  make all
  make install
  /etc/init.d/kamailio restart</span>

Now you have the latest Kamailio (OpenSER) v3.0.0 running on your system.

12. Time for maintenance service

Notification about GIT commits are sent to the mailing list: [email protected]. Each commit notification contains the reference to the branch where the commit has been done. If the commit message contains the lines:

<span style="font-family:Times New Roman;font-size:18px;">Module: sip-router
Branch: kamailio_3.0</span>

then an update has been made to Kamailio (OpenSER) version 3.0.x and it will be available to the public GIT in no time.


你可能感兴趣的:(mysql,File,git,database,compilation)