Asterisk for multiple PBX´s

Hi folks,

I´m looking for a solution over Asterisk for support more than one PBX in same Asterisk Server. Because we have more than one autonomous place and we need one pbx for place into only one Asterisk server.
I read documentation over Asterisk but i found information for one pbx for each server.
Can you help me with some sugestion about this??

Hello,
we are using more Asterisk 1.4.x pbxs on just one server (I just checked, 7 pbxs on the same server), these are used by our customers as virtual pbxs for services like call center and various types of ivrs, I’ve a document explaining how to setup Asterisk for this but it’s written in my native language, italian, so I’ll just post a short summary ( :wink: ) here to put you into the right direction:

  1. inside /etc/asterisk/ create a directory for each pbx, let’s call this directory pbxN;
  2. in each new directory pbxN created copy all the files of the /etc/asterisk/ directory;
  3. change the „directories„ section of /etc/asterisk/pbxN/asterisk.conf file from
[directories]
astetcdir => /etc/asterisk
astmoddir => /usr/lib/asterisk/modules
astvarlibdir => /var/lib/asterisk
astdatadir => /var/lib/asterisk
astagidir => /var/lib/asterisk/agi-bin
astspooldir => /var/spool/asterisk
astrundir => /var/run
astlogdir => /var/log/asterisk

to

[directories]
astetcdir => /etc/asterisk/pbxN
astmoddir => /usr/lib/asterisk/modules
astvarlibdir => /var/lib/asterisk/pbxN
astdatadir => /var/lib/asterisk/pbxN
astagidir => /var/lib/asterisk/pbxN/agi-bin
astspooldir => /var/spool/asterisk/pbxN
astrundir => /var/run/pbxN
astlogdir => /var/log/asterisk/pbxN
  1. be sure that each pbx uses differents ports for the various channel types and services needed, for example the Asterisk manager port of pbx1 could be 5038, for pbx2 5039, for 3 5040, the SIP listening port could be 5060 for pbx1, 5061 for pbx2 and 5062 for pbx3; you need to check and modify at least the files dundi.conf, h323.conf, http.conf, iax.conf, manager.conf, mgcp.conf, sip.cond and skinny.conf that are in each /etc/asterisk/pbxN directory;
  2. each of the pbxN pbxs need to use a different range of rtp ports, for example pbx1 uses rtp ports range 10000-10999, pbx2 11000-11999 and so on; the rtp range is setup in rtp.conf;
  3. create a directory /var/lib/asterisk/pbxN for each pbx and copy there the directories agi-bin, firmware, images, keys, moh, sounds, static-http;
  4. create a directory /var/spool/asterisk/pbxN for each pbx and copy there the directories dictate, meetme, monitor, outgoing, system, tmp, voicemail;
  5. create a directory /var/run/pbxN for each pbx;
    8 ) create a directory /var/logl/asterisk/pbxN for each pbx and copy there the directories cdr-csv e cdr-custom;
  6. this is the startup script used to start/stop/restart each pbx on our opensuse server (every script is named asterisk_pbxN):
#!/bin/sh
# $Id: asterisk,v 1.3 2005/11/17 22:30:01 Gregory Boehnlein <damin@nacs.net>
#
# asterisk    Starts, Stops and Reloads Asterisk.
#
# chkconfig: 2345 40 60
# description: Asterisk PBX and telephony daemon.
# processname: asterisk
# pidfile: /var/run/asterisk.pid
#
# Thu Nov 17 2005 Gregory Boehnlein <damin@nacs.net>
# - Updated Version to 1.3
# - Reversed behavior of LD_ASSUME_KERNEL=2.4.1
# - Added detailed failure messages
#
# Sun Jul 18 2004 Gregory Boehnlein <damin@nacs.net>
# - Updated Version to 1.2
# - Added test for safe_asterisk
# - Verified SIGTERM issued by "killproc" ensures "stop gracefully"
# - Added support for -U and -G command line options
# - Modified "reload" to call asterisk -rx 'reload' 

### BEGIN INIT INFO
# Provides:                    asterisk_pbxN
# Required-Start:	mysql
# Required-Stop:	mysql
# Default-Start:     3 5
# Default-Stop:      0 1 2 4 6
# Description: zaptel - zaptel modules for Asterisk
### END INIT INFO

# Source function library.
. /lib/lsb/init-functions

if ! [ -x /usr/sbin/asterisk ] ; then
	echo "ERROR: /usr/sbin/asterisk not found"
	exit 0
fi

if ! [ -d /etc/asterisk ] ; then
	echo "ERROR: /etc/asterisk directory not found"
	exit 0
fi

# Uncomment this ONLY if you know what you are doing.
# export LD_ASSUME_KERNEL=2.4.1

# Full path to asterisk binary
DAEMON=/usr/sbin/asterisk

# Full path to safe_asterisk script
SAFE_ASTERISK=/usr/sbin/safe_asterisk

# Uncomment the following and set them to the user/groups that you
# want to run Asterisk as. NOTE: this requires substantial work to
# be sure that Asterisk's environment has permission to write the
# files required  for  its  operation, including logs, its comm
# socket, the asterisk database, etc.
#AST_USER="asterisk"
#AST_GROUP="asterisk"

RETVAL=0

start() {
	# Start daemons.
	echo -n $"Starting asterisk: "
        if [ -f $SAFE_ASTERISK ] ; then
		DAEMON=$SAFE_ASTERISK
	fi
	if [ $AST_USER ] ; then
		ASTARGS="-U $AST_USER"
	fi
	if [ $AST_GROUP ] ; then
		ASTARGS="`echo $ASTARGS` -G $AST_GROUP"
	fi
	#$DAEMON $ASTARGS
	$DAEMON $ASTARGS -C /etc/asterisk/pbxN/asterisk.conf
	RETVAL=$?
	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/asterisk_pbxN
	echo
	return $RETVAL
}

stop() {
	# Stop daemons.
	echo -n $"Shutting down asterisk: "
	#killproc asterisk
	killproc asterisk  -p /var/run/pbxN/asterisk.pid
	RETVAL=$?
	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/asterisk_pbxN
	echo
	return $RETVAL
}

restart() {
	stop
	start
}

reload() {
	$DAEMON -rx 'reload' > /dev/null 2> /dev/null
	rm /var/run/pbxN/asterisk.ctl
}

# See how we were called.
case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  restart)
	restart
	;;
  reload)
	reload
	;;
  condrestart)
	[ -f /var/lock/subsys/asterisk_pbxN ] && restart || :
	;;
  status)
	#Marco Bruni 13/03/07 INIZIO
	#status asterisk
	echo -n "Checking for service Asterisk: "
	checkproc $DAEMON
        rc_status -v
	#Marco Bruni 13/03/07 FINE
	;;
  *)
	echo "Usage: asterisk {start|stop|restart|reload|condrestart|status}"
	exit 1
esac

exit $?
  1. to connect to a running pbx just specify the right configuration file on the command line:

asterisk -r -C /etc/asterisk/pbxN/asterisk.conf.

That’s all, hope it helps you start, let me know about your progresses/problems here, I’ll try to help you, time permitting.

Cheers.

Marco Bruni

good job - thx a lot for sharing your config.

just for information - could you post also your hardware config?
also, how you exactly are dealing with ZAP (or DAHDI) devices? I assume that them are configured with pbx0 and the rest of pbxN instances connect to pbx0 in case they need a ZAP (or DAHDI) channel.

BR,
Ioan.

Good question Ioan :smile: We are using only sip channels in the Asterisk pbxs, the pstn connection is through an Audiocodes Mediant 1000 sip/e1 gateway, in our installation there is only one Asterisk pbx, let’s call this pbx pbx0, that communicates directly with the Audiocodes gateway, all other pbxs reach the pstn and are reached from the pstn through the pbx pbx0.

Cheers.

Marco Bruni

thx Marco for your update.
what about your server hardware configuration - and maybe you could add some information regarding the load or average cpu idle.
BR,
Ioan

The server is a Dell PowerEdge with 1 Intel Xeon cpu dual core 2 Ghz with 2 GB of RAM, an average of 2000 calls per day, max concurrent calls less than 20, this the sar command report for today (the peaks are due to scheduled operations):

[code]00:00:01 CPU %user %nice %system %iowait %steal %idle
00:10:01 all 5,16 0,00 2,09 0,02 0,00 92,74
00:20:01 all 7,13 0,00 4,04 0,02 0,00 88,81
00:30:01 all 6,48 0,00 2,93 0,01 0,00 90,58
00:40:01 all 4,93 0,00 1,74 0,01 0,00 93,32
00:50:01 all 3,62 0,00 1,04 0,00 0,00 95,34
01:00:01 all 4,43 0,00 1,55 0,01 0,00 94,01
01:10:01 all 4,11 0,00 1,43 0,01 0,00 94,45
01:20:01 all 4,17 0,00 1,67 0,02 0,00 94,14
01:30:01 all 4,89 0,00 2,08 0,01 0,00 93,02
01:40:01 all 5,00 0,00 1,94 0,01 0,00 93,05
01:50:01 all 3,87 0,00 1,21 0,01 0,00 94,92
02:00:01 all 4,98 0,00 2,01 0,01 0,00 93,01
02:10:01 all 3,34 0,00 0,98 0,01 0,00 95,68
02:20:01 all 4,32 0,00 0,97 0,01 0,00 94,71
02:30:01 all 3,85 0,00 0,96 0,02 0,00 95,17
02:40:01 all 4,00 0,00 1,23 0,05 0,00 94,72
02:50:01 all 3,72 0,00 1,01 0,01 0,00 95,27
03:00:01 all 3,16 0,00 0,62 0,01 0,00 96,22
03:10:01 all 51,23 0,00 2,50 0,00 0,00 46,27
03:20:01 all 51,13 0,00 2,13 0,01 0,00 46,73
03:30:01 all 28,56 0,00 1,24 0,03 0,00 70,18
03:40:01 all 3,35 0,00 0,72 0,00 0,00 95,93
03:50:02 all 3,21 0,00 0,69 0,01 0,00 96,09
04:00:01 all 4,68 0,00 0,82 0,03 0,00 94,47
04:10:01 all 3,36 0,00 0,51 0,01 0,00 96,12
04:20:01 all 3,91 0,00 0,88 0,02 0,00 95,19
04:30:01 all 3,71 0,00 0,94 0,01 0,00 95,35
04:40:01 all 3,57 0,00 0,82 0,01 0,00 95,61
04:50:01 all 3,16 0,00 0,64 0,01 0,00 96,19
05:00:01 all 3,16 0,00 0,59 0,00 0,00 96,24
05:10:01 all 3,01 0,00 0,55 0,00 0,00 96,43
05:20:01 all 3,14 0,00 0,63 0,01 0,00 96,22
05:30:01 all 2,96 0,00 0,47 0,00 0,00 96,57
05:40:01 all 3,21 0,00 0,65 0,00 0,00 96,13
05:50:01 all 3,03 0,00 0,64 0,01 0,00 96,33
06:00:01 all 3,23 0,00 0,66 0,00 0,00 96,11
06:10:01 all 3,52 0,00 1,06 0,01 0,00 95,42
06:20:01 all 3,11 0,00 0,63 0,01 0,00 96,25
06:30:01 all 3,53 0,00 0,79 0,00 0,00 95,67
06:40:01 all 3,84 0,00 1,35 0,02 0,00 94,79
06:50:01 all 4,85 0,00 1,82 0,01 0,00 93,33
07:00:01 all 4,06 0,00 1,17 0,01 0,00 94,76
07:10:01 all 3,54 0,00 0,83 0,01 0,00 95,63
07:20:01 all 3,97 0,00 1,39 0,01 0,00 94,63
07:30:01 all 4,22 0,00 1,39 0,01 0,00 94,37
07:40:01 all 5,43 0,00 2,18 0,01 0,00 92,38
07:50:01 all 3,92 0,00 1,32 0,01 0,00 94,76
08:00:01 all 4,00 0,00 1,30 0,01 0,00 94,68
08:10:01 all 4,24 0,00 1,34 0,02 0,00 94,41

08:10:01 CPU %user %nice %system %iowait %steal %idle
08:20:01 all 4,35 0,00 1,61 0,02 0,00 94,02
08:30:01 all 6,48 0,00 3,20 0,01 0,00 90,31
08:40:01 all 6,10 0,00 3,08 0,03 0,00 90,79
08:50:01 all 6,41 0,00 3,89 0,03 0,00 89,67
09:00:01 all 7,37 0,00 4,18 0,03 0,00 88,42
09:10:01 all 7,00 0,00 3,83 0,01 0,00 89,16
09:20:01 all 6,58 0,00 3,50 0,04 0,00 89,88
09:30:01 all 6,63 0,00 3,40 0,02 0,00 89,95
09:40:01 all 8,36 0,00 4,26 0,02 0,00 87,36
09:50:01 all 6,61 0,00 3,67 0,07 0,00 89,65
10:00:01 all 6,37 0,00 3,42 0,02 0,00 90,19
10:10:01 all 29,71 0,01 4,93 0,03 0,00 65,33
10:20:01 all 53,22 0,01 5,64 0,00 0,00 41,13
10:30:01 all 51,90 0,01 6,73 0,01 0,00 41,36
10:40:01 all 17,40 0,00 4,18 0,01 0,00 78,41
10:50:01 all 6,49 0,00 3,50 0,04 0,00 89,98
11:00:01 all 6,94 0,00 4,01 0,02 0,00 89,04
11:10:01 all 6,76 0,00 3,85 0,02 0,00 89,37
11:20:01 all 8,19 0,00 5,11 0,01 0,00 86,68
11:30:01 all 7,10 0,00 3,97 0,03 0,00 88,90
11:40:01 all 9,60 0,00 5,55 0,03 0,00 84,82
11:50:01 all 7,14 0,00 4,04 0,03 0,00 88,78
12:00:01 all 7,29 0,00 4,49 0,02 0,00 88,20
12:10:01 all 7,65 0,00 4,03 0,03 0,00 88,29
12:20:01 all 7,95 0,00 4,58 0,04 0,00 87,43
12:30:01 all 11,20 0,00 7,11 0,02 0,00 81,67
12:40:01 all 11,57 0,00 6,68 0,02 0,00 81,73
12:50:01 all 9,74 0,00 5,67 0,02 0,00 84,57
13:00:01 all 8,45 0,00 5,27 0,03 0,00 86,26
13:10:01 all 8,22 0,00 4,98 0,02 0,00 86,77
13:20:01 all 6,65 0,00 3,70 0,01 0,00 89,64
13:30:01 all 8,62 0,00 4,45 0,02 0,00 86,91
13:40:01 all 9,01 0,00 4,87 0,02 0,00 86,10
13:50:01 all 9,21 0,00 5,12 0,04 0,00 85,62
14:00:01 all 9,35 0,00 4,93 0,02 0,00 85,69
14:10:01 all 7,16 0,00 3,95 0,07 0,00 88,82
14:20:01 all 7,96 0,00 4,27 0,04 0,00 87,73
14:30:01 all 9,35 0,00 4,94 0,04 0,00 85,67
14:40:01 all 7,58 0,00 3,71 0,03 0,00 88,68
14:50:01 all 13,08 0,00 3,58 0,02 0,00 83,32
15:00:01 all 9,09 0,00 5,60 0,05 0,00 85,27
15:10:01 all 8,96 0,00 4,86 0,03 0,00 86,15
15:20:01 all 9,20 0,00 4,62 0,03 0,00 86,15
[/code]

Sip peers, queue and queue members all stored in a mysql database.

Cheers.

Marco Bruni

muchas gracias, desde que se inventó el traductor de google no hay lengua desconocida. Estoy probando la configuración que has posteado luego te comento. :smiley: :smiley:

A more efficient way of implementing a multi-tenanted system is probably to use a different (set of) context(s) for each tenant, in a single instance.

David, this true in most of the situations, the configuration I shown helps to isolate each customer’s pbx more then multiple contexts, if you use only a pbx and multiple contexts a reload or a restart affects all customers, even if was changed the configuration for just a customer, with multiple pbxs just reload or restart the pbx with the configuration changed and so only this customer is affected, this is good to have less service disruption as possible.

Cheers.

Marco Bruni

Marco, you are right.
The configuration you was provide is just I looking for, because I need isolate each pbx.

Best Regards

OCobar