网咖网络规划与安装流媒体服务器

                                              **概要设计**

战神咖按照业务功能分成以下几个分区:普通上网区、游戏区、包厢区、视频区、商务区,各个分区部署在不同VLAN。IP网段分别为172.16.1.0/24——172.16.5.0/24。网吧的客户机采用千兆接入局域网,交换机带有万兆上行接口。出于安全考虑,网吧部署了监控系统,并由PoE交换机集中供电,采集的视频存储于网络硬盘录像机供调取。根据需要网吧在CentOS6.5上架设了流媒体服务器用于存放电影,音乐和视频游戏,部署DHCP服务为各功能分区统一提供IP地址等管理。网管系统和计费系统采用单独的软件部署在Windows7上,采用硬件防火墙设置访问策略和过滤规则来优化网吧内外网环境,网吧采用100M电信和50M联通的双WAN出口规划,以实现冗余和流量均衡。
根据以上要求给出设计方案,设备选型,拓扑设计,IP规划,产品配置,应用服务器配置,设计结果验证。

                                                **网络设计拓扑图** 

网咖网络规划与安装流媒体服务器_第1张图片

主要调试配置命令
1.1.接入层交换机配置:
sw3:
u t m
sys
sys sw3
vlan 10
int e0/0/3
port link-type acc
port default vlan 10
int g0/0/1
port link-type trunk
port trunk allow vlan 10
int g0/0/2
port link-type trunk
port trunk allow vlan 10
quit
stp enable
stp mode mstp
stp region-configuration
region-name huawei
instance 1 vlan 10 20 30
instance 2 vlan 40 50 60 70
active region-configuration
quit
int e0/0/3
stp edged-port enable
quit
stp bpdu-protection

sw4:
u t m
sys
sys sw4
vlan 20
int e0/0/3
port link-type acc
port default vlan 20
int g0/0/1
port link-type trunk
port trunk allow vlan 20
int g0/0/2
port link-type trunk
port trunk allow vlan 20
quit
stp enable
stp mode mstp
stp region-configuration
region-name huawei
instance 1 vlan 10 20 30
instance 2 vlan 40 50 60 70
active region-configuration
quit
int e0/0/3
stp edged-port enable
quit
stp bpdu-protection

sw5:
u t m
sys
sys sw5
vlan 30
int e0/0/3
port link-type acc
port default vlan 30
int g0/0/1
port link-type trunk
port trunk allow vlan 30
int g0/0/2
port link-type trunk
port trunk allow vlan 30
quit
stp enable
stp mode mstp
stp region-configuration
region-name huawei
instance 1 vlan 10 20 30
instance 2 vlan 40 50 60 70
active region-configuration
quit
int e0/0/3
stp edged-port enable
quit
stp bpdu-protection

sw6:
u t m
sys
sys sw6
vlan 40
int e0/0/3
port link-type acc
port default vlan 40
int g0/0/1
port link-type trunk
port trunk allow vlan 40
int g0/0/2
port link-type trunk
port trunk allow vlan 40
quit
stp enable
stp mode mstp
stp region-configuration
region-name huawei
instance 1 vlan 10 20 30
instance 2 vlan 40 50 60 70
active region-configuration
quit
int e0/0/3
stp edged-port enable
quit
stp bpdu-protection

sw7:
u t m
sys
sys sw7
vlan 50
int e0/0/3
port link-type acc
port default vlan 50
int g0/0/1
port link-type trunk
port trunk allow vlan 50
int g0/0/2
port link-type trunk
port trunk allow vlan 50
quit
stp enable
stp mode mstp
stp region-configuration
region-name huawei
instance 1 vlan 10 20 30
instance 2 vlan 40 50 60 70
active region-configuration
quit
int e0/0/3
stp edged-port enable
quit
stp bpdu-protection

sw8:
u t m
sys
sys sw8
vlan 60
int e0/0/3
port link-type access
port default vlan 60
int G0/0/1
port link-type trunk
port trunk allow vlan 60
int G0/0/2
port link-type trunk
port trunk allow vlan 60
quit
stp enable
stp mode mstp
stp region-configuration
region-name huawei
instance 1 vlan 10 20 30
instance 2 vlan 40 50 60 70
active region-configuration
quit
int e0/0/3
stp edged-port enable
quit
stp bpdu-protection

sw9:
u t m
sys
sys sw9
vlan 70
int e0/0/3
port link-type access
port default vlan 70
int G0/0/1
port link-type trunk
port trunk allow vlan 70
int G0/0/2
port link-type trunk
port trunk allow vlan 70
quit
stp enable
stp mode mstp
stp region-configuration
region-name huawei
instance 1 vlan 10 20 30
instance 2 vlan 40 50 60 70
active region-configuration
quit
int e0/0/3
stp edged-port enable
quit
stp bpdu-protection

1.2.流媒体服务器:
R1:
u t m
sys
sys zhanshen
dhcp enable
ip pool 10
gateway-list 172.16.1.254
network 172.16.1.0 mask 24
excluded-ip-address 172.16.1.253
lease day 3 hour 0 minute 0
dns-list 202.101.224.101
ip pool 20
gateway-list 172.16.2.254
network 172.16.2.0 mask 24
excluded-ip-address 172.16.2.253
lease day 3 hour 0 minute 0
dns-list 202.101.224.101
ip pool 30
gateway-list 172.16.3.254
network 172.16.3.0 mask 24
excluded-ip-address 172.16.3.253
lease day 3 hour 0 minute 0
dns-list 202.101.224.101
ip pool 40
gateway-list 172.16.4.254
network 172.16.4.0 mask 24
excluded-ip-address 172.16.4.253
lease day 3 hour 0 minute 0
dns-list 202.101.224.101
ip pool 50
gateway-list 172.16.5.254
network 172.16.5.0 mask 24
excluded-ip-address 172.16.5.253
lease day 3 hour 0 minute 0
dns-list 202.101.224.101
interface g0/0/1
ip address 172.16.8.2 24
dhcp select global
ip route-static 172.16.1.0 24 172.16.8.1
ip route-static 172.16.2.0 24 172.16.8.1
ip route-static 172.16.3.0 24 172.16.8.1
ip route-static 172.16.4.0 24 172.16.8.1
ip route-static 172.16.5.0 24 172.16.8.1
ip route-static 202.101.224.0 24 172.16.8.1
ip route-static 182.84.89.0 24 172.16.8.1
interface g0/0/2
ip address 172.16.9.2 24
dhcp select global
ip route-static 172.16.1.0 24 172.16.9.1
ip route-static 172.16.2.0 24 172.16.9.1
ip route-static 172.16.3.0 24 172.16.9.1
ip route-static 172.16.4.0 24 172.16.9.1
ip route-static 172.16.5.0 24 172.16.9.1
ip route-static 202.101.224.0 24 172.16.9.1
ip route-static 182.84.89.0 24 172.16.9.1

1.3.汇聚层交换机配置:
sw1:
u t m
sys
sys sw1
vlan batch 10 20 30 40 50 60 70 80 90
int g0/0/1
port link-type trunk
port trunk allow vlan 10
int g0/0/2
port link-type trunk
port trunk allow vlan 20
int g0/0/3
port link-type trunk
port trunk allow vlan 30
int g0/0/4
port link-type trunk
port trunk allow vlan 40
int g0/0/5
port link-type trunk
port trunk allow vlan 50
int g0/0/6
port link-type trunk
port trunk allow vlan 60
int vlanif60
ip add 172.16.6.254 24
int g0/0/7
port link-type trunk
port trunk allow vlan 70
int vlanif70
ip add 172.16.7.254 24
int g0/0/11
port link-type access
port default vlan 80
int vlanif80
ip add 172.16.8.1 24
int g0/0/8
port link-type access
port default vlan 90
int vlanif90
ip add 172.16.10.2 24
quit
ip route-static 0.0.0.0 0.0.0.0 172.16.10.1
dhcp enable
dhcp server group DHCP10
dhcp-server 172.16.8.2
interface vlanif10
ip add 172.16.1.254 24
dhcp select relay
dhcp relay server-select DHCP10
dhcp server group DHCP20
dhcp-server 172.16.8.2
interface vlanif20
ip add 172.16.2.254 24
dhcp select relay
dhcp relay server-select DHCP20
dhcp server group DHCP30
dhcp-server 172.16.8.2
interface vlanif30
ip add 172.16.3.254 24
dhcp select relay
dhcp relay server-select DHCP30
dhcp server group DHCP40
dhcp-server 172.16.8.2
interface vlanif40
ip add 172.16.4.254 24
dhcp select relay
dhcp relay server-select DHCP40
dhcp server group DHCP50
dhcp-server 172.16.8.2
interface vlanif50
ip add 172.16.5.254 24
dhcp select relay
dhcp relay server-select DHCP50
stp enable
stp mode mstp
stp region-configuration
region-name zhanshen
instance 1 vlan 10 to 30
instance 2 vlan 40 to 70
active region-configuration
quit
stp instance 1 root primary
stp instance 2 root secondary
int eth-trunk 1
int g0/0/9
eth-trunk 1
int g0/0/10
eth-trunk 1
int eth-trunk 1
port link-type trunk
port trunk allow-pass vlan all
quit
int vlanif10
vrrp vrid 1 virtual-ip 172.16.1.253
vrrp vrid 1 priority 150
vrrp vrid 1 preempt-mode timer delay 5
vrrp vrid 1 track interface g0/0/8 reduced 80
vrrp vrid 1 track interface g0/0/11 reduced 80
int vlanif20
vrrp vrid 2 virtual-ip 172.16.2.253
vrrp vrid 2 priority 150
vrrp vrid 2 preempt-mode timer delay 5
vrrp vrid 2 track interface g0/0/8 reduced 80
vrrp vrid 2 track interface g0/0/11 reduced 80
int vlanif30
vrrp vrid 3 virtual-ip 172.16.3.253
vrrp vrid 3 priority 150
vrrp vrid 3 preempt-mode timer delay 5
vrrp vrid 3 track interface g0/0/8 reduced 80
vrrp vrid 3 track interface g0/0/11 reduced 80
int vlanif40
vrrp vrid 4 virtual-ip 172.16.4.253
int vlanif50
vrrp vrid 5 virtual-ip 172.16.5.253
int vlanif60
vrrp vrid 6 virtual-ip 172.16.6.253
int vlanif70
vrrp vrid 7 virtual-ip 172.16.7.253
quit
ospf router-id 1.1.1.1
area 0
network 172.16.10.0 0.0.0.255
quit
ospf router-id 2.2.2.2
area 1
network 172.16.1.0 0.0.0.255
network 172.16.2.0 0.0.0.255
network 172.16.3.0 0.0.0.255
network 172.16.4.0 0.0.0.255
network 172.16.5.0 0.0.0.255
network 172.16.6.0 0.0.0.255
network 172.16.7.0 0.0.0.255
ospf router-id 4.4.4.4
area 3
network 172.16.8.0 0.0.0.255

sw2:
u t m
sys
sys sw2
vlan batch 10 20 30 40 50 60 70 80 90
int g0/0/1
port link-type trunk
port trunk allow vlan 10
int g0/0/2
port link-type trunk
port trunk allow vlan 20
int g0/0/3
port link-type trunk
port trunk allow vlan 30
int g0/0/4
port link-type trunk
port trunk allow vlan 40
int g0/0/5
port link-type trunk
port trunk allow vlan 50
int g0/0/6
port link-type trunk
port trunk allow vlan 60
int vlanif60
ip add 172.16.6.254 24
int g0/0/7
port link-type trunk
port trunk allow vlan 70
int vlanif70
ip add 172.16.7.254 24
int g0/0/11
port link-type access
port default vlan 80
int vlanif80
ip add 172.16.9.1 24
int g0/0/8
port link-type access
port default vlan 90
int vlanif90
ip add 172.16.11.2 24
quit
ip route-static 0.0.0.0 0.0.0.0 172.16.11.1
dhcp enable
dhcp server group DHCP10
dhcp-server 172.16.9.2
interface vlanif10
ip add 172.16.1.254 24
dhcp select relay
dhcp relay server-select DHCP10
dhcp server group DHCP20
dhcp-server 172.16.9.2
interface vlanif20
ip add 172.16.2.254 24
dhcp select relay
dhcp relay server-select DHCP20
dhcp server group DHCP30
dhcp-server 172.16.9.2
interface vlanif30
ip add 172.16.3.254 24
dhcp select relay
dhcp relay server-select DHCP30
dhcp server group DHCP40
dhcp-server 172.16.9.2
interface vlanif40
ip add 172.16.4.254 24
dhcp select relay
dhcp relay server-select DHCP40
dhcp server group DHCP50
dhcp-server 172.16.9.2
interface vlanif50
ip add 172.16.5.254 24
dhcp select relay
dhcp relay server-select DHCP50
stp enable
stp mode mstp
stp region-configuration
region-name zhanshen
instance 1 vlan 10 to 30
instance 2 vlan 40 to 70
active region-configuration
quit
stp instance 2 root primary
stp instance 1 root secondary
quit
int eth-trunk 1
int g0/0/9
eth-trunk 1
int g0/0/10
eth-trunk 1
int eth-trunk 1
port link-type trunk
port trunk allow-pass vlan all
quit
int vlanif10
vrrp vrid 1 virtual-ip 172.16.1.253
int vlanif20
vrrp vrid 2 virtual-ip 172.16.2.253
int vlanif30
vrrp vrid 3 virtual-ip 172.16.3.253
int vlanif40
vrrp vrid 4 virtual-ip 172.16.4.253
vrrp vrid 4 priority 150
vrrp vrid 4 preempt-mode timer delay 5
vrrp vrid 4 track interface g0/0/8 reduced 80
vrrp vrid 4 track interface g0/0/11 reduced 80
int vlanif50
vrrp vrid 5 virtual-ip 172.16.5.253
vrrp vrid 5 priority 150
vrrp vrid 5 preempt-mode timer delay 5
vrrp vrid 5 track interface g0/0/8 reduced 80
vrrp vrid 5 track interface g0/0/11 reduced 80
int vlanif60
vrrp vrid 6 virtual-ip 172.16.6.253
vrrp vrid 6 priority 150
vrrp vrid 6 preempt-mode timer delay 5
vrrp vrid 6 track interface g0/0/8 reduced 80
vrrp vrid 6 track interface g0/0/11 reduced 80
int vlanif70
vrrp vrid 7 virtual-ip 172.16.7.253
vrrp vrid 7 priority 150
vrrp vrid 7 preempt-mode timer delay 5
vrrp vrid 7 track interface g0/0/8 reduced 80
vrrp vrid 7 track interface g0/0/11 reduced 80
quit
ospf router-id 1.1.1.1
area 0
network 172.16.11.0 0.0.0.255
quit
ospf router-id 3.3.3.3
area 2
network 172.16.1.0 0.0.0.255
network 172.16.2.0 0.0.0.255
network 172.16.3.0 0.0.0.255
network 172.16.4.0 0.0.0.255
network 172.16.5.0 0.0.0.255
network 172.16.6.0 0.0.0.255
network 172.16.7.0 0.0.0.255
ospf router-id 4.4.4.4
area 3
network 172.16.9.0 0.0.0.255
1.4.防火墙配置:
FW:
u t m
sys
sysname firewall
int g0/0/1
ip add 172.16.10.1 24
int g0/0/2
ip add 172.16.11.1 24
int g0/0/3
ip add 202.101.224.100 24
int g0/0/4
ip add 182.84.89.100 24
quit
firewall zone trust
add interface GigabitEthernet0/0/1
add interface GigabitEthernet0/0/2
quit
firewall zone untrust
add interface GigabitEthernet0/0/3
add interface GigabitEthernet0/0/4
quit
ospf 1.1.1.1
area 0
network 172.16.10.0 0.0.0.255
network 172.16.11.0 0.0.0.255
quit
ip route-static 172.16.0.0 16 172.16.10.2
ip route-static 172.16.0.0 16 172.16.11.2
ip route-static 0.0.0.0 0.0.0.0 202.101.224.68
ip route-static 0.0.0.0 0.0.0.0 182.84.89.171
nat address-group 1 202.101.224.101 202.101.224.105
nat address-group 2 182.84.89.101 182.84.89.105
nat-policy interzone trust untrust outbound
policy 1
action source-nat
policy source 172.16.1.0 0.0.0.255
policy source 172.16.2.0 0.0.0.255
policy source 172.16.3.0 0.0.0.255
policy source 172.16.4.0 0.0.0.255
policy source 172.16.5.0 0.0.0.255
address-group 1
quit
policy 1 enable
quit
policy interzone trust untrust outbound
policy 1
action permit
policy source 172.16.1.0 0.0.0.255
policy source 172.16.2.0 0.0.0.255
policy source 172.16.3.0 0.0.0.255
policy source 172.16.4.0 0.0.0.255
policy source 172.16.5.0 0.0.0.255
policy destination any
quit
policy 1 enable
quit
nat-policy interzone trust untrust outbound
policy 2
action source-nat
policy source 172.16.6.0 0.0.0.255
policy source 172.16.7.0 0.0.0.255
policy source 172.16.8.0 0.0.0.255
policy source 172.16.9.0 0.0.0.255
address-group 2
quit
policy 2 enable
quit
policy interzone trust untrust outbound
policy 2
action permit
policy source 172.16.6.0 0.0.0.255
policy source 172.16.7.0 0.0.0.255
policy source 172.16.8.0 0.0.0.255
policy source 172.16.9.0 0.0.0.255
policy destination any
quit
policy 2 enable
quit
policy interzone trust untrust inbound
policy 2
action permit
policy destination 172.16.8.0 0.0.0.255
policy destination 172.16.9.0 0.0.0.255
quit
policy 1 enable
quit
nat server 1 protocol tcp global 202.101.224.68 ftp inside 172.16.8.2 ftp
nat server 2 protocol tcp global 182.84.89.100 www inside 172.16.9.2 www
1.5.电信联通:
R2:
u t m
sys
sys dianxin
int g0/0/1
ip add 202.101.224.68 24
R3:
u t m
sys
sys liantong
int g0/0/1
ip add 182.84.89.171 24

应用服务的功能配置
一、CentOS 6.5下的dhcp服务:
1、安装CentOS6.5:
修改网卡地址为静态
#vi /etc/sysconfig/network-scripts/ifcfg-eth0
ONBOOT=yes
IPADDR=192.168.177.177
PREFIX=16
GATEWAY=192.168.198.2
BOOTPROTO=static
DNS1=202.101.224.68
#service network restart
#service iptables stop
#sed -I ‘SELINUX=enforcing/SELINUX=disabled/g’ /etc/selinux/config
1、查询并安装DHCP服务

rpm -qa | grep dhcp

#yum -y install dhcp*
2、修改DHCP的配置文件
#cp -p /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf
cp:overwrit’/etc/dhcp/dhcp.conf’? y
#vi /etc/dhcp/dhcpd.conf //在命令模式下,按下G 到最后一行,添加:

subnet 172.16.1.0 netmask 255.255.255.0 {
range 172.16.1.1 172.16.1.253;
option domain-name-servers 202.101.224.68;
option domain-name “zhanshenwangka.com”;
option routers 172.16.1.254;
option broadcast-address 172.16.1.255;
default-lease-time 600;
max-lease-time 7200;
}
subnet 172.16.2.0 netmask 255.255.255.0 {
range 172.16.2.1 172.16.2.253;
option domain-name-servers 202.101.224.68;
option domain-name “zhanshenwangka.com”;
option routers 172.16.2.254;
option broadcast-address 172.16.2.255;
default-lease-time 600;
max-lease-time 7200;
}
subnet 172.16.3.0 netmask 255.255.255.0 {
range 172.16.3.1 172.16.3.253;
option domain-name-servers 202.101.224.68;
option domain-name “zhanshenwangka.com”;
option routers 172.16.3.254;
option broadcast-address 172.16.3.255;
default-lease-time 600;
max-lease-time 7200;
}
subnet 172.16.4.0 netmask 255.255.255.0 {
range 172.16.4.1 172.16.4.253;
option domain-name-servers 202.101.224.68;
option domain-name “zhanshenwangka.com”;
option routers 172.16.4.254;
option broadcast-address 172.16.4.255;
default-lease-time 600;
max-lease-time 7200;
}
subnet 172.16.5.0 netmask 255.255.255.0 {
range 172.16.5.1 172.16.5.253;
option domain-name-servers 202.101.224.68;
option domain-name “zhanshenwangka.com”;
option routers 172.16.5.254;
option broadcast-address 172.16.5.255;
default-lease-time 600;
max-lease-time 7200;
}
3、启动DHCP服务,查询相关进程和端口
修改完配置文件后,需要重启DHCP服务
#service dhcpd restart //重启DHCP的服务
#chkconfig --level 35 dhcpd on //配置在相关的运行级别上启动DHCP
#ps -aux | grep dhcpd //查询DHCP进程
#netstat -aultp | grep dhcpd //查询DHCP服务端口号 服务器端 67
#pgrep dhcpd //客户端 68
4、DHCP客户端验证
设置DHCP主机网络连接模式为VMnet1,再用一台主机设置网络连接模式为VMnet1,编辑网卡配置
#vi /etc/sysconfig/network-scripts/ifcfg-eth0
ONBOOT=yes
BOOTPROTO=dhcp
其他的不用加,然后
#ifconfig -a
就能看到获取到的IP了。
在windows主机的网卡上设置,自动获取IP和自动获取DNS
或者 c:>ipconfig /release
ipconfig /renew
服务器端查询地址租约数据库
#cat /var/lib/dhcpd/dhcpd.leases
#tail -n 10 /var/lib/dhcp/dhcpd.leases
二、流媒体服务安装
yum -y install gcc gcc-c++ glibc glibc-devel make nasm pkgconfig lib-devel openssl-devel expat-devel gettext-devel libtool mhash.x86_64 perl-Digest-SHA1.x86_64 git wget autoconf automake
#cd /usr/local/src
用wget 添加下面的网址
下载nginx http://nginx.org/download/nginx-1.6.2.tar.gz下载pcre (支持nginx伪静态)
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.36.tar.gz
下载openssl(nginx扩展) http://www.openssl.org/source/openssl-1.0.1j.tar.gz
下载zlib(nginx扩展) http://zlib.net/zlib-1.2.8.tar.gz
#git clone https://github.com/arut/nginx-rtmp-module.git 我是直接用下载好的镜像包安装的
1、安装pcre

cd /usr/local/src

mkdir /usr/local/pcre

mkdir /usr/local/pcre

tar zxvf pcre-8.36.tar.gz

cd pcre-8.36

#./configure --prefix=/usr/local/pcre && make && make install
2、安装openssl
#cd /usr/local/src
#mkdir /usr/local/openssl
#tar zxvf openssl-1.0.1j.tar.gz
#cd openssl-1.0.1j
#./config --prefix=/usr/local/openssl && make && make install
#vi /etc/profile
#export PATH=$PATH:/usr/local/openssl/bin
#source /etc/profile
2、安装zlib
#cd /usr/local/src
#mkdir /usr/local/zlib
#tar zxvf zlib-1.2.8.tar.gz
#cd zlib-1.2.8
#./configure --prefix=/usr/local/zlib && make && make install
4、安装nginx
#cd /usr/local/src
#tar zxvf nginx-1.6.2.tar.gz
#cd nginx-1.6.2
#./configure --prefix=/usr/local/nginx --without-http_memcached_module --user=www --group=www --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-openssl=/usr/local/src/openssl-1.0.1j --with-zlib=/usr/local/src/zlib-1.2.8 --with-pcre=/usr/local/src/pcre-8.36 --add-module=/usr/local/src/nginx-rtmp-module
注意:–with-openssl=/usr/local/src/openssl-1.0.1j --with-zlib=/usr/local/src/zlib-1.2.8 --with-pcre=/usr/local/src/pcre-8.36指向的是源码包解压的路径,而不是安装的路径,否则报错
#make && make install
#/usr/local/nginx/sbin/nginx //启动Nginx
设置nginx开机启动
#vi /etc/rc.d/init.d/nginx //编辑启动文件添加下面内容
#!/bin/sh

#nginx - this script starts and stops the nginx daemon

#chkconfig: - 85 15
#description: Nginx is an HTTP(S) server, HTTP(S) reverse \
#proxy and IMAP/POP3 proxy server
#processname: nginx
#config: /etc/nginx/nginx.conf
#config: /usr/local/nginx/conf/nginx.conf
#pidfile: /usr/local/nginx/logs/nginx.pid
#Source function library.
. /etc/rc.d/init.d/functions
#Source networking configuration.
. /etc/sysconfig/network
#Check that networking is up.
[ “KaTeX parse error: Expected 'EOF', got '&' at position 22: …KING" = "no" ] &̲& exit 0 nginx…(basename KaTeX parse error: Expected 'EOF', got '&' at position 88: …config/nginx ] &̲& . /etc/syscon…nginx -V 2>&1 | grep “configure arguments:” | sed ‘s/[*]*–user=([ ])./\1/g’ -if [ -z "grep $user /etc/passwd" ]; then useradd -M -s /bin/nologin $user fi options=$nginx -V 2>&1 | grep 'configure arguments:'for opt in $options; do if [echo $opt | grep '.*-temp-path’]; then value=echo o p t ∣ c u t − d " = " − f 2 ‘ i f [ ! − d " opt | cut -d "=" -f 2` if [ ! -d " optcutd"="f2if[!d"value” ]; then
#echo “creating” $value
mkdir -p $value && chown -R $user $value
fi
fi
done
}
start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
make_dirs
echo -n $"Starting $prog: "
daemon $nginx -c N G I N X C O N F F I L E r e t v a l = NGINX_CONF_FILE retval= NGINXCONFFILEretval=?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc p r o g − Q U I T r e t v a l = prog -QUIT retval= progQUITretval=?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
#configtest || return $?
stop
sleep 1
start
}
reload() {
#configtest || return $?
echo -n $"Reloading $prog: "
killproc n g i n x − H U P R E T V A L = nginx -HUP RETVAL= nginxHUPRETVAL=?
echo
}
force_reload() {
restart
}
configtest() {
$nginx -t -c $NGINX_CONF_FILE
}
rh_status() {
status $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case “$1” in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart|configtest)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
;;
*)
echo $“Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}”
exit 2
esac
#chmod 775 /etc/rc.d/init.d/nginx //赋予文件执行权限
#chkconfig nginx on //设置开机启动
#/etc/rc.d/init.d/nginx restart //重启
#vi /usr/local/nginx/conf/nginx.conf
在浏览器中打开服务器IP地址:192.168.177.177,可以看到下面的结果。
网咖网络规划与安装流媒体服务器_第2张图片

编辑原有的nginx.conf中加入如下配置:
#vi /usr/local/nginx/conf/nginx.conf
rtmp {
server {
listen 192.168.177.177:1935;
chunk_size 4000;
#HLS
# For HLS to work please create a directory in tmpfs (/tmp/app here)
# for the fragments. The directory contents is served via HTTP (see
# http{} section in config)
#
# Incoming stream must be in H264/AAC. For iPhones use baseline H264
# profile (see ffmpeg example).
# This example creates RTMP stream from movie ready for HLS:
#
# ffmpeg -loglevel verbose -re -i movie.avi -vcodec libx264
# -vprofile baseline -acodec libmp3lame -ar 44100 -ac 1
# -f flv rtmp://localhost:1935/hls/movie
#
# If you need to transcode live stream use ‘exec’ feature.
#
application hls {
live on;
hls on;
hls_path /usr/local/nginx/html/hls;
hls_fragment 5s;
}
}
}
http {
server {
listen 8080;
location /hls {
# Serve HLS fragments
types {
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
root html;
expires -1;
}
}
}

其中rtmp部分与原有的http部分在同一个级别,但是下面的http部分要放到已有的http部分中,也就是增加一个server部分。
然后运行如下命令检查nginx.conf是否有语法错误
service nginx configtest
重新加载配置文件
service nginx reload
运行下面的命令查看nginx状态
service nginx status
注意,这里reload并不能开启这几个服务,需要使用
service nginx restart
将rtmp服务和hls服务的端口1935和8080都打开
然后查看端口
netstat -nlp
一定要关闭防火墙,不然obs连不上
5.下载一个obs程序用于推流,或者在安装的时候添加安装FFmpeg用于推流
方法:在设置-串流里填上:rtmp://192.168.177.177:1935/hls,密钥就填你要推送的文件或电影名,我填的是:movie,然后就在浏览器里输入:http://192.168.177.177:8080/hls/movie.m3u8 ,就能看到推送的东西了。

网咖网络规划与安装流媒体服务器_第3张图片

你可能感兴趣的:(课设,网吧设计)