wvp-gb28181-pro搭建流媒体服务器,内存占用过高问题

直接给出解决办法,端口暴露的太多了,暴露了500个端口导致从3g---->11g

遇到的问题,直接使用镜像《648540858/wvp_pro:latest》在宿主机上运行,如我下面的博客

https://blog.csdn.net/weixin_41012767/article/details/137112338?spm=1001.2014.3001.5502

docker run  --env WVP_IP="自己电脑的ip" -it -p 18080:18080 -p 30000-30500:30000-30500/udp -p 30000-30500:30000-30500/tcp -p 80:80 -p 5060:5060 -p 5060:5060/udp 648540858/wvp_pro

 可以看暴露了1000个端口

为了解决内存过高的问题加了以下解决办法

1.限制java的运行的堆栈 

-Xms128m -Xmx256m

2.增加了docker的内存限制

方案一:
version: '3.7'
services:
  zxcloudserver:
    image: 648540858/wvp_pro
    privileged: true
    logging:
      driver: "json-file"
      options:
        max-size: "10m"
        max-file: "3"
    restart: always
    container_name: xxxx
    deploy:
      resources:
        limits:
          memory: 5g
方案二:
version: 'xxx'
services:
  zxcloudserver:
    image: 648540858/wvp_pro
    privileged: true
    logging:
      driver: "json-file"
      options:
        max-size: "10m"
        max-file: "3"
    restart: always
    container_name: xxxx
    mem_limit: 5g

 限制截图

 实际上限制是起来作用,但是宿主机内存还是很高,最后尝试改端口发现了,端口开多了内存占用非常高

------------------------------------分割线----------------------------------------------------------------------------------

以下是我使用的wvp记录跟上面没关系

1.将docker内部的这三个文件拷贝出来

root@4d1dfa5b7c08:/opt# tree -L 2
.
├── assist #这个是wvp-GB28181-pro的辅助录像程序,它提供了录像控制和录像合并下载接口。它可以与ZLMediaKit一起使用,为WVP-PRO提供国标28181的媒体部分的实现,并支持各种视频流格式的分发
│   ├── config
│   ├── logs
│   ├── nohup.out
│   └── wvp-pro-assist-1.0.0-20211119095941.jar
├── media #这个是ZLMediaKit
│   ├── api_tester_h264_media_server
│   ├── api_tester_pusher
│   ├── api_tester_server
│   ├── api_tester_websocket
│   ├── bom
│   ├── config.ini #重点 ZLMediaKit的配置文件
│   ├── default.pem
│   ├── ffmpeg
│   ├── libflv.a
│   ├── libjsoncpp.a
│   ├── libmk_api.so
│   ├── libmov.a
│   ├── libmpeg.a
│   ├── libzlmediakit.a
│   ├── libzltoolkit.a
│   ├── log
│   ├── MediaServer
│   ├── tab
│   ├── test_bench_proxy
│   ├── test_bench_pull
│   ├── test_bench_push
│   ├── test_httpApi
│   ├── test_httpClient
│   ├── test_pusher
│   ├── test_pusherMp4
│   ├── test_rtcp
│   ├── test_rtp
│   ├── test_server
│   ├── test_sortor
│   ├── test_wsClient
│   ├── test_wsServer
│   └── www
└── wvp
    ├── config #wvp的配置文件里面是application.yml
    ├── logs
    ├── run.sh #重点 wvp的镜像的运行脚本
    ├── static #wvp的前端
    └── wvp-pro-2.0-11190958.jar

11 directories, 33 files

软件的脚本如下,不需要辅助录像,可以注释掉内置的redis,和assist

#!/bin/bash
echo "----REDIS_HOST--------"+${REDIS_HOST}

echo  "------WVP_IP-----"${WVP_IP}
echo  "------WVP_CONFIG----1-----"${WVP_CONFIG}
#redis-server --daemonize yes --bind 0.0.0.0
cd /opt/assist
nohup java ${ASSIST_JVM_CONFIG} -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/opt/assist/heapdump/ -jar *.jar --userSettings.record=/opt/media/www/record/  &
nohup /opt/media/MediaServer -d -m 3 &

cd /opt/wvp
echo  "------WVP_CONFIG----2-----"+${WVP_CONFIG}
if [${WVP_CONFIG}]; then
          java  ${WVP_JVM_CONFIG} -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/opt/wvp/heapdump/ -jar *.jar --spring.config.location=/opt/wvp/config/application.yml --media.record-assist-port=18081 ${WVP_CONFIG}
else
          java  ${WVP_JVM_CONFIG} -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/opt/wvp/heapdump/ -jar *.jar --spring.config.location=/opt/wvp/config/application.yml --media.record-assist-port=18081 --media.ip=127.0.0.1 --media.hook-ip=127.0.0.1 --media.sdp-ip=${WVP_IP} --sip.ip=${WVP_IP} --media.stream-ip=${WVP_IP}
 fi

 wvp的application.yml的内容如下

spring:
    # REDIS数据库配置
    redis:
        # [必须修改] Redis服务器IP, REDIS安装在本机的,使用127.0.0.1
        host: ${REDIS_HOST}
        # [必须修改] 端口号
        port: ${REDIS_PORT}
        # [可选] 数据库 DB
        database: ${REDIS_DATABASE}
        # [可选] 访问密码,若你的redis服务器没有设置密码,就不需要用密码去连接
        password: ${REDIS_PASSWORD}
        # [可选] 超时时间
        timeout: 10000
    # [可选] jdbc数据库配置, 项目使用sqlite作为数据库,一般不需要配置
    datasource:
        # 使用mysql 打开23-28行注释, 删除29-36行
        # name: wvp
        # url: jdbc:mysql://127.0.0.1:3306/wvp?useUnicode=true&characterEncoding=UTF8&rewriteBatchedStatements=true
        # username:
        # password:
        # type: com.alibaba.druid.pool.DruidDataSource
        # driver-class-name: com.mysql.cj.jdbc.Driver
        name: eiot
        url: jdbc:sqlite::resource:wvp.sqlite
        username:
        password:
        type: com.alibaba.druid.pool.DruidDataSource
        driver-class-name:  org.sqlite.JDBC
        max-active: 1
        min-idle: 1

# [可选] WVP监听的HTTP端口, 网页和接口调用都是这个端口
server:
    port: 18080

# 作为28181服务器的配置
sip:
    # [必须修改] 本机的IP
    ip: ${WVP_HOST}
    # [可选] 28181服务监听的端口
    port: 5060
    # 根据国标6.1.2中规定,domain宜采用ID统一编码的前十位编码。国标附录D中定义前8位为中心编码(由省级、市级、区级、基层编号组成,参照GB/T 2260-2007)
    # 后两位为行业编码,定义参照附录D.3
    # 3701020049标识山东济南历下区 信息行业接入
    # [可选]
    domain: ${WVP_DOMAIN:4401020049}
    # [可选]
    id: ${WVP_ID:44010200492000000001}
    # [可选] 默认设备认证密码,后续扩展使用设备单独密码, 移除密码将不进行校验
    password: ${WVP_PWD:admin123}

#zlm 默认服务器配置
media:
    # [必须修改] zlm服务器的内网IP
    ip: 127.0.0.1
    # [必须修改] zlm服务器的http.port
    http-port: 8088
    # [可选] zlm服务器的hook.admin_params=secret
    secret: 035c73f7-bb6b-4889-a715-d9eb2d1925cc
    # 启用多端口模式, 多端口模式使用端口区分每路流,兼容性更好。 单端口使用流的ssrc区分, 点播超时建议使用多端口测试
    rtp:
        # [可选] 是否启用多端口模式, 开启后会在portRange范围内选择端口用于媒体流传输
        enable: true
        # [可选] 在此范围内选择端口用于媒体流传输,
        port-range: 30000,3005 # 端口范围
        # [可选] 国标级联在此范围内选择端口发送媒体流,
        send-port-range: 30000,30005 # 端口范围
    # 录像辅助服务, 部署此服务可以实现zlm录像的管理与下载, 0 表示不使用
    record-assist-port: 18081
    sdp-ip: ${WVP_HOST}
    stream-ip: ${WVP_HOST}
# [可选] 日志配置, 一般不需要改
logging:
    file:
        name: logs/wvp.log
        max-history: 30
        max-size: 10MB
        total-size-cap: 30MB
    level:
        com.genersoft.iot: debug
        com.genersoft.iot.vmp.storager.dao: info
        com.genersoft.iot.vmp.gb28181: info

# [根据业务需求配置]
user-settings:
    # 推流直播是否录制
    record-push-live: false
    auto-apply-play: false

# 在线文档: swagger-ui(生产环境建议关闭)
swagger-ui:
    enabled: true

# 版本信息, 不需修改
version:
    version: "@project.version@"
    description: "@project.description@"
    artifact-id: "@project.artifactId@"

assist的配置如下

spring:
    # REDIS数据库配置
    redis:
        # [必须修改] Redis服务器IP, REDIS安装在本机的,使用127.0.0.1
        host: ${REDIS_HOST:127.0.0.1}
        # [必须修改] 端口号
        port: ${REDIS_PORT:6379}
        # [可选] 数据库 DB
        database: 0
        # [可选] 访问密码,若你的redis服务器没有设置密码,就不需要用密码去连接
        password: ${REDIS_PASSWORD:}
        # [可选] 超时时间
        timeout: 10000

# [可选] WVP监听的HTTP端口, 网页和接口调用都是这个端口
server:
    port: 18081
    # [可选] HTTPS配置, 默认不开启
    ssl:
        # [可选] 是否开启HTTPS访问
        enabled: false
        # [可选] 证书文件路径,放置在resource/目录下即可,修改xxx为文件名
        key-store: classpath:xxx.jks
        # [可选] 证书密码
        key-password: password
        # [可选] 证书类型, 默认为jks,根据实际修改
        key-store-type: JKS

# [根据业务需求配置]
userSettings:
    # [必选 ] zlm配置的录像路径
    record: /media/lin/Server/ZLMediaKit/dev/ZLMediaKit/release/linux/Debug/www/record
    # [可选 ] 录像保存时长(单位: 天)每天晚12点自动对过期文件执行清理
    recordDay: 7
    # [必选 ] ffmpeg路径
    ffmpeg: /usr/bin/ffmpeg
    # [必选 ] ffprobe路径, 一般安装ffmpeg就会自带, 一般跟ffmpeg在同一目录,用于查询文件的信息
    ffprobe: /usr/bin/ffprobe


# [可选] 日志配置, 一般不需要改
logging:
    file:
        name: logs/wvp.log
        max-history: 30
        max-size: 10MB
        total-size-cap: 300MB
    level:
        root: WARN
        top:
            panll:
                assist: info

 config.ini的配置如下:

; auto-generated by mINI class {

[api]
apiDebug=0
defaultSnap=./www/logo.png
secret=035c73f7-bb6b-4889-a715-d9eb2d1925cc
snapRoot=./www/snap/

[ffmpeg]
bin=/usr/bin/ffmpeg
cmd=%s -fflags nobuffer -i %s -c:a aac -strict -2 -ar 44100 -ab 48k -c:v libx264  -f flv %s
log=./ffmpeg/ffmpeg.log
snap=%s -i %s -y -f mjpeg -t 0.001 %s

[general]
addMuteAudio=1
enableVhost=0
enable_audio=0
flowThreshold=1024
fmp4_demand=0
hls_demand=0
maxStreamWaitMS=15000
mediaServerId=KyYeBTLafedkuipC
mergeWriteMS=0
modifyStamp=0
publishToHls=0
publishToMP4=0
resetWhenRePlay=1
rtmp_demand=0
rtsp_demand=0
streamNoneReaderDelayMS=18000
ts_demand=0

[hls]
broadcastRecordTs=0
deleteDelaySec=0
fileBufSize=65536
filePath=./www
segDur=2
segNum=3
segRetain=5

[hook]
admin_params=secret=035c73f7-bb6b-4889-a715-d9eb2d1925cc
alive_interval=30.000000
enable=1
on_flow_report=
on_http_access=
on_play=http://127.0.0.1:18080/index/hook/on_play
on_publish=http://127.0.0.1:18080/index/hook/on_publish
on_record_mp4=http://127.0.0.1:18081/api/record/on_record_mp4
on_record_ts=
on_rtsp_auth=
on_rtsp_realm=
on_server_keepalive=
on_server_started=http://127.0.0.1:18080/index/hook/on_server_started
on_shell_login=http://127.0.0.1:18080/index/hook/on_shell_login
on_stream_changed=http://127.0.0.1:18080/index/hook/on_stream_changed
on_stream_none_reader=http://127.0.0.1:18080/index/hook/on_stream_none_reader
on_stream_not_found=http://127.0.0.1:18080/index/hook/on_stream_not_found
timeoutSec=20

[http]
charSet=utf-8
dirMenu=1
keepAliveSecond=15
maxReqSize=40960
notFound=<html><head><title>404 Not Found</title></head><body bgcolor="white"><center><h1>您访问的资源不存在!</h1></center><hr><center>ZLMediaKit(git hash:1cba3f4,branch:master,build time:Nov 19 2021 18:00:38)</center></body></html>
port=8088
rootPath=./www
sendBufSize=65536
sslport=443
virtualPath=

[multicast]
addrMax=239.255.255.255
addrMin=239.0.0.0
udpTTL=64

[record]
appName=record
fastStart=0
fileBufSize=65536
filePath=./www
fileRepeat=0
fileSecond=3600
sampleMS=500

[rtmp]
handshakeSecond=15
keepAliveSecond=15
modifyStamp=0
port=1935
sslport=19350

[rtp]
audioMtuSize=600
rtpMaxSize=10
videoMtuSize=1400

[rtp_proxy]
dumpDir=
port=10000
timeoutSec=15

[rtsp]
authBasic=0
directProxy=1
handshakeSecond=15
keepAliveSecond=15
port=554
sslport=332

[shell]
maxReqSize=1024
port=9000

; } ---

  • 3
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Y_Hungry

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值