当前位置: 首页 > article >正文

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

前言

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

http://www.kler.cn/a/487954.html

相关文章:

  • 网络-ping包分析
  • 鸿蒙面试 2025-01-10
  • 【Java项目】基于SpringBoot的【校园交友系统】
  • Ruby语言的软件开发工具
  • 『SQLite』解释执行(Explain)
  • vue2日历组件
  • 道品科技智慧农业与云平台:未来农业的变革之路
  • 【集成学习】Bagging算法详解及代码实现
  • 初学stm32 --- DAC模数转换器工作原理
  • #Phi-4:微软 14B 参数开源模型,性能匹敌 OpenAI GPT-4o-mini,现已登陆 Ollama
  • 互联网全景消息(10)之Kafka深度剖析(中)
  • 软件测试基础知识③—计算机网络基础
  • redis 模糊删除
  • 电脑每次开机卡到windows图标界面进不去
  • 设计模式 行为型 模板方法模式(Template Method Pattern)与 常见技术框架应用 解析
  • Git:merge合并、冲突解决、强行回退的终极解决方案
  • 社交新零售下开源 AI 智能名片 2+1 链动模式 S2B2C 商城小程序的创新实践与发展剖析
  • 【MySQL】数据库可视化工具,MySQL命令
  • ClickHouse vs StarRocks 选型对比
  • 红帽认证 VS 华为HCIP哪个有用?
  • 执行这个composer require topthink/think-mongo 报错
  • elasticsearch常见故障汇总
  • 2025年伊始:回顾 ChatGPT 引发的 AI 变革以及未来展望
  • xfs扩容目录lvm
  • 2025年XR行业展望:超越虚拟,融合现实
  • 浏览器网络插件