Discussion:
[asterisk-users] Asterisk 1.8.13.0 / problem with cdr logging (mysql, odbc)
Thorsten Göllner
2012-06-18 15:52:15 UTC
Permalink
Hi,

I am trying now for over 4 hours setting up cdr-logging via odbc into a
mysql database. But with no success. Do you have any hint for me?

cat /etc/odbc.ini
------------------
[MySQL-asterisk]
Description = MySQL ODBC Driver
Driver = MySQL
Socket = /var/run/mysqld/mysqld.sock
Server = localhost
User = xxx
Password = xxx
Database = asterisk
Option = 3
Port =

and

/etc/odbcinst.ini
--------------------
[MySQL]
Description = MySQL ODBC MyODBC Driver
Driver = /usr/lib/x86_64-linux-gnu/odbc/libmyodbc.so
FileUsage = 1

When testing this setup I can see, that this basic setup ist fine:

~$ isql MySQL-asterisk asterisk qpalym -v
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL>

So here are the config file for asterisk.

/etc/asterisk/res_odbc.conf
-----------------------------
[mysql]
enabled => yes
dsn => MySQL-asterisk
username => asterisk
password => qpalym
pre-connect => yes

and

/etc/asterisk/cdr_odbc.conf
----------------------------
[global]
dsn=MySQL-asterisk
loguniqueid=yes
dispositionstring=yes
table=cdr

But after a call hangup I get the following error:
cdr_odbc.c: Unable to retrieve database handle. CDR failed.

What is going wrong here, please?

-Thorsten-
Michael L. Young
2012-06-18 16:51:27 UTC
Permalink
----- Original Message -----
Sent: Monday, June 18, 2012 11:52:15 AM
Subject: [asterisk-users] Asterisk 1.8.13.0 / problem with cdr logging (mysql, odbc)
/etc/odbcinst.ini
--------------------
[MySQL]
Description = MySQL ODBC MyODBC Driver
Driver = /usr/lib/x86_64-linux-gnu/odbc/libmyodbc.so
FileUsage = 1
Try adding:

"Setup = /usr/lib/x86_64-linux-gnu/odbc/libodbcmyS.so"

Adjust the path according to where this file can be found on your system.
So here are the config file for asterisk.
/etc/asterisk/res_odbc.conf
-----------------------------
[mysql]
enabled => yes
dsn => MySQL-asterisk
username => asterisk
password => qpalym
pre-connect => yes
For MySQL, I think you also need:

"backslash_is_escape => yes"

Give those two things a try and see if that helps.

Regards,
Michael
Duncan Turnbull
2012-06-18 19:26:44 UTC
Permalink
I think you need the DSN in car_odbr.ini to refer to the one in res_odbc.conf as below
Hi,
I am trying now for over 4 hours setting up cdr-logging via odbc into a mysql database. But with no success. Do you have any hint for me?
cat /etc/odbc.ini
------------------
[MySQL-asterisk]
Description = MySQL ODBC Driver
Driver = MySQL
Socket = /var/run/mysqld/mysqld.sock
Server = localhost
User = xxx
Password = xxx
Database = asterisk
Option = 3
Port =
and
/etc/odbcinst.ini
--------------------
[MySQL]
Description = MySQL ODBC MyODBC Driver
Driver = /usr/lib/x86_64-linux-gnu/odbc/libmyodbc.so
FileUsage = 1
~$ isql MySQL-asterisk asterisk qpalym -v
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL>
So here are the config file for asterisk.
/etc/asterisk/res_odbc.conf
-----------------------------
[mysql]
enabled => yes
dsn => MySQL-asterisk
username => asterisk
password => qpalym
pre-connect => yes
and
/etc/asterisk/cdr_odbc.conf
----------------------------
[global]
dsn=MySQL-asterisk
dsn=mysql
loguniqueid=yes
dispositionstring=yes
table=cdr
cdr_odbc.c: Unable to retrieve database handle. CDR failed.
What is going wrong here, please?
-Thorsten-
--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
http://www.asterisk.org/hello
asterisk-users mailing list
http://lists.digium.com/mailman/listinfo/asterisk-users
James Sharp
2012-06-18 19:49:38 UTC
Permalink
Post by Thorsten Göllner
Hi,
I am trying now for over 4 hours setting up cdr-logging via odbc into a
mysql database. But with no success. Do you have any hint for me?
*SNIP*
Post by Thorsten Göllner
cdr_odbc.c: Unable to retrieve database handle. CDR failed.
What is going wrong here, please?
The DSN that you specify in cdr_odbc.con should be the DSN you
configured in res_odbc.conf, in this case "mysql" versus "MySQL-asterisk".

I beat head against the desk for hours because of this same issue.
Thorsten Göllner
2012-06-19 08:38:42 UTC
Permalink
Post by James Sharp
Post by Thorsten Göllner
Hi,
I am trying now for over 4 hours setting up cdr-logging via odbc into a
mysql database. But with no success. Do you have any hint for me?
*SNIP*
Post by Thorsten Göllner
cdr_odbc.c: Unable to retrieve database handle. CDR failed.
What is going wrong here, please?
The DSN that you specify in cdr_odbc.con should be the DSN you
configured in res_odbc.conf, in this case "mysql" versus
"MySQL-asterisk".
I beat head against the desk for hours because of this same issue.
This solved the problem. The CDR is written to the mysql database.
Thanks. It would never have occurred to me.

BUT the cli command "odbc show all" still shows and "uninitialized" last
connection attempt. Never mind?

CLI> odbc show all

ODBC DSN Settings
-----------------

Name: mysql
DSN: MySQL-asterisk
Last connection attempt: 1970-01-01 01:00:00
Pooled: No
Connected: Yes

Loading...