System information

Almost everything in this chapter is turned on by default. You will want
to run make menuselect to verify that the ODBC-related modules are
enabled. These include cdr_odbc, cdr_adaptive_odbc, func_odbc,
func_realtime, pbx_realtime, res_config_odbc, and res_odbc. For voi-
cemail stored in an ODBC database, be sure to select ODBC_STORAGE from
the Voicemail Build Options menu. You can verify that the modules exist
in the /usr/lib/asterisk/modules/ directory.
Configuring res_odbc to Allow Asterisk to Connect Through ODBC
Asterisk ODBC connections are configured in the res_odbc.conf file located in /etc/
asterisk. The res_odbc.conf file sets the parameters that various Asterisk modules will
use to connect to the database.
The pooling and limit options are quite useful for MS SQL and Sybase
databases. These permit you to establish multiple connections (up to
limit connections) to a database while ensuring that each connection
has only one statement executing at once (this is due to a limitation in
the protocol used by these database servers).
Modify the res_odbc.conf file so it looks like the following:
[asterisk]
enabled => yes
dsn => asterisk-connector
username => asterisk
password => welcome
pooling => no
limit => 0
pre-connect => yes
The dsn option points at the database connection you configured in /etc/odbc.ini, and
the pre-connect option tells Asterisk to open up and maintain a connection to the
database when loading the res_odbc.so module. This lowers some of the overhead that
would come from repeatedly setting up and tearing down the connection to the
database.
Once you’ve configured res_odbc.conf, start Asterisk and verify the database connec-
tion with the odbc show CLI command:
*CLI> odbc show
ODBC DSN Settings
-----------------
Name: asterisk
DSN: asterisk-connector
352 | Chapter 16:Relational Database Integration