使用数据库保存Asterisk配置.docVIP

  • 42
  • 0
  • 约1.44万字
  • 约 10页
  • 2017-08-17 发布于河南
  • 举报
在默认情况下,Asterisk的配置文件都保存在/etc/asterisk目录中,以ini文件的格式保存。我们也可以使用数据库来保存大多数Asterisk配置信息。 Asterisk使用数据库保存配置信息有两种方法:静态和动态,对于不经常修改的配置数据,可以使用静态的方式保存,这些数据都是在Asterisk对应的模块加载时获取配置信息。动态方式适合那些经常变化的数据,例如SIP帐号信息。使用数据库来保存SIP帐号信息还有一个好处:Asterisk会自动把SIP帐号登录Asterisk的相关资料保存到表中,这样大大的方便了管理员检查当前SIP帐号的使用情况和状态。 下面开始介绍Asterisk的数据库获取配置的方法。我使用的是Asterisk版本是 11.0.0。 在这里,我只对Asterisk的基本配置和SIP相关的配置感兴趣,AIX帐号的配置和SIP的配置应该类似,不想多作分析。 基本介绍 获取数据的方法 配置信息可以保存在多种数据库中,下面是Asterisk支持的数据库的列表和对应的模块: odbc res_config_odbc sqlite res_config_sqlite pgsql res_config_pgsql curl res_config_curl ldap res_config_ldap 为了通用性,我选择了ODBC作为获得和修改Asterisk配置信息的方式,数据库使用mysql。在这里我不介绍如何安装unixODBC和mysql,只对相关的表和配置文件做介绍。 使用到的表结构 静态配置表 CREATE TABLE `ast_config` ( `id` int(11) NOT NULL auto_increment, `cat_metric` int(11) NOT NULL default 0, `var_metric` int(11) NOT NULL default 0, `commented` int(11) NOT NULL default 0, `filename` varchar(128) NOT NULL default , `category` varchar(128) NOT NULL default default, `var_name` varchar(128) NOT NULL default , `var_val` varchar(128) NOT NULL default , PRIMARY KEY (`id`), KEY `filename_comment` (`filename`,`commented`) ) 这个表结构是一个通用的保存各种.conf文件信息的表结构。Asterisk可以让模块的配置信息保存在一个表中,或者分别保存在不同的表中。 下面是表的说明 Column name Column type Description id Serial, auto-incrementing An auto-incrementing unique value for each row in the table. cat_metric Integer The weight of the category within the file. A lower metric means it appears higher in the file (see the sidebar ). context类型的权重 var_metric Integer The weight of an item within a category. A lower metric means it appears higher in the list (see the sidebar ). This is useful for things like codec order in sip.conf, or iax.conf where you want disallow=all to appear first (metric of 0), followed by allow=ulaw (metric of 1), then allow=gsm (metric of 2). 变量的权重 filename Varchar 128 The filename the module would normally read from the hard drive of your system (e.g., musiconhold.conf, sip.conf, iax.conf, etc.). 文件名 category Varchar 128 The section name wi

文档评论(0)

1亿VIP精品文档

相关文档