[运维] wvp 28181安装部署全流程(ubuntu2204)

部署wvp

系统环境

系统版本ubuntu2204

安装相关工具

sudo apt update
## 编译工具
sudo apt install git openjdk-11-jdk tar vim cmake gcc g++ libsrtp2-dev libssl-dev
## ffmepg
sudo apt install ffmpeg

编译zlm

编译zlm

git clone https://gitee.com/xia-chu/ZLMediaKit.git

cd ZLMediaKit
git submodule update --init --recursive
mkdir -p build release/linux/Release/
cd build 
cmake -DCMAKE_BUILD_TYPE=Release -DENABLE_WEBRTC=true -DENABLE_TESTS=false ..
cmake --build . --target MediaServer

搭建wvp开发环境

安装maven

官网下载地址

wget https://dlcdn.apache.org/maven/maven-3/3.9.4/binaries/apache-maven-3.9.4-bin.tar.gz

mkdir app

tar xf apache-maven-3.9.4-bin.tar.gz

mv apache-maven-3.9.4 app/maven

echo "export PATH=~/app/maven/bin:\$PATH" >> ~/.bashrc
## 环境变量生效
source ~/.bashrc

安装nodejs

官网下载地址

wget https://nodejs.org/dist/v16.19.0/node-v16.19.0-linux-x64.tar.gz
tar xf node-v16.19.0-linux-x64.tar.gz
mv node-v16.19.0-linux-x64 app/node
echo "export PATH=~/app/node/bin:\$PATH" >> ~/.bashrc
## 环境变量生效
source ~/.bashrc

编译wvp

签出代码

git clone https://gitee.com/pan648540858/wvp-GB28181-pro.git

编译前端

cd wvp-GB28181-pro/web_src
# 下载依赖
npm install --registry=https://registry.npmmirror.com
# 编译
npm run build

编译后端

cd ..
mvn clean package -DskipTests

部署docker

curl -sfL https://get.rainbond.com/install_docker | bash

部署docker-compose

sudo curl -L https://github.com/docker/compose/releases/download/v2.20.3/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose

chmod +x /usr/local/bin/docker-compose

部署数据库和redis

  1. 创建安装目录
## 创建储存目录
mkdir -p /home/media/mysqldata /home/media/redisdata
  1. 创建yml文件
cd /home/media/
vim video.yml

将以下内容复制到vim编辑器中

version: "3.8"
services:
  redis:
    image: redis:6.2-alpine
    restart: always
    environment:
      TZ: Asia/Shanghai
    ports:
      - 6379:6379
    volumes:
      - /opt/video/redisdata/data:/data
      - /opt/video/redisdata/log:/logs
    command: redis-server --port 6379 --requirepass 12345678  --appendonly yes
  mysql:
    image: mysql:8
    restart: always
    command: 
      [
        "--character-set-server=utf8mb4",
        "--collation-server=utf8mb4_unicode_ci",
        "--default-time-zone=+8:00",
      ]
    ports:
      - 3306:3306
    environment:
      TZ: Asia/Shanghai
      MYSQL_ROOT_PASSWORD: 12345678
      SQL_MODE: "STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION"
    volumes:
      - /opt/video/mysqldata/mysql:/var/lib/mysql:rw 

  1. 启动数据库和redis
# 将镜像pull下来
docker pull redis:6.2-alpine
docker pull mysql:8
## 启动
docker-compose -f video.yml -p wvp up -d

部署zlm

  1. 创建安装目录
mkdir -p /home/media/zlm
  1. 复制zlm启动文件到安装目录
# 进入zlm项目目录
cd ~/ZLMediaKit
cp -r release/linux/Release/* /home/media/zlm
  1. 创建开机启动脚本
vim /etc/systemd/system/zlm.service

将以下内容复制到vim编辑器

[Unit]
Description=ZLMediaKit
[Service]
Environment="PATH=/usr/local/bin:/bin:/sbin:/usr/bin:/usr/sbin"
ExecStart=/home/media/zlm/MediaServer -c /home/media/zlm/config.ini
StandardOutput=null
[Install]
WantedBy=multi-user.target
  1. 启动zlm
# 设置开机启动
systemctl enable zlm
# 启动zlm
systemctl start zlm
  1. 其他
# 重启zlm
systemctl restart zlm
# 停止zlm
systemctl stop zlm
# 查看启动状态 
systemctl status zlm

部署wvp

  1. 导入sql文件
## 进入wvp项目
cd ~/wvp-GB28181-pro/
## 复制mysql.sql、update.sql文件到mysql容器
docker cp sql media-mysql-1:/tmp
## 进入mysql容器
docker exec -it media-mysql-1 bash
## 登录数据库
mysql -uroot -p12345678
## 创建wvp数据库
CREATE DATABASE `wvp` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
  1. 创建安装目录
mkdir -p /home/media/wvp
  1. 复制jar文件和配置到安装目录
cd ~/wvp-GB28181-pro/
# 复制java包安装目录
cp target/wvp-pro-2.6.6-xxxxx.jar /home/media/wvp/wvp-pro.jar
# 复制配置文件安装目录
cp src/main/resources/all-application.yml /home/media/wvp/application.yml
  1. 创建开机启动文件
vim /etc/systemd/system/wvp.service

将以下内容复制到vim编辑器

[Unit]
Description=wvp
[Service]
Environment="PATH=/usr/local/bin:/bin:/sbin:/usr/bin:/usr/sbin"
ExecStart=/usr/bin/java -jar /home/media/wvp/wvp-pro.jar --spring.config.location=/home/media/wvp/application.yml
StandardOutput=null
[Install]
WantedBy=multi-user.target
  1. 启动wvp
# 设置开机启动
systemctl enable wvp
# 启动wvp
systemctl start wvp
  1. 其他
# 重启wvp
systemctl restart wvp
# 停止wvp
systemctl stop wvp
# 查看启动状态 
systemctl status wvp

wvp-pro-assist 部署

  1. 编译
git clone https://gitee.com/pan648540858/wvp-pro-assist.git
cd wvp-pro-assist
## assist在编译前需要把配置文件更改好
mvn clean package -DskipTests
  1. 安装
mkdir /home/media/assist
cp target/wvp-pro-assist-2.6.8-08261304.jar /home/media/assist/wvp-pro-assist.jar
  1. 创建开机启动文件
vim /etc/systemd/system/assist.service

将以下内容复制到vim编辑器

[Unit]
Description=assist
[Service]
Environment="PATH=/usr/local/bin:/bin:/sbin:/usr/bin:/usr/sbin"
ExecStart=/usr/bin/java -jar /home/media/assist/wvp-pro-assist.jar 
StandardOutput=null
[Install]
WantedBy=multi-user.target
  1. 启动wvp
# 设置开机启动
systemctl enable assist
# 启动wvp
systemctl start assist

登录

登录地址

http://xxx.xxx.xxx.xxx:18080

用户名/密码:admin/admin

需要远程协助可私信我

你可能感兴趣的:(运维,GB28181,运维)