opensips+rtpproxy安装笔记

    xiaoxiao2021-03-25  204

    此文完整记录了利用官网提供的rpm包搭建opensips+rtpproxy服务,实现视频通话全过程,留下记号,自我总结一下,方便日后查阅。


    系统环境:CentOS7 x64 软件版本: opensips :v2.2.3-1 rtpproxy : v2.0.0 mysql : 5.6.35


    安装opensips

    ①安装epel(Extra Packages for Enterprise Linux)
    rpm -ivh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-9.noarch.rpm rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 yum install yum-priorities
    ②安装opensips包
    mkdir /opt/soft cd /opt/soft/ wget http://yum.opensips.org/2.2/releases/el/7/x86_64/opensips-yum-releases-2.2-3.el7.noarch.rpm yum localinstall opensips-yum-releases-2.2-3.el7.noarch.rpm yum install opensips
    ③安装mysql模块

    上述获取的opensips rpm包中未包含mysql模块,需手动下载对应opensips版本模块安装,模块汇总下载地址为:http://yum.opensips.org/browse.php

    wget http://yum.opensips.org/2.2/releases/el/7/x86_64/opensips-db_mysql-2.2.3-1.el7.x86_64.rpm rpm -ivh opensips-db_mysql-2.2.3-1.el7.x86_64.rpm

    安装rtpproxy

    执行如下命令:

    yum install rtpproxy

    启动rtpproxy

    rtpproxy -F

    安装mysql

    ①安装mysql repo源
    wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm rpm -ivh mysql-community-release-el7-5.noarch.rpm
    ②安装mysql服务
    yum install mysql-server
    ③权限配置及root密码修改

    //权限配置

    chown -R root:root /var/lib/mysql service mysqld restart mysql -u root

    //root密码修改及分配权限

    update user set password=password('123456') where user='root'; GRANT ALL ON *.* TO root@'%' IDENTIFIED BY '123456'; SET GLOBAL sql_mode = ''; //此处设置避免opensips创建opensips数据库出错 FLUSH PRIVILEGES; exit

    配置opensips

    ①配置opensipsctlrc文件
    vi /etc/opensips/opensipsctlrc

    将对应字段的内容修改如下

    SIP_DOMAIN=192.168.2.73 //此处改为你服务器本机IP DBENGINE=MYSQL DBHOST=localhost DBNAME=opensips DBRWUSER=opensips DBRWPW="opensipsrw" USERCOL="username" ETCDIR="/etc/opensips"
    ②创建opensips.cfg配置文件并配置
    osipsconfig ---> Generate OpenSIPS Script ---> Residential Script ---> Configure Residential Script [*] ENABLE_TCP [*] USE_AUTH [*] USE_DBACC [*] USE_DBUSRLOC [*] USE_DIALOG [*] USE_NAT ---> Save Residential Script ---> Generate Residential Script ---> Exit & Save All Changes

    成功会生成提示 /usr/etc/opensips/opensips_residential_2017-3-8_10:45:27.cfg = SUCCESS 如若失败,则手动创建 /usr/etc/opensips目录,mkdir /usr/etc/opensips

    //备份旧配置文件

    cp /etc/opensips/opensips.cfg /etc/opensips/opensips.cfg.origin

    //移动上述产生的配置文件并重命名

    mv /usr/etc/opensips/opensips_residential_2017-3-8_10:45:27.cfg /etc/opensips/opensips.cfg

    //修改opensips.cfg

    vi /etc/opensips/opensips.cfg

    //监听地址改为本机服务器IP

    listen=udp:192.168.2.73:5060 # CUSTOMIZE ME listen=tcp:192.168.2.73:5060 # CUSTOMIZE ME

    //rtpproxy模块配置

    modparam("rtpproxy", "rtpproxy_sock", "unix:/var/run/rtpproxy.sock")
    ③创建opensips数据库
    opensipsdbctl create
    启动opensips服务并测试
    opensipsctl start

    //创建账号

    opensipsctl add test01 test01 opensipsctl add test02 test02

    添加的账号在数据库subscriber表中,下载sip客户端测试,PC端建议使用X-lite或Linphone,手机端使用linphone测试,Domain填写opensips服务器IP,账号/密码填写上述创建的即可注册、呼叫测试。

    //查看在线用户

    opensipsctl ul show opensipsctl online

    ============================================================== 至此,已全部完成opensips服务及rtpproxy代理服务搭建,正常情况下可以实现视频通话。

    问题纪录汇总

    1.开放数据库3306端口,使其他客户端可以远程登录

    参考解决链接:http://www.111cn.net/sys/CentOS/109189.htm

    2.执行opensipsdbctl create 创建数据库报错

    ERROR: could not load the script in /usr/lib64/opensips/opensipsctl/opensipsdbctl.mysql for database engine MYSQL ERROR: database engine not loaded - tried ‘MYSQL’ 解决办法:rpm包未包含mysql模块,需访问官网下载提供的对应安装版本的db_mysql rpm包安装即可

    ERROR 1101 (42000) at line 2: BLOB/TEXT column ‘extra_hdrs’ can’t have a def 解决办法:mysql> SET GLOBAL sql_mode = ”;

    3.Generate Residential Script 失败

    /usr/etc/opensips/opensips_residential_2017-2-28_9:39:49.cfg = FAILED 解决办法:创建/usr/etc/opensips/目录

    4.执行opensipsctl start

    ERROR: PID file /var/run/opensips.pid does not exist – OpenSIPS start failed 解决办法:修改opensips.cfg文件中的db_url地址,大多数为权限问题 “mysql://opensips:opensips@localhost/opensips”) # CUSTOMIZE ME

    5.建立用户后注册不上用户

    将opensips.cfg文件中listen=udp:127.0.0.1:5060 # CUSTOMIZE ME 修改为:listen=udp:192.168.2.73:5060 #这里的的IP以本机实际IP为准

    6. ERROR:rtpproxy:force_rtp_proxy: Unable to parse body

    解决办法: 将opensips.cfg文件中 if ( isflagset(NAT) ) rtpproxy_answer(“ro”); 修改为: if ( isflagset(NAT) && has_body(“application/sdp”) ) rtpproxy_answer(“ro”);


    注:使用过程中,出现错误,日志记录在/var/log/messages,查看日志解决问题。


    参考链接:

    1.安装epel:http://blog.csdn.net/yasi_xi/article/details/11746255 2.opensips官网: http://yum.opensips.org/packages.php?v=2.2 http://yum.opensips.org/browse.php 3.安装mysql:http://www.mamicode.com/info-detail-503994.html 4.rtpproxy: http://www.rtpproxy.org/post/v2release/ http://blog.csdn.net/forest_world/article/details/51647108 5.配置参考链接: http://blog.chinaunix.net/uid-26118446-id-5615983.html http://blog.csdn.net/cazicaquw/article/details/7376026 http://www.cnblogs.com/bjzhanghao/archive/2013/02/13/2910903.html https://yq.aliyun.com/articles/44437 6.centos7 防火墙配置:http://www.linuxidc.com/Linux/2015-05/117473.htm

    转载请注明原文地址: https://ju.6miu.com/read-1008.html

    最新回复(0)