首页 > 其他分享 >【环境搭建】Metersphere v2.x 容器部署教程&踩坑总结

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

时间:2025-01-09 18:02:06浏览次数:3  
标签:教程 healthy 0.0 mysql Up tcp v2 sh Metersphere

前言

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 ]; then
  echo "此脚本需要root权限,请使用sudo执行。"
  exit 1
fi

wget https://github.com/metersphere/metersphere/releases/download/v2.4.0/metersphere-online-installer-v2.4.0.tar.gz --no-check-certificate

tar zxvf metersphere-online-installer-v2.4.0.tar.gz

cd 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.sh

msctl 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->8
                                                                     000/tcp                          
kafka                /opt/bitnami/scripts/kafka ...   Up (healthy)   0.0.0.0:9092->9092/tcp,:::9092->9
                                                                     092/tcp                          
minio                /usr/bin/docker-entrypoint ...   Up (healthy)   0.0.0.0:9000->9000/tcp,:::9000->9
                                                                     000/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->8
                                                                     082/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->9
                                                                     090/tcp                          
mysql                docker-entrypoint.sh mysqld      Up (healthy)   0.0.0.0:3307->3306/tcp,:::3307->3
                                                                     306/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->6
                                                                     379/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 status

       Name                     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.33
    container_name: mysql
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-uroot", "-p${MS_MYSQL_PASSWORD}"]
      interval: 6s
      timeout: 5s
      retries: 50
    environment:
      MYSQL_DATABASE: ${MS_MYSQL_DB}
      MYSQL_ROOT_PASSWORD: ${MS_MYSQL_PASSWORD}
    ports:
      - 3307:3306
    volumes:
      - ${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/mysql
    networks:
      - ms-network
    restart: always
  system-setting:
    depends_on:
      mysql:
        condition: service_healthy

volumes:
  ms-mysql-data:
    driver_opts:
      type: none
      device: ${MS_BASE}/metersphere/data/mysql
      o: 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 status
       Name                  Command               State                Ports         
--------------------------------------------------------------------------------------
api-test             /deployments/run-java.sh   Up (healthy)   0.0.0.0:10000->10000/tc
                                                               p,:::10000->10000/tcp, 
                                                               0.0.0.0:10001->10001/tc
                                                               p,:::10001->10001/tcp, 
                                                               0.0.0.0:10002->10002/tc
                                                               p,:::10002->10002/tcp, 
                                                               0.0.0.0:10003->10003/tc
                                                               p,:::10003->10003/tcp, 
                                                               0.0.0.0:10004->10004/tc
                                                               p,:::10004->10004/tcp, 
                                                               0.0.0.0:10005->10005/tc
                                                               p,:::10005->10005/tcp, 
                                                               0.0.0.0:10006->10006/tc
                                                               p,:::10006->10006/tcp, 
                                                               0.0.0.0:10007->10007/tc
                                                               p,:::10007->10007/tcp, 
                                                               0.0.0.0:10008->10008/tc
                                                               p,:::10008->10008/tcp, 
                                                               0.0.0.0:10009->10009/tc
                                                               p,:::10009->10009/tcp, 
                                                               0.0.0.0:10010->10010/tc
                                                               p,:::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,:::9
                                                               001->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,:::9
                                                               100->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

标签:教程,healthy,0.0,mysql,Up,tcp,v2,sh,Metersphere
From: https://blog.csdn.net/Mitchell_Donovan/article/details/145034583

相关文章

  • 2025最新Python安装教程+PyCharm安装教程(超详细!)看这一篇全都搞定!
    Python安装1、首先进入网站下载:点击打开链接(或自己输入网址https://www.python.org/downloads/),进入之后如下图,选择图中红色圈中区域进行下载。(免下载直接安装......
  • langfuse从v2升级到v3(本地升级)
    环境:OS:Centos7#################################################部署v2###########################################################1.部署v2v2资源清单配置文件如下:[root@host135langfuse]#moredocker-compose.ymlservices:langfuse-server:image:regi......
  • 如何安装python?超详细安装教程!
    首先,请确保你的系统是Windows-64位1.下载Python首先,打开浏览器,我们需要到Python的官方网站在地址栏输入python.org,然后点击页面上的“Downloads”按钮,接着选择适合你电脑系统的版本进行下载。如果是Windows或者Mac的小可爱们,直接下载推荐版本就好啦。小编下载的是python-3.7......
  • Three.js教程015:全面讲解Three.js的UV与应用
    文章目录全面讲解UV与应用UV介绍代码演示完整代码全面讲解UV与应用UV介绍在Three.js中,UV坐标(也称为纹理坐标)是用来定义纹理如何映射到三维模型上的一组二维坐标。UV坐标的范围通常是(0,0)到(1,1),其中:U对应纹理的横向轴(类似于X轴)。V对应纹......
  • 服务器安全设置教程,手把手保护好你的主机(保姆级)
    防护的意义自古以来,攻击和防护就像盾牌和矛处于对立面上。自打有linux系统以来,这两个对立面就一直彼此的升级,又彼此的促进。互联网时代,网站、APP、服务均部署在远程服务器上,这背后牵涉到巨大的经济利益和商业价值,于是各种产业链就有了巨大的攻击动力,所以防护的好可以减少遭......
  • 看完这个教程,非专业人士也能搭建出AI口播数字人系统!
    随着AI口播数字人的使用频率不断提升,不少创业者都开始察觉到了它所蕴含着的巨大市场需求,并关注起了与之相关的各类话题,特别是AI口播数字人系统怎么搭建这一问题,几乎到了一经出现,就能够立刻引发热烈讨论的程度。毕竟,不管是从AI口播数字人目前在影视娱乐、品牌营销、电商直播和......
  • go语言RSA分段加密V2501
    go语言RSA分段加密V2501,GOLANG,RSA/ECB/PKCS1Padding。 加密解析://假设私钥长度为1024,1024/8-11=117。//如果明文的长度小于117,直接全加密,然后转base64。(data.Length<=maxBlockSize)//如果明文长度大于117,则每117分一段加密,publicKey.Size()刚好是(私钥长度/8)。privateKey.......
  • C-V2X测试探秘系列之:电磁兼容试验方法
    在智能网联汽车中,各种通信技术如2G/3G/4G/5G、GNSS(全球导航卫星系统)、V2X(车联网通信)等在行业内被广泛使用。这些技术让汽车能够实现紧急呼叫、在线娱乐、导航等多种功能。EMC测试就是为了确保在复杂电磁环境下,汽车的通信系统仍然可以正常工作,保护驾乘者的安全。参考《QCT-基于LTE-......
  • CF div2 994 (A~E)
    VP赛时三题,自我感觉发挥不错,唯一不满意的地方在于D题完全没有思路。A答案最多为2,因为最坏情况即为先将整个区间合并为一个数,若这个数不是0,则再将这个数变为0。所以3种情况分类讨论即可:全是0,则不需要操作->\(0\)只有一段非\(0\)连续区间->\(1\)不止\(1\)个非\(0\)连续区......
  • 蓝易云 - 用JAVA实现文件分隔功能教程
    当你需要用Java实现文件分隔功能时,你可以按照以下步骤进行操作。文件分隔功能指将一个大文件分隔成多个小文件,以方便处理和传输。步骤1:导入JavaIO包首先,在Java程序中导入JavaIO包,以便后续处理文件操作。importjava.io.*;​步骤2:实现文件分隔功能接下来,你可以创建一个J......