Saturday, January 8, 2011

Asterisk with Oracle

Now Asterisk:

Having installed unixODBC and unixODBC-devel, I download Asterisk and installed it.


make or make menuselect

make install

During the execution of ./configure script, on finding uinxODBC and unixODBC-devel installed, it prepares all ODBC related modules for installation, it can be verified it by using ‘make select’ instead of ‘make’. After ‘make install’ had finished, my Asterisk was ODBC enabled, all I needed to do was configure the conf files. 

Before changing the conf files, I created a table called ‘sip_buddies’ in my database, schema can be found here, I had to make some changes in the schema according to my database. I was planning to test peer registration from database.

On Asterisk, I was interested in dynamic mode of Asterisk Realtime Arcitecture (ARA), based on that, I had to change the following conf files:


In modules.conf, I uncommented following two lines:

preload =>
preload =>

In res_odbc.conf, I added following context:

enabled  => yes
dsn => OracleODBC-11g     ; the context added to odbc.ini
;username => testdb            ;already provided in odbc.ini , may be provided here too
;password => testdb           ;already provided in odbc.ini, may be provided here too
pooling => no
limit => 0
pre-connect => yes

Like username and password, there are other parameters in odbc.ini which may be overridden here in this file, as has been mentioned at the above link.

Finally, I changed the extconfig.conf and added the following line:

sippeers => odbc, asterisk_oracle, sip_buddies

‘asterisk_oracle’ is the database as I created in res_odbc.conf. sip_buddies was the table in my database where peers resided.

After running asterisk, I executed following command on CLI
odbc show

The output showed that I was connected to OracleODBC-11g.

Then I added some peers in my peers table while Asterisk was running and tried to register them on Asterisk through Soft Phones.

Note: I had a little problem here while registering the peer with following output:
chan_sip.c:20603 handle_request_register: Registration from…….. failed for…….. - No
matching peer found.
It was fixed by populating the ‘defaultip’ field of my table sip_buddies, a null value in this field was creating the problem. This problem has been discussed with a patch that is available here. I hope the future release of Asterisk would have it fixed or you can do it yourself from above link by changing the source.
It’s all worth it. I was successfully able to register my peers without a reload. Everything I did was working fine especially about unixODBC-devel which seemed like a nightmare!!!!!!

You can do more things with this, I hope this long post (splited into four parts) is helpful to all you guys who dealing with the same issue. Let me know, if it is useful for you.


Anonymous said...

hi my name is julio cesar, have u tried to store cdr in oracle also?

Tiff said...

Julio, if you are done with unixODBC i dont think there is much to do for storing CRD, its merely configurations. Please explain the issue you are facing and the way you are trying to do it.

srikanth said...

Hi I am Srikanth,
I am able to connect to database from asterisk CLI and execute all sql commands.But when the call is coming to asterisk it is not connecting to database and inserting into table.It is saying like this:

[Jun 10 22:17:01] NOTICE[24985]: res_odbc.c:1480 odbc_obj_connect: Connecting asterisk
[Jun 10 22:17:01] WARNING[24985]: res_odbc.c:1507 odbc_obj_connect: res_odbc: Error SQLConnect=-1 errno=0 [unixODBC][Driver Manager]Can't open lib '/opt/instantclient_11/instantclient_11_2/
[Jun 10 22:17:01] WARNING[24985]: res_odbc.c:1328 _ast_odbc_request_obj2: Failed to connect to asterisk

here asterisk is the database instance name.
Can u please mail me the reply to