2

问题:我正在使用在 VirtualBox 中运行星号 2.0 服务器的 AsteriskNow。我想使用 ODBC 模块将 Asterisk 与 MySQL 数据库连接起来。但它失败了。当我开始使用星号*CLI> odbc show 命令提示符显示“没有这样的命令 ODBC SHOW”

我的目标:在 asterisk 中配置 ODBC 以直接动态地从 Asterisk 的拨号方案访问 MySQL。

我做了什么:我在 VirtualBox 中安装了我的 AsteriskNow。asterisk 的版本是 2.0,CentOS 的版本是 5.8 final。我首先通过以下方式安装了相关的 Linux RPM

yum -y install unixODBC-devel
yum -y install libdbi-dbd-mysql
yum -y install mysql-connector-odbc

我的详细配置文件如下:

/etc/odbc.ini

[asterisk-connector]
Description           = MySQL connection to 'asterisk' database
Driver                = MySQL
Database              = asterisk
Server                = localhost
UserName              = root        
Password              = mypassword
Port                  = 3306
Socket                = /var/lib/mysql/mysql.sock

/etc/odbcinst.ini

# Driver from the mysql-connector-odbc package
# Setup from the unixODBC-libs package
[MySQL]
Description = ODBC for MySQL
Driver      = /usr/lib/libmyodbc3_r.so
Setup       = /usr/lib/libodbcmyS.so
;Driver64   = /usr/lib64/libmyodbc3_r.so
;Setup64        = /usr/lib64/libodbcmyS.so
FileUsage   = 1

/etc/asterisk/res_odbc.conf

[asterisk]
enabled=>yes
dsn=>asterisk-connector
;dsn=>asterisk
username=>root
password=>mypassword
pooling=>no
limit=>0
pre-connect=>yes

当我使用“isql”命令连接 MySQL 数据库时,它工作正常 在此处输入图像描述

但是当我在 CLI 中启动控制台时,输入命令odbc show。它显示没有这样的命令“odbc show”

在此处输入图像描述

我在这里很困惑,不知道如何解决它。我用谷歌搜索,发现有人建议通过加载 res_odbc.so 模块来解决它。因此我浏览了文件 modules.conf 并将这些修改添加到文件中

autoload=yes
preload => res_odbc.so
preload => res_config_odbc.so

修改后完整文件如下" /etc/asterisk/modules

;
; Asterisk Module Loader configuration file
;
;

[modules]
autoload=yes
;
; Any modules that need to be loaded before the Asterisk core has been
; initialized (just after the logger has been initialized) can be loaded
; using 'preload'. This will frequently be needed if you wish to map all
; module configuration files into Realtime storage, since the Realtime
; driver will need to be loaded before the modules using those configuration
; files are initialized.
;
; An example of loading ODBC support would be:
preload => res_odbc.so
preload => res_config_odbc.so
;
; As FreePBX is using Local as the channel for queue members we need to make sure
; that pbx_config.so and chan_local.so are preloaded. If not, queue members
; will be marked as invalid until app_queue is reloaded. 
preload => pbx_config.so
preload => chan_local.so
;
; Uncomment the following if you wish to use the Speech Recognition API
;preload => res_speech.so
;
; If you want, load the GTK console right away.  
; KDE console is obsolete and was removed from Asterisk 2008-01-10
;
noload => pbx_gtkconsole.so
;load => pbx_gtkconsole.so
noload => pbx_kdeconsole.so
;
; Intercom application is obsoleted by
; chan_oss.  Don't load it.
;
noload => app_intercom.so
;
; DON'T load the chan_modem.so, as they are obsolete in * 1.2

noload => chan_modem.so
noload => chan_modem_aopen.so
noload => chan_modem_bestdata.so
noload => chan_modem_i4l.so

; Trunkisavail is a broken module supplied by Trixbox
noload => app_trunkisavail.so

; Ensure that format_* modules are loaded before res_musiconhold
;load => format_ogg_vorbis.so
load => format_wav.so
load => format_pcm.so

; format_au.so is removed from Asterisk 1.4 and later, remove ; to enable
;load => format_au.so

; This isn't part of 'Asterisk' iteslf, it's part of asterisk-addons. If this isn't
; installed, asterisk will fail to start. But it does need to go here for native MOH
; to work using mp3's. 
;   Note that on a system with a high number of calls, using a compressed audio format for
;   musiconhold takes CPU resources. Converting these files to ulaw/alaw makes the job
;   much easier for your CPU.
load => format_mp3.so
load => res_musiconhold.so
;
; Load either OSS or ALSA, not both
; By default, load no console driver
;
noload => chan_alsa.so
noload => chan_oss.so
;
noload => app_directory_odbcstorage.so 
noload => app_voicemail_odbcstorage.so 

完成此操作后,我返回 CLI 控制台重新加载 res_odbc.so。但它未能找到 res_odbc.so 在此处输入图像描述

我需要有人给我解决 ODBC 连接问题的提示。

4

5 回答 5

3

尝试执行以下操作:

asterisk -rvvv
module unload res_odbc.so
module load res_odbc.so

并查看输出。

于 2012-10-03T15:01:54.830 回答
2

在 AsteriskNOW 环境中,要获取res_odbc.so为 Asterisk 提供 ODBC 资源的模块,您需要asterisk-odbc安装包。

(取决于您的 AsteriskNOW 安装是如何针对 packages.asterisk.org 存储库配置的,您可能需要asterisk18-odbc或类似的版本控制包。)

如果你有res_odbc.so(签入/usr/lib/asterisk/modules这个文件)并且它仍然没有正确加载,你应该检查 Asterisk 登录以/var/log/asterisk获取与更多信息相关的消息res_odbc

于 2012-10-31T15:37:03.357 回答
0

请注意,当您使用 isql 命令时,您会收到一个错误(未知属性用户名)。

试试这个 /etc/odbc.ini 文件:

[asterisk-connector]
Description = MySQL connection to 'asterisk' database
Driver      = MySQL
DATABASE    = asterisk
SERVER      = localhost
USER        = root
PASSWORD    = mypassword
PORT        = 3306
Option      = 3

我不知道是否对 CentOS 有效,但在 Debian 中我必须重新编译 Asterisk 并执行 menuselect 才能工作。为此,请转到您的 Asterisk 字体目录:

$ ./configure

$ make clean

$ make menuselect

请验证是否检查了以下模块:

[*] cdr_odbc

[*] cdr_adaptive_odbc

[*] func_odbc

[*] func_realtime

[*] pbx_realtime

[*] res_config_odbc

[*] res_odbc

进而:

$ sudo make install

我希望对你有所帮助。

于 2012-10-11T20:29:35.590 回答
0

当您执行“make menuselect”检查时,您似乎忘记添加一些重要的模块。

此外,如果您使用 mysql 作为关系数据库,则必须在您描述的配置文件 (/etc/asterisk/res_odbc.conf) 中建立“limit=>1”,这一点非常重要,或者只需注释该行。如果您遵循 orreilly 指南 ( http://ofps.oreilly.com/titles/9781449332426/asterisk-DB.html ),您可以查看勘误表 ( http://oreilly.com/catalog/errata.csp?isbn= 9780596517342)。

于 2013-10-17T12:54:06.483 回答
0

sudo service asterisk restart

奇迹般有效

于 2016-07-17T02:23:04.413 回答