使用Docker部署WVP国标视频平台
一、准备工作
准备一台物理机或者虚拟机安装CentOS 7 Minimal
系统
推荐内存不小于4G,硬盘最好是两块,32G以上系统盘,1T以上录像盘(建立独立分区专门用来存储录像)
以ESXi创建的虚拟机为例
安装正常流程安装CentOS操作系统,安装完毕后,给1T硬盘创建分区,并单独挂载到/opt目录(如果只有一块硬盘则忽略此操作)
使用parted
命令创建分区,过程如下
先查看硬盘盘符
[root@localhost ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 32G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 31G 0 part
└─centos-root 253:0 0 31G 0 lvm /
sdb 8:16 0 1T 0 disk
sr0 11:0 1 1024M 0 rom
可以看到空硬盘的盘符为sdb,接下来使用parted对该硬盘建立一个类型为xfs的分区
[root@localhost ~]# parted /dev/sdb
GNU Parted 3.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel gpt #指定分区类型为GPT
(parted) mkpart #建立新分区
Partition name? []? video #指定分区名称为video
File system type? [ext2]? xfs #指定文件系统为xfs
Start? 0% #从0%开始
End? 100% #到100%结束,意思是使用整个硬盘
(parted) quit #退出
Information: You may need to update /etc/fstab.
再次执行lsblk,可以看到分区已经创建好
[root@localhost ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 32G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 31G 0 part
└─centos-root 253:0 0 31G 0 lvm /
sdb 8:16 0 1T 0 disk
└─sdb1 8:17 0 1024G 0 part
sr0 11:0 1 1024M 0 rom
用xfs文件系统格式化sdb1分区并挂载到/opt目录(需要先保证opt是一个空目录)
[root@localhost ~]# mkfs.xfs /dev/sdb1
Discarding blocks...Done.
meta-data=/dev/sdb1 isize=512 agcount=4, agsize=67108736 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=268434944, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=131071, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
查看sdb1分区的UUID
[root@localhost ~]# blkid /dev/sdb1
/dev/sdb1: UUID="6bd502df-0bec-4615-869b-7d2b8a7cc3c1" TYPE="xfs" PARTLABEL="video" PARTUUID="5404b60a-6a99-4b13-a66d-be8c1959a8d7"
将sdb1分区挂载到opt目录,并使用df -h命令验证
[root@localhost ~]# mount UUID="6bd502df-0bec-4615-869b-7d2b8a7cc3c1" /opt
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs 1.9G 9.1M 1.9G 1% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/mapper/centos-root 31G 1.3G 30G 4% /
/dev/sda1 1014M 150M 865M 15% /boot
tmpfs 379M 0 379M 0% /run/user/0
/dev/sdb1 1.0T 33M 1.0T 1% /opt
编辑/etc/fstab
文件,追加以下内容,开机自动挂载
UUID=6bd502df-0bec-4615-869b-7d2b8a7cc3c1 /opt xfs defaults 0 0
关闭防火墙
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@localhost ~]# systemctl mask firewalld
Created symlink from /etc/systemd/system/firewalld.service to /dev/null.
关闭selinux
[root@localhost ~]# setenforce 0
[root@localhost ~]# getenforce
Permissive
永久关闭selinux,修改/etc/selinux/config
文件,将selinux修改成disabled
二、配置DVD镜像源及docker-ce源
说明:如果满足下面两个条件其一,则可以跳过步骤二和步骤三
1、网络条件允许,使用下面的命令直接安装Docker
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
2、使用宝塔面板、1Panel、云服务器自带或者其他方式已经安装好Docker的
否则继续往下看
以清华大学镜像站为例
配置DVD镜像源
sed -e "s|^mirrorlist=|#mirrorlist=|g" \
-e "s|^#baseurl=http://mirror.centos.org/centos/\$releasever|baseurl=https://mirrors4.tuna.tsinghua.edu.cn/centos-vault/7.9.2009|g" \
-e "s|^#baseurl=http://mirror.centos.org/\$contentdir/\$releasever|baseurl=https://mirrors4.tuna.tsinghua.edu.cn/centos-vault/7.9.2009|g" \
-i.bak \
/etc/yum.repos.d/CentOS-*.repo
配置docker-ce源
vi /etc/yum.repos.d/docker-ce.repo
写入以下内容
[docker-ce-stable]
name=Docker CE Stable - $basearch
baseurl=https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/$releasever/$basearch/stable
enabled=1
gpgcheck=1
gpgkey=https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/gpg
[docker-ce-stable-debuginfo]
name=Docker CE Stable - Debuginfo $basearch
baseurl=https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/$releasever/debug-$basearch/stable
enabled=0
gpgcheck=1
gpgkey=https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/gpg
[docker-ce-stable-source]
name=Docker CE Stable - Sources
baseurl=https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/$releasever/source/stable
enabled=0
gpgcheck=1
gpgkey=https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/gpg
[docker-ce-test]
name=Docker CE Test - $basearch
baseurl=https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/$releasever/$basearch/test
enabled=0
gpgcheck=1
gpgkey=https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/gpg
[docker-ce-test-debuginfo]
name=Docker CE Test - Debuginfo $basearch
baseurl=https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/$releasever/debug-$basearch/test
enabled=0
gpgcheck=1
gpgkey=https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/gpg
[docker-ce-test-source]
name=Docker CE Test - Sources
baseurl=https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/$releasever/source/test
enabled=0
gpgcheck=1
gpgkey=https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/gpg
[docker-ce-nightly]
name=Docker CE Nightly - $basearch
baseurl=https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/$releasever/$basearch/nightly
enabled=0
gpgcheck=1
gpgkey=https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/gpg
[docker-ce-nightly-debuginfo]
name=Docker CE Nightly - Debuginfo $basearch
baseurl=https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/$releasever/debug-$basearch/nightly
enabled=0
gpgcheck=1
gpgkey=https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/gpg
[docker-ce-nightly-source]
name=Docker CE Nightly - Sources
baseurl=https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/$releasever/source/nightly
enabled=0
gpgcheck=1
gpgkey=https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/gpg
重建yum缓存
yum clean all && yum makecache
更新软件包
yum update
yum upgrade
三、安装依赖和Docker
安装Docker依赖
yum install -y yum-utils device-mapper-persistent-data lvm2
安装docker软件包
yum install -y docker-ce docker-ce-cli containerd.io
启动docker并配置开机自启动,查看运行状态
[root@localhost ~]# systemctl start docker && systemctl enable docker && systemctl status docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
Active: active (running) since Sun 2024-07-21 21:11:32 CST; 134ms ago
Docs: https://docs.docker.com
Main PID: 9270 (dockerd)
CGroup: /system.slice/docker.service
└─9270 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
Jul 21 21:11:30 localhost.localdomain systemd[1]: Starting Docker Application Container Engine...
Jul 21 21:11:30 localhost.localdomain dockerd[9270]: time="2024-07-21T21:11:30.204790073+08:00" level=info msg="Starting up"
Jul 21 21:11:31 localhost.localdomain dockerd[9270]: time="2024-07-21T21:11:31.622722131+08:00" level=info msg="Loading c...art."
Jul 21 21:11:32 localhost.localdomain dockerd[9270]: time="2024-07-21T21:11:32.055188977+08:00" level=info msg="Loading c...one."
Jul 21 21:11:32 localhost.localdomain dockerd[9270]: time="2024-07-21T21:11:32.077519319+08:00" level=info msg="Docker da...6.1.4
Jul 21 21:11:32 localhost.localdomain dockerd[9270]: time="2024-07-21T21:11:32.077696173+08:00" level=info msg="Daemon ha...tion"
Jul 21 21:11:32 localhost.localdomain dockerd[9270]: time="2024-07-21T21:11:32.130173081+08:00" level=info msg="API liste...sock"
Jul 21 21:11:32 localhost.localdomain systemd[1]: Started Docker Application Container Engine.
Hint: Some lines were ellipsized, use -l to show in full.
四、导入wvp_pro镜像
说明:如果网络条件允许,也可以通过下面的命令直接拉取镜像
docker pull 648540858/wvp_pro
否则联系作者获取镜像导出的tar包,使用下面命令导入
[root@localhost ~]# docker load -i wvp_pro.tar && docker images
9f54eef41275: Loading layer [==================================================>] 75.16MB/75.16MB
ecc4a82ef3c9: Loading layer [==================================================>] 615.3MB/615.3MB
2b3b1e3d55de: Loading layer [==================================================>] 2.048kB/2.048kB
f605eab3b521: Loading layer [==================================================>] 197.6MB/197.6MB
Loaded image: 648540858/wvp_pro:latest
REPOSITORY TAG IMAGE ID CREATED SIZE
648540858/wvp_pro latest 5d1686b1730f 2 years ago 880MB
五、运行容器
将IP地址修改成服务器网卡的IP
docker run -itd \
--name wvp_pro \
--hostname wvp_pro \
-v /opt/wvp/record:/opt/media/www/record \
-v /opt/wvp/logs/wvp:/opt/wvp/logs \
-v /opt/wvp/logs/media:/opt/media/log \
-v /opt/wvp/logs/assist:/opt/assist/logs \
--env WVP_IP="172.16.1.201" \
--network host \
--restart=always 648540858/wvp_pro
容器默认配置信息
SIP服务器端口:5060
SIP服务器国标编码:44010200492000000001
六、修改节点名称和国标配置(可选)
进入到容器
docker exec -it wvp_pro /bin/bash
下载vim
apt-get update && apt install -y vim
修改media配置文件,将其中的ID修改成自己喜欢的
vim /opt/media/config.ini
修改SIP配置
vim /opt/wvp/config/application.yml
退出容器并重启
root@wvp_pro:/opt/wvp# exit
exit
[root@localhost ~]# docker restart wvp_pro
wvp_pro
如果不想进容器或者因为网络原因vim软件包下载很慢,也可以用docker cp
命令将配置文件导出到宿主机,修改完成后导入容器,再重启容器
从容器拷贝配置文件出来
[root@localhost ~]# docker cp wvp_pro:/opt/media/config.ini .
Successfully copied 4.1kB to /root/.
[root@localhost ~]# docker cp wvp_pro:/opt/wvp/config/application.yml .
Successfully copied 5.63kB to /root/.
修改完成后拷回容器并覆盖
[root@localhost ~]# docker cp application.yml wvp_pro:/opt/wvp/config
Successfully copied 5.63kB to wvp_pro:/opt/wvp/config
[root@localhost ~]# docker cp config.ini wvp_pro:/opt/media
Successfully copied 4.1kB to wvp_pro:/opt/media
最后再重启容器
[root@localhost ~]# docker restart wvp_pro
wvp_pro
七、登录验证
登录方式为http://IP:18080
用户名和密码都为admin
,如果修改过节点名称,则在节点管理里面会多出一个离线的节点,直接删除就好
八、相机国标注册测试
找一个支持GB28181
功能的摄像头
这里以大华摄像头(推荐)为例,进入网络设置,平台接入,完成信息填写后打开GB28181功能,则可以看到已成功注册
WVP上也可以看到设备注册上线,且测试实时预览和云台控制正常
九、wvp_pro端口说明
共有 0 条评论