【环境搭建】Metersphere v2.x 容器部署教程踩坑总结

news/2025/1/31 16:57:50/

前言

Metersphere部署过程中遇到的问题有点多,原因是其容器的架构蛮复杂的,比较容易踩坑,所以记录一下。

介绍

MeterSphere 是开源持续测试平台,遵循 GPL v3 开源许可协议,涵盖测试管理、接口测试、UI 测试和性能测试等功能,全面兼容 JMeter、Selenium 等主流开源标准,有效助力开发和测试团队充分利用云弹性进行高度可扩展的自动化测试,加速高质量的软件交付。
在这里插入图片描述

主页:https://metersphere.io/

源码:https://github.com/metersphere/metersphere

前置环境

Ubuntu 20.04
Docker version 27.3.1
docker-compose version 1.27.4
openjdk version “17.0.13”

MeterSphere-v2.4.0安装部署

首先以v2.4.0为例,直接给出我的sh:

if [ "$(id -u)" -ne 0 ]; thenecho "此脚本需要root权限,请使用sudo执行。"exit 1
fiwget https://github.com/metersphere/metersphere/releases/download/v2.4.0/metersphere-online-installer-v2.4.0.tar.gz --no-check-certificatetar zxvf metersphere-online-installer-v2.4.0.tar.gzcd metersphere-online-installer-v2.4.0#启用工作台
#CONFIG_FILE="install.conf"
#echo "修改配置文件..."
#sed -i 's/^MS_UI_ENABLED=false$/MS_UI_ENABLED=true/' "$CONFIG_FILE"
#sed -i 's/^MS_WORKSTATION_ENABLED=false$/MS_WORKSTATION_ENABLED=true/' "$CONFIG_FILE"#MYSQL降级
#sed -i 's/\${MS_IMAGE_PREFIX}\/mysql:8.0.33/\${MS_IMAGE_PREFIX}\/mysql:8.0.30/' "metersphere/docker-compose-mysql.yml"sudo ./install.shmsctl status

可以使用命令msctl status检查服务运行情况,正确部署后的输出如下所示:

       Name                     Command                  State                     Ports              
------------------------------------------------------------------------------------------------------
api-test             /deployments/run-java.sh         Up (healthy)   0.0.0.0:10000->10000/tcp,:::10000->10000/tcp, 0.0.0.0:10001->10001/tcp,:::10001->10001/tcp, 0.0.0.0:10002->10002/tcp,:::10002->10002/tcp, 0.0.0.0:10003->10003/tcp,:::10003->10003/tcp, 0.0.0.0:10004->10004/tcp,:::10004->10004/tcp, 0.0.0.0:10005->10005/tcp,:::10005->10005/tcp, 0.0.0.0:10006->10006/tcp,:::10006->10006/tcp, 0.0.0.0:10007->10007/tcp,:::10007->10007/tcp, 0.0.0.0:10008->10008/tcp,:::10008->10008/tcp, 0.0.0.0:10009->10009/tcp,:::10009->10009/tcp, 0.0.0.0:10010->10010/tcp,:::10010->10010/tcp                        
eureka               /deployments/run-java.sh         Up (healthy)                                    
gateway              /deployments/run-java.sh         Up (healthy)   0.0.0.0:8081->8000/tcp,:::8081->8000/tcp                          
kafka                /opt/bitnami/scripts/kafka ...   Up (healthy)   0.0.0.0:9092->9092/tcp,:::9092->9092/tcp                          
minio                /usr/bin/docker-entrypoint ...   Up (healthy)   0.0.0.0:9000->9000/tcp,:::9000->9000/tcp, 0.0.0.0:9001->9001/tcp,:::9001->9001/tcp                 
ms-data-streaming    /deployments/run-java.sh         Up (healthy)                                    
ms-node-controller   /deployments/run-java.sh         Up (healthy)   0.0.0.0:8082->8082/tcp,:::8082->8082/tcp, 0.0.0.0:9100->9100/tcp,:::9100->9100/tcp                 
ms-prometheus        /bin/prometheus --config.f ...   Up (healthy)   0.0.0.0:9090->9090/tcp,:::9090->9090/tcp                          
mysql                docker-entrypoint.sh mysqld      Up (healthy)   0.0.0.0:3307->3306/tcp,:::3307->3306/tcp, 33060/tcp               
nodeexporter         /bin/node_exporter --path. ...   Up (healthy)                                    
performance-test     /deployments/run-java.sh         Up (healthy)                                    
project-management   /deployments/run-java.sh         Up (healthy)                                    
redis                docker-entrypoint.sh redis ...   Up (healthy)   0.0.0.0:6379->6379/tcp,:::6379->6379/tcp                          
report-stat          /deployments/run-java.sh         Up (healthy)                                    
system-setting       /deployments/run-java.sh         Up (healthy)                                    
test-track           /deployments/run-java.sh         Up (healthy)                                                        
URL: http://$LOCAL_IP:8081
用户名: admin
初始密码: metersphere

在这里插入图片描述

然而整个过程并非这么顺利的,过程中会出现各种各样的问题(尤其是在服务器部署的情况下),我的建议是时刻检查安装目录在哪里,通过Debug找到到底是哪里的conf文件在生效,免得乱改一通发现压根没从这里读配置。。。
接下来说一些比较好解决的问题:

v2.4.0 Q&A

Q:部分容器(例如api-test等)起不来,msctl status显示mysql容器一直在restarting

$ msctl statusName                     Command                  State                                       Ports                                
------------------------------------------------------------------------------------------------------------------------------------------
eureka               /deployments/run-java.sh         Up (healthy)                                                                        
gateway              /deployments/run-java.sh         Up (healthy)   0.0.0.0:8081->8000/tcp,:::8081->8000/tcp                             
kafka                /opt/bitnami/scripts/kafka ...   Up (healthy)   0.0.0.0:9092->9092/tcp,:::9092->9092/tcp                             
minio                /usr/bin/docker-entrypoint ...   Up (healthy)   0.0.0.0:9000->9000/tcp,:::9000->9000/tcp,                            0.0.0.0:9001->9001/tcp,:::9001->9001/tcp                             
ms-data-streaming    /deployments/run-java.sh         Up (healthy)                                                                        
ms-node-controller   /deployments/run-java.sh         Up (healthy)   0.0.0.0:8082->8082/tcp,:::8082->8082/tcp,                            0.0.0.0:9100->9100/tcp,:::9100->9100/tcp                             
ms-prometheus        /bin/prometheus --config.f ...   Up (healthy)   0.0.0.0:9090->9090/tcp,:::9090->9090/tcp                             
mysql                docker-entrypoint.sh mysqld      Restarting                                                                          
nodeexporter         /bin/node_exporter --path. ...   Up (healthy)                                                                        
redis                docker-entrypoint.sh redis ...   Up (healthy)   0.0.0.0:6379->6379/tcp,:::6379->6379/tcp                             

A:这个问题一般出现在之前安装过高版本Metersphere的情况,看一下日志

$ docker logs mysql
2025-01-09 04:58:20+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.30-1.el8 started.
2025-01-09 04:58:20+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2025-01-09 04:58:20+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.30-1.el8 started.
'/var/lib/mysql/mysql.sock' -> '/var/run/mysqld/mysqld.sock'
2025-01-09T04:58:20.857320Z 0 [Warning] [MY-011068] [Server] The syntax '--skip-host-cache' is deprecated and will be removed in a future release. Please use SET GLOBAL host_cache_size=0 instead.
2025-01-09T04:58:20.857349Z 0 [Warning] [MY-011068] [Server] The syntax 'expire-logs-days' is deprecated and will be removed in a future release. Please use binlog_expire_logs_seconds instead.
2025-01-09T04:58:20.857466Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.30) starting as process 1
2025-01-09T04:58:20.861214Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2025-01-09T04:58:21.299938Z 1 [ERROR] [MY-013171] [InnoDB] Cannot boot server version 80030 on data directory built by version 80033. Downgrade is not supported
mysqld: Can't open file: 'mysql.ibd' (errno: 0 - )
2025-01-09T04:58:21.594261Z 1 [ERROR] [MY-010334] [Server] Failed to initialize DD Storage Engine
2025-01-09T04:58:21.594352Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
2025-01-09T04:58:21.594359Z 0 [ERROR] [MY-010119] [Server] Aborting
2025-01-09T04:58:21.594589Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.30)  MySQL Community Server - GPL.

可以看到是mysql版本不匹配问题,修改metersphere-online-installer-v2.x.x/metersphere/docker-compose-mysql.yml,进行降级:

version: "2.1"
services:mysql:image: ${MS_IMAGE_PREFIX}/mysql:8.0.33container_name: mysqlhealthcheck:test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-uroot", "-p${MS_MYSQL_PASSWORD}"]interval: 6stimeout: 5sretries: 50environment:MYSQL_DATABASE: ${MS_MYSQL_DB}MYSQL_ROOT_PASSWORD: ${MS_MYSQL_PASSWORD}ports:- 3307:3306volumes:- ${MS_BASE}/metersphere/conf/my.cnf:/etc/mysql/conf.d/my.cnf- ${MS_BASE}/metersphere/bin/mysql:/docker-entrypoint-initdb.d/- ms-mysql-data:/var/lib/mysqlnetworks:- ms-networkrestart: alwayssystem-setting:depends_on:mysql:condition: service_healthyvolumes:ms-mysql-data:driver_opts:type: nonedevice: ${MS_BASE}/metersphere/data/mysqlo: bind

修改之后重新安装即可,当然也可以直接解除start_in_docker.sh里MYSQL降级部分的注释后重新执行即可

sed -i 's/\${MS_IMAGE_PREFIX}\/mysql:8.0.33/\${MS_IMAGE_PREFIX}\/mysql:8.0.30/' "metersphere/docker-compose-mysql.yml"

Q:工作台未启用,功能不齐全,左侧边栏只显示两种功能。

A:修改install.conf如下内容:

MS_UI_ENABLED=true
MS_WORKSTATION_ENABLED=true

执行msctl reload后,即可看到工作台容器已经启动便可以正常使用,访问UI后可以看到左侧边栏已经显示全面。当然也可以直接解除start_in_docker.sh里启用工作台部分的注释后重新执行即可

CONFIG_FILE="install.conf"
sed -i 's/^MS_UI_ENABLED=false$/MS_UI_ENABLED=true/' "$CONFIG_FILE"
sed -i 's/^MS_WORKSTATION_ENABLED=false$/MS_WORKSTATION_ENABLED=true/' "$CONFIG_FILE"

MeterSphere-v2.10.1-lts安装部署

再拿v2.10.1-lts版本举例:

$ wget https://github.com/metersphere/metersphere/releases/download/v2.10.1-lts/metersphere-online-installer-v2.10.1-lts.tar.gz --no-check-certificate
$ tar zxvf metersphere-online-installer-v2.10.1-lts.tar.gz
$ cd metersphere-online-installer-v2.10.1-lts
$ sudo ./install.sh
$ msctl statusName                  Command               State                Ports         
--------------------------------------------------------------------------------------
api-test             /deployments/run-java.sh   Up (healthy)   0.0.0.0:10000->10000/tcp,:::10000->10000/tcp, 0.0.0.0:10001->10001/tcp,:::10001->10001/tcp, 0.0.0.0:10002->10002/tcp,:::10002->10002/tcp, 0.0.0.0:10003->10003/tcp,:::10003->10003/tcp, 0.0.0.0:10004->10004/tcp,:::10004->10004/tcp, 0.0.0.0:10005->10005/tcp,:::10005->10005/tcp, 0.0.0.0:10006->10006/tcp,:::10006->10006/tcp, 0.0.0.0:10007->10007/tcp,:::10007->10007/tcp, 0.0.0.0:10008->10008/tcp,:::10008->10008/tcp, 0.0.0.0:10009->10009/tcp,:::10009->10009/tcp, 0.0.0.0:10010->10010/tcp,:::10010->10010/tcp  
eureka               /deployments/run-java.sh   Up (healthy)                          
gateway              /deployments/run-java.sh   Up (healthy)   0.0.0.0:8081->8000/tcp,:::8081->8000/tcp      
kafka                /opt/bitnami/scripts/kaf   Up (healthy)   0.0.0.0:9092->9092/tcp,ka ...                                    :::9092->9092/tcp      
minio                /usr/bin/docker-           Up (healthy)   0.0.0.0:9000->9000/tcp,entrypoint ...                            :::9000->9000/tcp, 0.0.0.0:9001->9001/tcp,:::9001->9001/tcp          
ms-data-streaming    /deployments/run-java.sh   Up (healthy)                          
ms-node-controller   sh -c sed -i               Up (healthy)   0.0.0.0:8082->8082/tcp,"s/:101:/:136 ...                         :::8082->8082/tcp, 0.0.0.0:9100->9100/tcp,:::9100->9100/tcp          
ms-prometheus        /bin/prometheus            Up (healthy)   0.0.0.0:9091->9090/tcp,--config.f ...                            :::9091->9090/tcp      
mysql                docker-entrypoint.sh       Up (healthy)   0.0.0.0:3306->3306/tcp,mysqld                                    :::3306->3306/tcp,     33060/tcp              
nodeexporter         /bin/node_exporter         Up (healthy)                          --path. ...                                                      
performance-test     /deployments/run-java.sh   Up (healthy)                          
project-management   /deployments/run-java.sh   Up (healthy)                          
redis                docker-entrypoint.sh       Up (healthy)   0.0.0.0:6379->6379/tcp,redis ...                                 :::6379->6379/tcp      
report-stat          /deployments/run-java.sh   Up (healthy)                          
system-setting       /deployments/run-java.sh   Up (healthy)                          
test-track           /deployments/run-java.sh   Up (healthy)                          
workstation          /deployments/run-java.sh   Up (healthy) 

v2.10.1-lts Debug

Debug1:访问Web UI有{"success":false,"message":"401 UNAUTHORIZED \"Not found session, Please Login again.\"","data":null}报错,一定要等待所有容器Up并healthy状态,后再等5min访问Web UI(不要中途切换)。

Debug2:9090端口号占用问题,在docker-compose-prometheus.ymlinstall.conf修改为9091即可。

# Debug3: Additionally
$ msctl restart gateway
$ msctl restart workstation
$ msctl restart prometheus

http://www.ppmy.cn/news/1567584.html

相关文章

C++ 学习:深入理解 Linux 系统中的冯诺依曼架构

一、引言 冯诺依曼架构是现代计算机系统的基础,它的提出为计算机的发展奠定了理论基础。在学习 C 和 Linux 系统时,理解冯诺依曼架构有助于我们更好地理解程序是如何在计算机中运行的,包括程序的存储、执行和资源管理。这对于编写高效、可靠的…

二级C语言题解:孤独数、找最长子串、返回两数组交集

目录 一、程序填空 --- 孤独数 题目 分析 二、程序修改 --- 找最长子串 题目 分析 三、程序设计题 --- 返回两数组交集 题目 分析 前言: 本文开始讲解二级C语言的程序填空题和程序改错题以及程序设计题 旨在帮助大家更好的理解这些题目 希望能够帮助到大家(…

使用八爪鱼爬虫和Web Scraper抓取数据实战案例,附详细教程

最近有不少小伙伴咨询怎么抓取抖音视频或者评论的数据,他们多是自媒体或者商家,想要模仿爆火视频或者分析视频评论区的舆情信息,确实呀,现在抖音是流量高地,淘金的地方,真的是一个值得挖掘的宝藏。当然我一…

机器学习:支持向量机

支持向量机(Support Vector Machine)是一种二类分类模型,其基本模型定义为特征空间上的间隔最大的广义线性分类器,其学习策略便是间隔最大化,最终可转化为一个凸二次规划问题的求解。 假设两类数据可以被 H x : w T x…

08.OSPF 特殊区域及其他特性

OSPF 特殊区域及其他特性 一. 前言OSPF的四个特殊区域Stub末梢区域Totally Stub完全末梢区域NSSATotally NSSA完全的NSSA二.Stub 区域和 Totally Stub 区域(1)网络规模变大引发的问题(2)传输区域和末端区域(3)Stub 区域(4)Totally Stub 区域三.NSSA 区域和 Totally NSS…

运行虚幻引擎UE设置Visual Studio

运行虚幻引擎UE设置Visual Studio 1. 枚举转换为字符串2. 修改 解决方案配置 下拉框宽度3. 调试较慢4. 如何修复GPU驱动程序崩溃 1. 枚举转换为字符串 -Desc: 从静态 Uenum 调用 GetNameStringByValue 并为其提供你要获取其名称的值,可以将枚举转换为字符串。初始化…

【2024年终总结】深圳工作生活评测

距离上次写年终总结已经过了一年半了,这一年半中哪怕经历了很多的事情,但是感觉又没发生什么。想写一些骚话,却总觉得自己无法完全表达,便也就这样,静静地记录下这一段时光。 现在是2025年,春节前的时光&am…

vue(33) : 安装组件出错解决

1. request to https://registry.npm.taobao.org/semver/download/semver-6.1.1.tgz?cache0&other_urlshttps%3A%2F%2Fregistry.npm.taobao.org%2Fsemver%2Fdownload%2Fsemver-6.1.1.tgz failed, reason: certificate has expired 这个错误提示表明你在尝试从https://reg…