Search code examples
postgresqlkamailio

Connect Kamailio with PostgreSQL


I have a specific situation where I need to connect Kamailio to PostgreSQL DB rather than MySQL. Can someone please provide the step for that. Tried multiple steps from the forum but it failed.

Problem faced: whenever kamailio creates the database in PostgreSQL it keeps on asking the password and ultimately it fails.

Ubuntu version: 16.04 LTS Kamailio: 5.0

I have done following things so far: 1. Included the postgre modules 2. Modified kamailio.cfg and added following lines:

#!ifdef WITH_PGSQL
# - database URL - used to connect to database server by modules such
#       as: auth_db, acc, usrloc, a.s.o.
#!ifndef DBURL
#!define DBURL "postgres://kamailio:password@localhost/kamailio"
#!endif
#!endif

This is my file kambdctlrc:

# The Kamailio configuration file for the control tools.
#
# Here you can set variables used in the kamctl and kamdbctl setup
# scripts. Per default all variables here are commented out, the control tools
# will use their internal default values.

## your SIP domain
SIP_DOMAIN=sip.<DOMAIN>.net

## chrooted directory
# $CHROOT_DIR="/path/to/chrooted/directory"

## database type: MYSQL, PGSQL, ORACLE, DB_BERKELEY, DBTEXT, or SQLITE
# by default none is loaded
#
# If you want to setup a database with kamdbctl, you must at least specify
# this parameter.
DBENGINE=PGSQL

## database host
DBHOST=localhost

## database host
# DBPORT=3306

## database name (for ORACLE this is TNS name)
DBNAME=kamailio

# database path used by dbtext, db_berkeley or sqlite
# DB_PATH="/usr/local/etc/kamailio/dbtext"

## database read/write user
DBRWUSER="kamailio"

## password for database read/write user
DBRWPW="password"

## database read only user
DBROUSER="kamailioro"

Thanks in advance !!


Solution

  • Finally, we have figured out the issue, It was a small mistake in .pgpass file which eventually creating authentication problem.