• asterisk 相关数据库配置 使用


    Linux/Unix下ODBC的安装:

      先下载最新的unixODBC源码包(http://www.unixodbc.org/unixODBC-2.2.1.tar.gz)放到/usr/local下,然后运行下述命令:

      tar zxvf unixODBC-2.2.1.tar.gz

      cd unixODBC-2.2.1

      ./configure --prefix=/usr/local/unixODBC-2.2.1 --includedir=/usr/include --libdir=/usr/lib -bindir=/usr/bin --sysconfdir=/etc

      make

      make install

      安装成功后,unixODBC所需的头文件都被安装到了/usr/inlucde下,编译好的库文件安装到了/usr/lib下,与unixODBC相关的可执行文件安装到了/usr/bin下,配置文件放到了/etc下。

    asterisk mysql安装:

    1、安装mysql mysql -u root mysql UPDATE user SET Password=PASSWORD('123456') where USER='root'; FLUSH PRIVILEGES

    2、建立asterisk数据库 SQL如下:

    CREATE DATEBASE asterisk;

    USE asterisk;

    CREATE TABLE cdr (  

    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 '',  

    start datetime NOT NULL default '0000-00-00 00:00:00',  

    answer datetime NOT NULL default '0000-00-00 00:00:00',  

    end datetime NOT NULL default '0000-00-00 00:00:00',  

    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 '',  

    uniqueid varchar(32) NOT NULL default '',  

    userfield varchar(255) NOT NULL default '',  

    myself varchar(32) NOT NULL default '' );

    ALTER TABLE cdr ADD INDEX ( calldate );

    ALTER TABLE cdr ADD INDEX ( dst );

    ALTER TABLE cdr ADD INDEX ( uniqueid );

    CREATE TABLE vc_talklog (

    src varchar(80) NOT NULL default '',

    dst varchar(80) NOT NULL default '',

    channel varchar(80) NOT NULL default '',

    dstchannel varchar(80) NOT NULL default '',

    start datetime NOT NULL default '0000-00-00 00:00:00',

    answer datetime NOT NULL default '0000-00-00 00:00:00',

    end datetime NOT NULL default '0000-00-00 00:00:00',

    duration int(11) NOT NULL default '0',

    billsec int(11) NOT NULL default '0',

    disposition varchar(45) NOT NULL default '',

    recfilepath varchar(20) NOT NULL default '',

    talklogid varchar(32) NOT NULL default '',

    );

    CREATE TABLE vc_talklog (

    src varchar(80) NOT NULL default '',

    dst varchar(80) NOT NULL default '',

    start datetime NOT NULL default '0000-00-00 00:00:00',

    answer datetime NOT NULL default '0000-00-00 00:00:00',

    end datetime NOT NULL default '0000-00-00 00:00:00',

    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 '',

    uniqueid varchar(32) NOT NULL default '',

    userfield varchar(255) NOT NULL default ''

    );

    exten => _70XX,1,MYSQL(Connect connid 127.0.0.1 root 123456 asterisk)

    exten => _70XX,n,MYSQL(Query resultid ${connid} select over from billing where username='${CALLERID(number)}')

    exten => _70XX,n,MYSQL(Fetch fetchid ${resultid} over)

    ;exten => _70XX,n,SayNumber(${resultid})

    ;exten => _70XX,n,SayNumber(${fetchid})

    ;exten => _70XX,n,SayNumber(${over})

    exten => _70XX,n,MYSQL(Clear  ${resultid})

    exten => _70XX,n,MYSQL(Disconnect ${connid})

    ;exten => _70XX,n,SayNumber(${fetchid})

    ;exten => _70XX,n,SayNumber(${over})

    exten => _70XX,n,GoToIf($["${fetchid}" == "0"]?1000)

    exten => _70XX,n,GotoIf($[${over} <= 0]?1000)

    exten => _70XX,n,Dial(sip/5051)

    exten => _70XX,1000,playback(busy)

    exten => _70XX,n,Hangup()

    3、下载及编译asterisk-addons

    # cd asterisk-addons-1.6.2

    # ./configure

    # make menuselect  

    必须确保Applications--》app_addon_sql_mysql和Call Detail Recording--》cdr_addon_mysql是选中的

    # make clean # make # make install

    4、修改相关配置文件

    (1)vi /etc/asterisk/cdr.conf  

    [general]  

    enable=yes

    (2)vi /etc/asterisk/cdr_mysql.conf  

    [global]  

    hostname=127.0.0.1  

    dbname=asterisk  

    table=cdr  

    password=******  

    user=adminstrator  

    port=3306

    (3)vi /etc/asterisk/modules.conf  

    在文件最后添加下面一行内容  

    load => cdr_addon_mysql.so

    5、重启asterisk服务器  

    /usr/sbin/asterisk -r  

    core restart now  

    重启完成后正常情况下可以用cdr mysql status查看相关信息,如果没有则说明还存在问题

    6、确认  

    进行一次成功的通话操作后进入mysql数据库查看是否已经添加了一条记录,如果有的话则说明已经成功了。

    asterisk odbc连接数据库: Client does not support authentication protocol requested by server; consider upgrading MySQL client错误解决办法:

    UPDATE mysql.user SET Password = OLD_PASSWORD('123456') WHERE Host = '127.0.0.1' AND User = 'root';

    FLUSH PRIVILEGES;

    1,安装odbc

    2.下载mysql驱动

    3,配置odbc:

    vi /etc/odbc.ini       

    [mysql-asterisk]  

    Description = MySQL test database  

    Trace = On  

    TraceFile = stderr  

    Driver = mysql  

    SERVER = 192.168.0.251  

    USER = root  

    PASSWORD = 123456  

    PORT = 3306  

    DATABASE = asterisk  

    socket = /tmp/mysql.soc  

    vi /etc/odbcini.ini    

    [mysql]  

    Description = MySQL driver  

    Driver = /usr/lib/libmyodbc.so  

    Setup = /usr/lib/libodbcmyS.so  

    Socket = /tmp/mysql.sock  

    FileUsage = 1    

    测试 isql -v mysql-asterisk root 123456    

    能连接成功,即证明unixODBC 配置正常

    vi /etc/asterisk/cdr_odbc.conf

      加入        

    [global]      

    dsn=mysql-asterisk      

    username=root      

    password=123456      

    loguniqueid=yes      

    dispositionstring=yes      

    table=cdr              

    ;"cdr" is default table name      

    usegmtime=no            

    ; set to "yes" to log in GMT

    vi /etc/asterisk/res_odbc.conf      

    加入          

    [mssql2000]       

    dsn => mysql-asterisk       

    username => root       

    password => 123456       

    pre-connect => yes     

    vi /etc/asterisk/cdr_adaptive_odbc.conf     

    加入         

    [first]      

    connection=mssql2000      

    table=cdr      

    alias start => calldate     

    说明connection必须与res_odbc.conf里的[]对应

      录音:

    [macro-outbound]

    exten => s,1,Set(PATH=/var/spool/asterisk/monitor/${STRFTIME(${EPOCH},,%Y-%m-%d)})

    exten => s,n,Set(FILENAME=${STRFTIME(${EPOCH},,%Y-%m-%d-%H%M%S)}--${CALLERID(num)}-${ARG2})

    exten => s,n,Set(MONITOR_EXEC=/etc/asterisk/scripts/mce ${PATH} ${FILENAME})

    exten => s,n,Monitor(wav,${PATH}/${FILENAME},mb)

    exten => s,n,Dial(${ARG1}/${ARG2},,tTm)

    [from-internal]

    exten =>_500X,1,Macro(outbound,sip,${EXTEN})

    设置变量

    Set(CDR(userfield)=value)

    轮询振铃

    exten => 1000,1,MYSQL(Connect connid 127.0.0.1 root 123456 asterisk)

    exten => 1000,2,MYSQL(Query resultid ${connid} select extension from pollexten)

    exten => 1000,3,MYSQL(Fetch fetchid ${resultid} extension)

    exten => 1000,4,MYSQL(Clear ${resultid})

    exten => 1000,5,set(count=$[${extension}])

    exten => 1000,6,GotoIf($["${count}" == "2006"]?3000)

    exten => 1000,7,MYSQL(Query resultid ${connid} select statu from ExtenStatu where extension='${count}')

    exten => 1000,n,NoOp(${resultid})

    exten => 1000,n,MYSQL(Fetch fetchid ${resultid} statu)

    exten => 1000,n,MYSQL(Clear ${resultid})

    exten => 1000,n,NoOp(${fetchid})

    exten => 1000,n,NoOp(${statu})

    exten => 1000,n,GoToIf($["${statu}" == "0"]?1000:2000)

    exten => 1000,1000,set(count-dial=${count})

    exten => 1000,n,Set(count=$[${count}+1])

    exten => 1000,n,MYSQL(Query resultid ${connid} update pollexten set extension = '${count}')

    exten => 1000,n,MYSQL(Disconnect ${connid})

    exten => 1000,n,Dial(sip/${count-dial},30,rtw)

    exten => 1000,2000,Set(count=$[${count}+1])

    exten => 1000,n,Goto(1000,6)

    exten => 1000,3000,set(count=2000)

    exten => 1000,n,Goto(1000,7)

    有志者事竟成
  • 相关阅读:
    【Beta阶段】第五次Scrum Meeting
    wireshark怎么抓包、wireshark抓包详细图文教程
    Java环境变量的配置
    Office2007 每次打开斗需要检查 【配置进度】
    思科SVI接口和路由接口区别
    Windows Server 2008 R2之管理Sysvol文件夹
    Windows Server 2008 R2之六活动目录域服务的卸载
    Windows Server 2008 R2之五操作主控的管理
    Windows Server 2008 R2之三管理活动目录数据库
    23. Merge k Sorted Lists
  • 原文地址:https://www.cnblogs.com/dancheblog/p/3508811.html
Copyright © 2020-2023  润新知