Thinkai's Blog

Autohoutkey|Python|php|aardio|VOIP|IT 爱好者

Elastix 2.5的系统是Centos 5.9,Asterisk 11。在测试dialpan拨号方案使用odbc mysql的时候报错驱动/usr/lib64/libmyodbc3_r.so找不到,经验证是系统的mysql-connector-odbc没有安装。

在通过yum安装的时候又发现源已经停止服务了,无法下载,找到一个国外源fq下载完,在另外一台机子上则是选择本地安装yum包,下载地址:

https://centos.pkgs.org/5/centos-x86_64/mysql-connector-odbc-3.51.26r1127-2.el5.x86_64.rpm.html  (x64)

https://centos.pkgs.org/5/centos-i386/mysql-connector-odbc-3.51.26r1127-2.el5.i386.rpm.html (x86)

下载完后可以放到当前目录 shell执行:

yum -y localinstall mysql-connector-odbc-3.51.26r1127-2.el5.x86_64.rpm

安装完成后还需配置/etc/odbc.ini:

[MYSQL-asteriskcdrdb]
Description = MySQL connection to 'asterisk' database
Driver = MySQL
Database = asteriskcdrdb
Server = localhost
Port = 3306
Socket = /var/lib/mysql/mysql.sock
User = root
Password = MyPass
Option = 3

配置完成后可以在shell中测试:

[root@Elastix ~]# isql -v MYSQL-asteriskcdrdb
+---------------------------------------+
| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| quit                                  |
|                                       |
+---------------------------------------+
SQL> show tables;
+-----------------------------------------------------------------+
| Tables_in_asteriskcdrdb                                         |
+-----------------------------------------------------------------+
| cdr                                                             |
+-----------------------------------------------------------------+
SQLRowCount returns 1
1 rows fetched

这就算完成了一半,还需在/etc/asterisk/res_odbc.conf中配置dsn:

[asteriskcdrdb]
enabled=>yes
dsn=>MySQL-asteriskcdrdb
pooling=>no
limit=>1
pre-connect=>yes
share_connections => yes
isolation => repeatable_read
forcecommit => yes

在/etc/asterisk/func_odbc.conf中配置自定义函数(此处dsn指res_odbc.conf中的[name]):

[SQL]
dsn=asteriskcdrdb
readsql=${ARG1}
synopsis=ODBC_SQL(sql)

具体配置说明详见:https://wiki.asterisk.org/wiki/display/AST/Getting+Asterisk+Connected+to+MySQL+via+ODBC

http://www.asteriskdocs.org/en/3rd_Edition/asterisk-book-html-chunk/getting_funky.html

配置完后注意在Asterisk CLI中执行reload或者shell执行:

asterisk -x reload

最后就可以在dialpan中测试使用了,如下面的例子(/etc/asterisk/extensions.conf)拨打876在asterisk日志中输出结果:

[from-internal]
exten => 876,1,Answer
exten => 876,n,Noop(${ODBC_SQL("select now()")})
exten => 876,n,Noop(${ODBC_SQL("select top 1 uniquid from cdr order by calldate desc")})
exten => 876,n,Background(star)
exten => 876,n,Wait(60)
include => from-internal-noxfer
include => from-internal-xfer
include => bad-number ; auto-generated



来了就留个评论吧! 1个评论



Silicone wristbands 2018年9月4日 的 05:44

I drop a leave a response each time I appreciate a article on a site or I have something to
valuable to contribute to the conversation. It is caused by the sincerness displayed in the article
I browsed. And on this post Elastix 2.5 Asterisk 11 x64拨号方案中使用odbc mysql的问题及解决 | Thinkai's Blog.
I was actually excited enough to post a comment ;-) I actually do have
a few questions for you if it’s okay. Is it just me or do some of these
responses look like written by brain dead people?
:-P And, if you are writing on additional online sites, I’d like to follow everything
new you have to post. Could you list the complete urls of your social sites like your Facebook page, twitter feed,
or linkedin profile? https://www.personalized-braclets.com/blog/wp-login.php


友情链接:Autohotkey中文论坛Autohotkey中文帮助Autohotkey官网我的B站直播间如若生涯一场梦博客联系作者免GooglePlay APK下载

 主题设计 • skyfrit.com  Thinkai's Blog | 保留所有权利

65 queries in 1.759 seconds |