本文主要是介绍微信多群直播服务器,基于srs直播群集架构之一路rtmp推流,多rtmp拉流,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
基于srs直播群集架构之一路rtmp推流,多rtmp拉流
一、架构设计
1、基础网络设施架构
2、一台目标推流的服务器,负责直播的源存储转发(origin)
3、一台loadbalance服务器,负责边界拉流服务器的负载调度(loadbalance)
4、两台realserver服务器,参与负载调度的边界拉流服务器(edge)
5、参与负载调度的服务器可以横向扩展
6、架构设计图,见下图
二、环境说明
所有服务器系统:centos-6.7-x86_64 Linux内核2.6.32
推流系统:网络摄像头作为视频源(rtsp),obs采集视频并推流(rtmp)
直播服务器软件: srs(simple-rtmp-server) SRS-CentOS6-x86_64-2.0.205.zip
loadbalance软件: ipvsadm-1.26-4.el6.x86_64 && keepalived-1.2.13-5.el6_6.x86_64
三、系统实现
1、推流服务器配置,即srs-origin
网卡配置:eth2:172.16.1.207/24
srs服务器配置:
a.安装srs服务器,默认安装后路径 /usr/local/srs
cd /usr/local/src
unzip SRS-CentOS6-x86_64-2.0.205.zip
./ INSTALL
b.修改配置文件ln -s /usr/local/srs /etc/srs
vim origin.conf
listen 1935;
max_connections 1000;
pid objs/origin.pid;
srs_log_file ./objs/origin.log;
vhost __defaultVhost__ {
gop_cache off;
queue_length 10;
min_latency on;
mr {
enabled off;
}
mw_latency 100;
tcp_nodelay on;
}
将/etc/init.d/srs 启动脚本中srs.conf 修改为origin.conf
c.启动srs服务
service srs start
推流和拉流测试rtmp://172.16.1.228/live/livestream
2、loadbalance服务器配置,即loadbalance
网卡配置eth2:172.16.1.208/24 eth2:0:172.16.1.200/24
网络参数配置:vim /etc/sysctrl.conf 修改 net.ipv4.ip_forward = 1
安装调度器软件ipvsadm&&keepalived :yum install ipvsadm keepalived -y
配置keepalived:vim /etc/keepalived/keepalived.conf
! Configuration File for keepalived
global_defs {
notification_email {
}
notification_email_from keepalived@localhost
#smtp_server 192.168.200.1
#smtp_connect_timeout 30
#router_id LVS_DEVEL
}
vrrp_instance VI_1 {
state MASTER
interface eth2
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
172.16.1.200
}
}
virtual_server 172.16.1.200 1935 {
delay_loop 6
lb_algo rr
lb_kind DR
nat_mask 255.255.255.0
persistence_timeout 50
protocol TCP
real_server 172.16.1.211 1935 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
real_server 172.16.1.207 1935 {
weight 1
TCP_CHECK {
connect_timeout 3
nb_get_retry 3
delay_before_retry 3
}
}
}
启动服务和保存配置:service network restart service ipvsadm start service keepalived start
3、realserver1服务器配置,即srs-edge1
网卡配置:eth2:172.16.1.211/24 lo:0:172.16.1.200/32
网络参数配置:vim /etc/sysctrl.conf 修改 net.ipv4.ip_forward = 1 添加 net.ipv4.conf.all.arp_ignore=1
net.ipv4.conf.all.arp_announce=2
添加本地路由:route add -host 172.16.1.200 dev lo:0
srs服务器配置:
a.安装srs服务器,默认安装后路径 /usr/local/srs
cd /usr/local/src
unzip SRS-CentOS6-x86_64-2.0.205.zip
./ INSTALL
b.修改配置文件ln -s /usr/local/srs /etc/srs
vim edge.conf
listen 1935;
max_connections 1000;
pid objs/edge.pid;
srs_log_file ./objs/edge.log;
vhost __defaultVhost__ {
mode remote;
origin 172.16.1.228:1935;
}
将/etc/init.d/srs 启动脚本中srs.conf 修改为edge.conf
c.启动srs服务,并重启网卡服务
service srs start service network restart
4、realserver2服务器配置,即srs-edge2
网卡配置:eth2:172.16.1.207/24 lo:0:172.16.1.200/32
网络参数配置:vim /etc/sysctrl.conf 修改 net.ipv4.ip_forward = 1 添加 net.ipv4.conf.all.arp_ignore=1
net.ipv4.conf.all.arp_announce=2
添加本地路由:route add -host 172.16.1.200 dev lo:0
srs服务器配置:
a.安装srs服务器,默认安装后路径 /usr/local/srs
cd /usr/local/src
unzip SRS-CentOS6-x86_64-2.0.205.zip
./ INSTALL
b.修改配置文件ln -s /usr/local/srs /etc/srs
vim edge.conf
listen 1935;
max_connections 1000;
pid objs/edge.pid;
srs_log_file ./objs/edge.log;
vhost __defaultVhost__ {
mode remote;
origin 172.16.1.228:1935;
}
将/etc/init.d/srs 启动脚本中srs.conf 修改为edge.conf
c.启动srs服务,并重启网卡服务
service srs start service network restart
四、系统测试
最终群集结果:
单路推流服务器地址:rtmp://172.16.1.228/live/streamlive
多路拉流服务器地址:rtmp://172.16.1.200/live/streamlive
这篇关于微信多群直播服务器,基于srs直播群集架构之一路rtmp推流,多rtmp拉流的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!