CREATE DATABASE asterisk;
GRANT INSERT
ON asterisk.*
TO asterisk@localhost
IDENTIFIED BY 'yourpassword';
USE asterisk;
CREATE TABLE cdr
(
calldate
datetime NOT NULL default '0000-00-00 00:00:00',
clid
varchar(80) NOT NULL default '',
src
varchar(80) NOT NULL default '',
dst
varchar(80) NOT NULL default '',
dcontext
varchar(80) NOT NULL default '',
channel
varchar(80) NOT NULL default '',
dstchannel
varchar(80) NOT NULL default '',
lastapp
varchar(80) NOT NULL default '',
lastdata
varchar(80) NOT NULL default '',
duration
int(11) NOT NULL default '0',
billsec
int(11) NOT NULL default '0',
disposition
varchar(45) NOT NULL default '',
amaflags
int(11) NOT NULL default '0',
accountcode
varchar(20) NOT NULL default '',
userfield
varchar(255) NOT NULL default ''
);
ALTER TABLE cdr
ADD uniqueid
VARCHAR(32) NOT NULL default '';
ALTER TABLE cdr
ADD INDEX ( calldate
);
ALTER TABLE cdr
ADD INDEX ( dst
);
ALTER TABLE cdr
ADD INDEX ( accountcode
);
5. service mysqld restart
6. Check asterisk db and cdr table for errors.
we need to install some of the options from the Asterisk-Addons download.
7. cd /usr/src
8. wget http://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk-addons-1.6.1.4.tar.gz
10. tar –zxvf asterisk-addons-1.6.1.4.tar.gz
cd /usr/src/asterisk/asterisk-addons-1.6.1.4
make clean
./configure
make menuselect
At this point, be sure to select at least the following items:
• Applications – app_addon_sql_mysql
• Call Detail Recording – cdr_addon_mysql
• Resource Modules – res_config_mysql
After you’ve got those selected, save and exit. Then proceed with the following steps:
make
make install
make samples
Once we’ve got that done, we need to edit the cdr_mysql.conf file to enter the mysql username and password, database, and table we setup earlier.
vi /etc/asterisk/cdr_mysql.conf
[global]
hostname=localhost
dbname=asterisk
table=cdr
password=PASSWORD
user=asterisk
port=3306
sock=/var/lib/mysql/mysql.sock
userfield=1
loguniqueid=yes
============
HELP
1. If you do not find cdr_addon_mysql.so file under /usr/lib/asterisk/modules, you will have to re-compile.
2. edit /etc/asterisk/modules.conf and add lin: load => cdr_addon_mysql.so
3. save and restart asterisk – then check if cdrs are wrking in mysql.