FreeSwitch+Opensips+NFS文件共享集群安装配置操作指导书_第1页
FreeSwitch+Opensips+NFS文件共享集群安装配置操作指导书_第2页
FreeSwitch+Opensips+NFS文件共享集群安装配置操作指导书_第3页
FreeSwitch+Opensips+NFS文件共享集群安装配置操作指导书_第4页
FreeSwitch+Opensips+NFS文件共享集群安装配置操作指导书_第5页
已阅读5页,还剩18页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、Freeswitch+Opensips+NFS集群安装配置指导书文档密级confidentiality levelFreeSwitch+Opensips集群安装配置操作指导书拟制:Prepared by杨机智 日期:Date2015-9-24审核:Reviewed by日期:Date审核:Reviewed by日期:Date批准:Granted by日期:Date修订记录Revision record日期Date修订版本Revision version修改描述 change Description作者Author2015-9-241.00初稿完成 杨机智目 录Table of Contents

2、 1集群组网72Opensips安装配置72.1环境说明72.2安装依赖的包82.3安装Opensips82.4配置Mysql82.5复制启动脚本82.6启动Opensips93集群配置93.1Opensips负载均衡配置93.2Freeswitch集群配置123.2.1环境说明123.2.2安装依赖的包133.2.3ODBC配置133.2.4Freeswitch安装143.2.5数据库共享配置143.2.6账号数据库验证模式配置143.2.7High Availability配置163.2.8共享数据库表结构说明173.3NFS文件共享配置183.3.1NFS软件包安装183.3.2NFS

3、Server配置183.3.1NFS Server启动关闭193.3.1NFS Client配置193.3.1NFS Client 挂载卸载203.1rsync文件同步配置203.1.1rsync介绍203.1.2rsync安装203.1.3rsync服务端配置203.1.4rsync客户端配置223.1.5rsync文件同步224常见问题解决方法224.1用nslookup 解析域名解析不了224.1.1现象描述224.1.2原因分析234.1.3处理方法234.2数据库连接不上234.2.1现象描述234.2.2原因234.2.3解决方法23表目录 List of Tables表1 XX表

4、 Table 1 XX3图目录 List of Figures图1 XX图 Figure 1 XX3第23页,共23页Page 23 , Total23FreeSwitch+Opensips集群安装配置操作指导书关键词Key words:FreeSwitch,Opensips,NFS,集群摘 要Abstract:本文介绍了Freeswitch+Opensips集群的安装与配置缩略语清单List of abbreviations:Abbreviations缩略语Full spelling 英文全名Chinese explanation 中文解释1 集群组网集群组网如下图所示:集群组网说明:Ope

5、nsips部署在前端,作为集群的负载均衡器,同时负责对FS节点的健康检查及故障转移Freeswitch服务器集群部署在中间,提供注册及通话等服务后端为mysql数据库及NFS服务器,mysql提供Freeswitch集群各节点的注册信息、会话信息的共享,NFS服务器提供Freeswitch集群各节点配置文件的共享2 Opensips安装配置2.1 环境说明操作系统:CentOS 6.3 32位(会升级为6.6)数据库:Mysql 5.1.732.2 安装依赖的包# yum install gcc-c+ bison flex lynx subversion2.3 安装Opensips从官方网站:

6、/,下载稳定的版本,当前为:1.11.3解压:# tar -zxvf opensips-1.11.3_src.tar.gz安装:# cd opensips-1.11.3-tls# make menuconfig(选择Configure Compile Options-Configure Excluded Modules-mysql)# make include_modules=”db_mysql” prefix=”/usr/local” install完成之后会在/usr/local/etc/下生成opensips文件夹2.4 配置Mysql1. 进

7、入安装目录/etc/opensips/,编辑opensipsctlrc文件DBENGINE=MYSQL(可选的有MYSQL, PGSQL, ORACLE, DB_BERKELEY, or DBTEXT)DBHOST=localhost(数据库所在主机)DBNAME=opensips(数据库的名称)DBRWUSER=opensips(数据库的用户名)DBRWPW=opensips(数据库的密码)DBROOTUSER=root(使用该数据库的用户)2. 在安装目录/sbin/下运行:./opensipsdbctl create3. 进入Mysql修改权限:grant all privileges

8、on opensips.* to opensipslocalhost identified by 'opensips'2.5 复制启动脚本# cp /usr/src/opensips-1.11.3-tls/packaging/rpm/opensips.init /etc/init.d/opensips# sed -i "s/usr/sbin/opensips/usr/local/sbin/opensips/g" /etc/init.d/opensips# sed -i "s/etc/opensips/usr/local/etc/opensips/g

9、" /etc/init.d/opensips# sed -i "s/etc/default/opensips/usr/local/etc/opensips/g" /etc/init.d/opensips# sed -i "s/RUN_OPENSIPS=no/RUN_OPENSIPS=yes/g" /etc/init.d/opensipschmod +x /etc/init.d/opensips2.6 启动Opensips进入安装目录/sbin/运行: ./opensips3 集群配置3.1 Opensips负载均衡配置步骤1、修改opensip

10、s.cfg文件(建议先备份)debug=6#设置输出的日志级别log_stderror=yes#将Log打印到控制台上log_facility=LOG_LOCAL0#日志输出fork=no#启动到前台,便于调试children=4disable_tcp=yesdns_try_ipv6=noauto_aliases=nodisable_tls=yeslisten=udp:40:5060#用于监听IP地址和端口# 加载的模块#set module pathmpath="/usr/local/lib/opensips/modules/"# SIGNALING mo

11、duleloadmodule "signaling.so"# StateLess moduleloadmodule "sl.so"# Transaction Moduleloadmodule "tm.so"modparam("tm", "fr_timeout", 5)modparam("tm", "fr_inv_timeout", 30)modparam("tm", "restart_fr_on_each_reply"

12、;, 0)modparam("tm", "onreply_avp_mode", 1)modparam("tm", "fr_timer", 2)# Record Route Moduleloadmodule "rr.so"/* do not append from tag to the RR (no need for this script) */modparam("rr", "append_fromtag", 1)modparam("rr&quo

13、t;, "enable_double_rr", 1)# MAX ForWarD moduleloadmodule "maxfwd.so"# SIP MSG OPerationS moduleloadmodule "sipmsgops.so"# FIFO Management Interfaceloadmodule "mi_fifo.so"modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo")#modpa

14、ram("mi_fifo", "fifo_mode", 0666)# URI moduleloadmodule "uri.so"modparam("uri", "use_uri_table", 0)# USeR LOCation moduleloadmodule "usrloc.so"modparam("usrloc", "nat_bflag", "NAT")modparam("usrloc",

15、"db_mode", 0)# REGISTRAR moduleloadmodule "registrar.so"modparam("registrar", "tcp_persistent_flag", "TCP_PERSISTENT")/* uncomment the next line not to allow more than 10 contacts per AOR */#modparam("registrar", "max_contacts", 1

16、0)# ACCounting moduleloadmodule "acc.so"/* what special events should be accounted ? */modparam("acc", "early_media", 0)modparam("acc", "report_cancels", 0)/* by default we do not adjust the direct of the sequential requests. if you enable this param

17、eter, be sure the enable "append_fromtag" in "rr" module */modparam("acc", "detect_direction", 0)modparam("acc", "failed_transaction_flag", "ACC_FAILED")/* account triggers (flags) */modparam("acc", "log_flag",

18、 "ACC_DO")modparam("acc", "log_missed_flag", "ACC_MISSED")loadmodule "textops.so"# db_mysql moduleloadmodule "db_mysql.so"db_default_url="mysql:/opensips:opensipslocalhost/opensips"# dialog moduleloadmodule "dialog.so"mo

19、dparam("dialog", "db_mode", 1)modparam("dialog", "db_url", "mysql:/opensips:opensipslocalhost/opensips")# dispatcher moduleloadmodule "dispatcher.so"modparam("dispatcher", "db_url", "mysql:/opensips:opensipslocalhos

20、t/opensips")modparam("dispatcher", "ds_ping_method", "OPTIONS")modparam("dispatcher", "ds_ping_interval", 5)modparam("dispatcher", "ds_probing_threshhold", 2)modparam("dispatcher", "ds_probing_mode", 1)# l

21、oad_balancer moduleloadmodule "load_balancer.so"modparam("load_balancer", "db_url", "mysql:/opensips:opensipslocalhost/opensips")modparam("load_balancer", "probing_method", "OPTIONS")modparam("load_balancer", "probi

22、ng_interval", 5)# Routing Logic # main request routing logicroute if (!mf_process_maxfwd_header("10") sl_send_reply("483","Too Many Hops"); exit; if (!has_totag() # initial request record_route(); else # sequential request - obey Route indication loose_route(); t_r

23、elay(); exit; # CANCEL processing if (is_method("CANCEL") if (t_check_trans() t_relay(); exit; # from now on we have only the initial requests # select the node that'll handle the call (load balanced) # the method used is different for invite/register requests # unknown methods are rej

24、ected hereif (is_method("INVITE") if (!load_balance("1","pstn","1") send_reply("503","Service Unavailable"); exit; else if (is_method("REGISTER") if (!ds_select_dst("1", "0") send_reply("503","Se

25、rvice Unavailable"); exit; else send_reply("405","Method Not Allowed"); exit; # route the request if (!t_relay() sl_reply_error(); 步骤2、添加Freeswitch节点添加Freeswitch节点作为负载均衡:mysql> use opensips;mysql> insert into load_balancer (group_id, dst_uri, resources, description)val

26、ues (1,'sip:30', 'pstn=32', 'FS1');mysql> insert into load_balancer (group_id, dst_uri, resources, description)values (1,'sip:32', 'pstn=32', 'FS2');mysql> quit;添加分发器节点:格式为:opensipsctl dispatcher addgw <setid> <destinatio

27、n> <socket> <state> <weight> <attrs> descriptionopensipsctl dispatcher addgw 1 sip:30 '' 0 50 'FS1' '230 cluster-FS1'opensipsctl dispatcher addgw 1 sip:32 '' 0 50 'FS1' '230 cluster-FS1'此时就可以将SIP客户端注册到上,可以看到两个

28、Freeswitch的节点上发现了注册日志3.2 Freeswitch集群配置3.2.1 环境说明操作系统:CentOS 6.3 32位(后面会更新成6.6)Freeswitch:1.4数据库:Mysql 5.1.733.2.2 安装依赖的包系统需要的包: # yum install git gcc-c+ autoconf automake libtool wget python ncurses-devel zlib-devel libjpeg-devel openssl-devel e2fsprogs-devel sqlite-devel libcurl-devel pcre-devel s

29、peex-devel ldns-devel libedit-develODBC需要的包:# yum install unixODBC unixODBC-develMysql需要的包:# yum install mysql-connector-odbc更新系统的内核及依赖包:# yum y update3.2.3 ODBC配置1、修改/etc/odbc.ini 配置要连接的数据库信息freeswitchDriver = /usr/lib/libmyodbc5.soSERVER = 20(数据库地址)PORT = 3306DATABASE = freeswitch(数据库上要先创建

30、该数据库名称)USER = root(数据库用户名)PASSWORD = 123456(数据库密码)OPTION = 67108864(freeswitch会将多条SQL语句放一起执行,提高效率)2、/etc/odbcinst.ini 修改mysq的部分,将驱动包指向正确,关注Mysql数据库配置即可。MySQLDescription = ODBC for MySQLDriver = /usr/lib/libmyodbc5.soSetup = /usr/lib/libodbcmyS.soFileUsage = 13、修改之后,执行 isql -v freeswitch如果出现roottest

31、etc# isql -v freeswitch+-+| Connected! | | sql-statement | help tablename | quit | |+-+SQL> 则代表你的unixodbc配置成功了3.2.4 Freeswitch安装# cd /usr/local/src# git clone -b v1.4 /stash/scm/fs/Freeswitch.git# cd /usr/local/src/Freeswitch# ./configure -enable-core-odbc-support# make#

32、 make install# make cd-sounds-install(声音包)# make cd-moh-install(声音包)完成之后会默认在/usr/local/路径下3.2.5 数据库共享配置在每一个Freeswitch集群节点按照如下设置数据库共享:修改:/usr/local/freeswitch/conf/autoload_configs/switch.conf.xml <param name="core-db-dsn" value="freeswitch:root:123456" />修改:/usr/local/frees

33、witch/conf/autoload_configs/db.conf.xml<param name="odbc-dsn" value="freeswitch:root:123456"/>修改:/usr/local/freeswitch/conf/sip_profiles/internal.xml<param name="odbc-dsn" value="freeswitch:root:123456"/>修改freeswitch下的vars.xml文件,将<X-PRE-PROCESS

34、cmd="set" data="domain=$local_ip_v4"/>修改成:<X-PRE-PROCESS cmd="set" data="domain="/>3.2.6 账号数据库验证模式配置Freeswitch默认是采用conf/directory/目录下的账号文件来进行注册账号的验证。如果采用共享数据库的模式,也可以配置成通过mysql数据库的users表来进行注册账号的验证。具体可以通过如下步骤来修改:修改freeswitch/conf/autoload_configs/lua.co

35、nf.xml,内容如下:<param name="xml-handler-script" value="/usr/local/freeswitch/scripts/gen_dir_user_xml.lua" /><param name="xml-handler-bindings" value="directory" />其中gen_dir_user_xml.lua内容如下:freeswitch.consoleLog("NOTICE","lua take the

36、users.n");- gen_dir_user_xml.lua- example script for generating user directory XML- comment the following line for production:-freeswitch.consoleLog("notice", "Debug from gen_dir_user_xml.lua, provided params:n" . params:serialize() . "n")local req_domain = params:

37、getHeader("domain")local req_key = params:getHeader("key")local req_user = params:getHeader("user")local req_password = params:getHeader("pass")-database name:freeswitch-database user:root-database media:medialocal dbh = freeswitch.Dbh("freeswitch",&

38、quot;root","media");freeswitch.consoleLog("NOTICE","start connect DB.rn");assert(dbh:connected();-database user table name:Usersdbh:query("select password from Users where id=".req_user,function(row)freeswitch.consoleLog("NOTICE",string.format(&

39、quot;%sn",row.password)req_password=string.format("%s",row.password)end);dbh:release();freeswitch.consoleLog("NOTICE","info:".req_domain."-".req_key."-".req_user."-".req_password."n");-assert (req_domain and req_key and req_u

40、ser,-"This example script only supports generating directory xml for a single user !n")if req_domain = nil and req_key=nil and req_user=nil then XML_STRING = <?xml version="1.0" encoding="UTF-8" standalone="no"?> <document type="freeswitch/xml&qu

41、ot;> <section name="directory"> <domain name=".req_domain."> <params> <param name="dial-string" value="presence_id=$dialed_user$dialed_domain$sofia_contact($dialed_user$dialed_domain)"/> </params> <groups> <group name=

42、"default"> <users> <user id=" .req_user."> <params> <param name="password" value=".req_password."/> <param name="vm-password" value=".req_password."/> </params> <variables> <variable name=&quo

43、t;toll_allow" value="domestic,international,local"/> <variable name="accountcode" value=" .req_user."/> <variable name="user_context" value="default"/> <variable name="directory-visible" value="true"/> &l

44、t;variable name="directory-exten-visible" value="true"/> <variable name="limit_max" value="15"/> <variable name="effective_caller_id_name" value="Extension .req_user."/> <variable name="effective_caller_id_number"

45、; value=" .req_user."/> <variable name="callgroup" value="techsupport"/> </variables> </user> </users> </group> </groups> </domain> </section> </document>else XML_STRING = <?xml version="1.0" encoding

46、="UTF-8" standalone="no"?> <document type="freeswitch/xml"> <section name="directory"> </section> </document>end- comment the following line for production:freeswitch.consoleLog("notice", "Debug from gen_dir_user_xml.l

47、ua, generated XML:n" . XML_STRING . "n");拨号规则配置(用于测试使用)<include> <extension name="freeswitch"> <condition field="destination_number" expression="(29d2)$"> <action application="log" data="INFO test update mount file 219&

48、quot; /> <action application="set" data="dialed_extension=$1"/> <action application="bridge" data="user/$dialed_extension$domain_name"/> </condition> </extension></include>3.2.7 High Availability配置为了freeswitch在故障之后能够恢复,需要进行3步配置

49、:1. 将故障前的信息写入数据库中,在sip_profiles/internal.xml添加参数:<param name="track-calls" value="true"/>2. Freeswitch恢复时是通过hostname来查询数据库中的数据,需要在switch.conf.xml中修改:<param name="switchname" value="freeswitch"/>3. 如果手动恢复freeswitch,需要在控制台中执行命令:sofia recover4. 如果自动恢复

50、freeswitch,需要在freeswitch.xml中添加:<X-PRE-PROCESS cmd="set" data="api_on_startup=sofia recover"/>3.2.8 共享数据库表结构说明表名来源作用备注aliasesfreeswitchbasic_callfreeswitch通话的基本信息视图callsfreeswitch通话的记录表,只记录双方的uuid和时间channelsfreeswitch记录一次通话的双方具体信息db_datafreeswitchdetailed_callsfreeswitch通话的

51、详细信息视图group_datafreeswitchinterfacesfreeswitch保存当前Freeswitch提供出的接口,可以是application中的也可以是file中的limit_datafreeswitchnatfreeswitchrecoveryfreeswitch需要恢复的信息依赖3.2.7的配置记录下通话的信息registrationsfreeswitch已注册的SIP账号信息sip_authenticationfreeswitch保存服务器对SIP客户端的消息摘要信息sip_dialogsfreeswitch保存每路通话的信息sip_presencefreeswit

52、chsip_registrationsfreeswitch保存已注册的SIP客户端信息sip_shared_appearance_dialogsfreeswitchsip_shared_appearance_subscriptionsfreeswitchsip_subscriptionsfreeswitch存储非话机的SIP客户端例如使用Xlite注册时会被记录到该表中tasksfreeswitchusers外部创建存储SIP账号目前该表仅做测试使用数据库表:Users名称类型长度是否为空是否主键备注idvarchar128NYpasswordvarchar128NN3.3 NFS文件共享配置

53、3.3.1 NFS软件包安装NFS服务器和FreeSwitch各节点都要安装nfs 和 rpcbind 软件包:yum -y install nfs-utils rpcbind3.3.2 NFS Server配置步骤1:在服务器上创建NFS共享目录:mkdir /usr/local/freeswitch/conf步骤2:设置共享目录的读写权限: chmod 666 /usr/local/freeswitch/conf步骤3: 编辑export文件: vi /etc/exports /usr/local/freeswitch/conf 10.3.4.xxx(rw,no_root_squash,n

54、o_all_squash,sync)注意地址和参数表之间没有空格。如果下面设置的mountd端口大于1024,需要在参数表里加入参数:insecure步骤4: 配置生效:exportfs -r注:配置文件说明:/usr/local/freeswitch/conf 为Freeswitch集群各节点共享的目录,使用绝对路径。10.3.4.xxx(rw,no_root_squash,no_all_squash,sync) 为客户端的地址及权限,地址可以是一个网段(如:/24),一个IP地址或者是一个域名,域名支持通配符,如:*,地址与权限中间没有空格。权限说明:rw:read-

55、write,可读写;ro:read-only,只读;sync:文件同时写入硬盘和内存;async:文件暂存于内存,而不是直接写入内存;no_root_squash:NFS客户端连接服务端时如果使用的是root的话,那么对服务端分享的目录来说,也拥有root权限。显然开启这项是不安全的。root_squash:NFS客户端连接服务端时如果使用的是root的话,那么对服务端分享的目录来说,拥有匿名用户权限,通常他将使用nobody或nfsnobody身份;all_squash:不论NFS客户端连接服务端时使用什么用户,对服务端分享的目录来说都是拥有匿名用户权限;anonuid:匿名用户的UID值,

56、通常是nobody或nfsnobody,可以在此处自行设定;anongid:匿名用户的GID值。3.3.1 NFS Server启动关闭启动:# service rpcbind start# service nfs start重启:# service nfs restart关闭:# service nfs stop3.3.1 NFS Client配置步骤1:扫瞄可以使用的NFS Server目录showmount -e 10.3.4.xxx步骤2:创建挂载目录mkdir /usr/local/freeswitch/conf /对于freeswitch节点这一步可以省略,因为目录已经存在了步骤3

57、:使用mount进行挂载mount -t nfs 0:/usr/local/freeswitch/conf /usr/local/freeswitch/conf -o proto=tcp -o nolock注:为了提高NFS的稳定性,使用TCP协议挂载,NFS默认用UDP协议步骤4:查看挂载情况用如下命令查看:# df Filesystem 1K-blocks Used Available Use% Mounted on/dev/mapper/VolGroup-lv_root 51606140 3471488 45513212 8% /tmpfs 2004288 0 2004288 0% /dev/shm/dev/sda1 495844 52809 417435 12% /boot/dev/mapper/VolGroup-lv_home 42452

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论