Asterisk联合NuoDB

[复制链接]
查看11 | 回复8 | 2014-2-19 11:55:14 | 显示全部楼层 |阅读模式
You may already be familiar with Asterisk, the widely-deployed open-source telephony framework. If you aren't, you should check it out. It's a pretty cool piece of software. A low-load instance of Asterisk can be deployed to use the filesystem to store things like phone-registration data and voicemails.
But if you want to do anything fancy with Asterisk, or if you happen to care about things like fault-tolerance, you might look at pointing Asterisk at a database. And if you happen to have a large Asterisk cluster built to handle significant load, you might look at pointing Asterisk at an elastically-scalable database.
In this post, I'll walk you through setting up a minimal Asterisk installation on a single RPM-based Linux machine with NuoDB. You can go much farther with Asterisk installs spanning several data centers, but I'll leave those headaches to the experts. Pairing such an installation with NuoDB will at least take the database pain out of such a setup. Let's dive in.
Installing NuoDB
First, download and install NuoDB.
sudo rpm -i nuodb.rpm复制代码


回复

使用道具 举报

千问 | 2014-2-19 11:55:14 | 显示全部楼层
This will start a NuoDB broker on this host. Next, we start a Transaction Engine and Storage Manager:java -jar /opt/nuodb/jar/nuodbmanager.jar --broker localhost --user domain --password bird --command "start process sm database asteriskCDR host localhost archive /tmp/ast-cdr initialize yes"
2.java -jar /opt/nuodb/jar/nuodbmanager.jar --broker localhost --user domain --password bird --command "start process te database asteriskCDR host localhost options '--dba-user asteriskUser --dba-password mySecret'"
复制代码
回复

使用道具 举报

千问 | 2014-2-19 11:55:14 | 显示全部楼层
Setting up ODBC
While there is native support in Asterisk to talk directly to MySQL and PostgreSQL, the more tested and hardened path is to connect to a database through ODBC. Here, we install unixODBC, the ODBC driver manager implementation for Unix-like operating systems.as root:
yum install gcc gcc-c++ ncurses-devel unixODBC unixODBC-devel
复制代码
回复

使用道具 举报

千问 | 2014-2-19 11:55:14 | 显示全部楼层
This created two files: /etc/odbc.ini and /etc/odbcinst.ini which we now edit to point at our NuoDB instance.
01./etc/odbc.ini
02.[NuoODBC]
03.Description = NuoDB ODBC3 Driver DSN
04.Driver= /opt/nuodb/lib64/libNuoODBC.so
05.Database= asteriskCDR
06.ServerName= localhost
07.User= asteriskUser
08.Password= mySecret
09.Schema= user

回复

使用道具 举报

千问 | 2014-2-19 11:55:14 | 显示全部楼层
We can leave /etc/odbcinst.ini empty, or if you would like to enable (a very verbose!) logging:
1./etc/odbcinst.ini
2.[ODBC]
3.TraceFile = /tmp/odbc.log
4.Trace = Yes
These are by no means the only options to get unixODBC up and running, but we'll roll with this for now. Let's make sure that what we've got so far works:
01.isql NuoODBC asteriskUser mySecret -v -3
02.+---------------------------------------+
03.| Connected!
|
04.|
|
05.| sql-statement
|
06.| help [tablename]
|
07.| quit
|
08.|
|
09.+---------------------------------------+
10.SQL>

回复

使用道具 举报

千问 | 2014-2-19 11:55:14 | 显示全部楼层
本帖最后由 jieforest 于 2013-10-28 13:51 编辑
Installing Asterisk
At the time of writing, the current tested and stable release of Asterisk is 11.4.0, but you can check here for the release of your choice.
01.as root:
02.yum install libtool-ltdl libtool-ltdl-devel sqlite-devel libxml2-devel openssl-devel libuuid-devel
03.cd /usr/src
04.wget http://downloads.asterisk.org/pu ... 0.tar.gz
05.wget http://downloads.asterisk.org/pu ... .gz.sha1
06.sha1sum -c asterisk-11.4.0.tar.gz.sha1
07.tar zxvf asterisk-11.4.0.tar.gz
08.cd asterisk-11.4.0
09../configure --libdir=/usr/lib64 --disable-xmldoc
10.make menuselect && make && make install && make samples && make config


回复

使用道具 举报

千问 | 2014-2-19 11:55:14 | 显示全部楼层
During make menuselect, check the Call Detail Recording (CDR) to make sure that cdr_odbc is enabled. Press q to leave make menuselect. After that, you can get yourself a coffee and spend a few minutes checking out Dinosaur Comics. If compilation on your system succeeded and your distribution is recognized by the make install phase, you should be able to start the Asterisk service:sudo service asterisk start复制代码Connecting Asterisk and NuoDB
Asterisk can utilize a database in various ways. As an example, we'll set up CDR logging.
01./etc/asterisk/cdr_odbc.conf
02.[global]
03.dsn=NuoODBC
04.loguniqueid=no
05.dispositionstring=yes
06.table=cdr
07.usegmtime=yes
08.hrtime=yes
09./etc/asterisk/res_odbc.conf
10.[NuoODBC]
11.enabled => yes
12.dsn => NuoODBC
13.username => asteriskUser
14.password => mySecret
15.pre-connect => yes
16.sanitysql => select 1 from dual

回复

使用道具 举报

千问 | 2014-2-19 11:55:14 | 显示全部楼层
We force the reload of the configuration files:sudo service asterisk restart复制代码Now we can check the database connection with a simple command inside the Asterisk console.
01.asterisk -rvvv
02.
03.p131*CLI> odbc show
04.
05.ODBC DSN Settings
06.-----------------
07.
08.Name: NuoODBC
09.DSN:NuoODBC
10.Last connection attempt: 2013-09-03 10:45:41

回复

使用道具 举报

千问 | 2014-2-19 11:55:14 | 显示全部楼层
As you might have guessed, we'll be logging Call Detail Records into a table called cdr. Let's create the table:
1./opt/nuodb/bin/nuosql asteriskCDR --user asteriskUser --password mySecret123,1,Answer
04.exten => 123,2,SetMusicOnHold(default)
05.exten => 123,3,WaitMusicOnHold(2)
06.exten => 123,4,Hangup
07./etc/asterisk/sip.conf
08.[sipp]
09.type=friend
10.context=sipp
11.host=dynamic
12.user=sipp
13.canreinvite=no
14.disallow=all
15.allow=ulaw
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行