Running Asterisk 22.4.1 with FreePBX 17 on Oracle Linux 9.6 with MariaDB 12.
I am getting intermittent errors in Asterisk console:
Unable to retrieve database handle. CDR failed.
MariaDB is on the same server, so it can’t be a network issue. Had it been a configuration error, there should have been no CDR records at all. As it is, this is an intermittent issue with some records getting lost.
/etc/odbc.ini:
[MySQL-asteriskcdrdb]
Description = MySQL connection to ‘asteriskcdrdb’ database
Driver = MySQL
Server = localhost
Database = asteriskcdrdb
Port = 3306
Socket = /var/lib/mysql/mysql.sock
Option = 3
username = asterisk
password = PASSWORD
/etc/asterisk/res_odbc_additional.conf:
[asteriskcdrdb]
enabled=>yes
dsn=>MySQL-asteriskcdrdb
pre-connect=>yes
max_connections=>5
username=>freepbxuser
password=>94dbeec506815118a5aa05e9d883b1b9
database=>asteriskcdrdb
/etc/asterisk/cdr_odbc.conf:
[global]
dsn=MySQL-asteriskcdrdb
username=freepbxuser
password=94dbeec506815118a5aa05e9d883b1b9
loguniqueid=yes
dispositionstring=yes
table=cdr ;“cdr” is default table name
usegmtime=no ; set to “yes” to log in GMT
hrtime=yes ;Enables microsecond accuracy with the billsec and duration fields
newcdrcolumns=yes ; Enable logging of post-1.8 CDR columns (peeraccount, linkedid, sequence)
/etc/asterisk/cdr_adaptive_odbc.conf:
[asteriskcdrdb]
connection=asteriskcdrdb
loguniqueid=1
table=cdr
alias start => calldate
cdr show status:
Call Detail Record (CDR) settings
Logging: Enabled
Mode: Simple
Log calls by default: Yes
Log unanswered calls: No
Log congestion: No
Ignore bridging changes: No
Ignore dial state changes: No
Registered Backends
ODBC
cdr_manager
csv
Adaptive ODBCODBC DSN Settings
Name: asteriskcdrdb
DSN: MySQL-asteriskcdrdb
Number of active connections: 2 (out of 5)
Logging: Disabled