It is very easy to store the call records of Asterisk to MySQL, but it is also easy to store them to SQL Server.
First declare the environment: centos6.2 + asterisk 1.8.7.1 + freetds 0.91 + sqlserver 2008
1. Install rpmforge and epel sources
2. Install freetds:
Yum install freetds *
3. Configure and test freetds
VI/etc/freetds. conf
Example:
IP: Port mode:
[Sql2008] Host= 172.16.16.100Port= 1433TDS version= 8.0
The test is as follows:
Tsql-s sql2008-U sa-P Password
Database instance mode:
[Voipcdrsvr] Host= 172.16.16.101Instance=Sqlexpresstds version= 8.0
The test is as follows:
Tsql-s voipcdrsvr-U sa-P Password
4. Configure Asterisk
Clear cdr_odbc.conf
>/Etc/asterisk/cdr_odbc.conf
Edit cdr_tds.conf
VI/etc/asterisk/cdr_tds.conf
[Global] connection=Voipcdrsvrport= 1433Dbname=Mydbtable=Cdruser=Sapassword= Mypasswd
5. Create an sqlserver data table:
Create Table CDR ( [ Accountcode ] [ Varchar ] ( 20 ) Null , [ SRC ] [ Varchar ] ( 80 ) Null , [ DST ] [ Varchar ] ( 80 ) Null , [ Dcontext ] [ Varchar ] ( 80 ) Null , [ Clid ] [ Varchar ] ( 80 ) Null , [ Channel ] [ Varchar ] ( 80 ) Null , [ Dstchannel ] [ Varchar ] ( 80 ) Null , [ Lastapp ] [ Varchar ] (80 ) Null , [ Lastdata ] [ Varchar ] ( 80 ) Null , [ Start ] [ Datetime ] Null , [ Answer ] [ Datetime ] Null , [ End ] [ Datetime ] Null , [ Duration ] [ Int ] Null , [ Billsec ] [ Int ] Null , [ Disposition ] [ Varchar ] ( 20 ) Null , [ Amaflags ] [ Varchar ] ( 16 )Null , [ Uniqueid ] [ Varchar ] ( 150 ) Null , [ Userfield ] [ Varchar ] (256 ) Null )
6. Restart asterisk to take effect:
Asterisk-Rx "core restart now"
Okay, that's all. I hope it will help you.