【DockerCE】使用Docker安装运行性能测试工具-RunnerGo

时间:2021-05-06 01:22:45

一、安装环境

CentOS-7.9 / Docker-CE-23.0.1 / Docker-compose-2.17.2

二、资源配置

4核8G(官方建议8核16GB)

三、安装运行

从Github下载安装所需的文件包(版本1.0.3),这里选择的是tar.gz包

【DockerCE】使用Docker安装运行性能测试工具-RunnerGo

 将压缩包里面的runnergo目录上传到本地虚拟机/data目录下,目录结构如下所示:

# tree -L 2
.
├── config.env
├── mongo
│   └── init-mongo.sh
├── mysql
│   ├── mysql.cnf
│   └── mysql.sql
└── runnergo.yaml

2 directories, 5 files

备注:runnergo.yaml是我这边重命名后的,压缩包里面的源文件名为docker-compose.yaml

核心配置文件-config.env,官方文档说一般无需修改,但是里面涉及到的密码存在弱密码,在生产环境运行,这个配置肯定是要修改的。

下面是我本地修改 config.env 的配置:

# 数据库root 密码
MYSQL_ROOT_PASSWORD=3******M

# runnergo 使用的数据库名
MYSQL_DATABASE=runnergo

# redis 初始话
REDIS_PASSWD=3******M

# Mongo 数据管理员的用户名
MONGO_INITDB_ROOT_USERNAME=root

# Mongo 数据库管理员的账号
MONGO_INITDB_ROOT_PASSWORD=3******M

# runnergo  Mongo使用的数据库名
MONGO_INITDB_DATABASE=runnergo

# runnergo Mongo库的用户名
MONGO_INITDB_USERNAME=runnergo

# runnergo Mongo库的密码
MONGO_INITDB_PASSWORD=3******M

# 最大并发数
MAX_RUNNER_CONCURRENCY=1000

# 上传文件端口号(非必要不要改,这是容器里的)
FILE_SERVER_PORT=80

# Runnergo 应用mongo 配置
RG_MONGO_DSN=mongodb://runnergo:3******M@mongo-db:27017/runnergo
RG_MONGO_DATABASE=runnergo
RG_REDIS_ADDRESS=redis-db:6379
RG_REDIS_PASSWORD=3******M
RG_REDIS_DB=0

# kafka Topic
RG_KAFKA_TOPIC=report
RG_KAFKA_ADDRESS=kafka:9092
RG_KAFKA_PORT=9092

# kafka 分区数,(同时并行跑多少任务)
RG_KAFKA_NUM=2

# engine 日志路径
RG_ENGINE_LOG_PATH=/dev/stdout

# collector 日志路径
RG_COLLECTOR_LOG_PATH=/dev/stdout

# 内部互通参数(不要更改)
RG_MANAGEMENT_NOTIFY_STOP_STRESS=http://manage:30000/management/api/v1/plan/notify_stop_stress
RG_MANAGEMENT_NOTIFY_RUN_FINISH=http://manage:30000/management/api/v1/auto_plan/notify_run_finish
RG_DOMAIN=
RG_MYSQL_HOST=mysql-db
RG_MYSQL_USERNAME=root
RG_MYSQL_PASSWORD=3******M
RG_MYSQL_DBNAME=runnergo

# JWT
RG_JWT_ISSUER=asfdasfasdfasfd
RG_JWT_SECRET=sdfaswerwrwerwerwer

# MONG
RG_MONGO_PASSWORD=3******M

#  内部互通参数(不要更改)
RG_CLIENTS_ENGINE_RUN_API=http://engine:30000/runner/run_api
RG_CLIENTS_ENGINE_RUN_SCENE=http://engine:30000/runner/run_scene
RG_CLIENTS_ENGINE_STOP_SCENE=http://engine:30000/runner/stop_scene
RG_CLIENTS_ENGINE_RUN_PLAN=http://engine:30000/runner/run_plan
RG_CLIENTS_ENGINE_STOP_PLAN=http://engine:30000/runner/stop
RG_REDIS_REPORT_ADDRESS=redis-db:6379

# #初始化压力机可使用分区
RG_CAN_USE_PARTITION_TOTAL_NUM=2

## KAFKA 配置
KAFKA_ZOOKEEPER_CONNECT=zookeeper:2181/kafka
KAFKA_LISTENERS=PLAINTEXT://:9092
KAFKA_BROKER_ID=0
KAFKA_CREATE_TOPICS=report:2:1

runnergo.yaml(注意redis-server启动密码的修改)

version: "3"
services:
  mysql-db:
    image: registry.cn-beijing.aliyuncs.com/runnergo/mysql:5.7.40.v1
    env_file:
      - ./config.env
    volumes:
      - ./mysql/mysql.sql:/docker-entrypoint-initdb.d/mysql.sql:ro
      - ./mysql/data:/var/lib/mysql
    restart: always
    networks:
      - apipost_net
  redis-db:
    image: registry.cn-beijing.aliyuncs.com/runnergo/redis:6.2.7
    volumes:
      - ./redis/data:/data
    command:  redis-server --requirepass 3******M
    restart: always
    networks:
      - apipost_net
  mongo-db:
    image: registry.cn-beijing.aliyuncs.com/runnergo/mongo:4.4
    env_file:
      - ./config.env
    volumes:
      - ./mongo/data:/data/db
      - ./mongo/init-mongo.sh:/docker-entrypoint-initdb.d/init-mongo.sh
    restart: always
    networks:
      - apipost_net
  manage:
    image: registry.cn-beijing.aliyuncs.com/runnergo/manage:releases-v1.0.4
    restart: always
    env_file:
      - ./config.env
    networks:
      - apipost_net
    ports:
      - "58889:30000"
    depends_on:
      - mysql-db
  web-ui:
    image: registry.cn-beijing.aliyuncs.com/runnergo/web-ui:releases-v1.0.5
    restart: always
    ports:
      - "9999:81"
      - "58888:82"
    networks:
      - apipost_net
  engine:
    image: registry.cn-beijing.aliyuncs.com/runnergo/engine:releases-v1.0.3
    restart: always
    env_file:
      - ./config.env
    networks:
      - apipost_net
  file-server:
    image: registry.cn-beijing.aliyuncs.com/runnergo/file-server:v2.2
    restart: always
    env_file:
      - ./config.env
    volumes:
      - ./file-server/data:/app/file-server/file
    networks:
      - apipost_net
  zookeeper:
      image: registry.cn-beijing.aliyuncs.com/runnergo/zookeeper:latest 
      restart: always
      networks:
        - apipost_net
  kafka:
    image: registry.cn-beijing.aliyuncs.com/runnergo/kafka:2.13-3.2.1 
    restart: always
    depends_on:
        - zookeeper
    env_file:
        - ./config.env
    networks:
      - apipost_net
  collector:
      image: registry.cn-beijing.aliyuncs.com/runnergo/collector:master
      restart: always
      env_file:
        - ./config.env
      networks:
        - apipost_net
      depends_on:
        - kafka
networks:
  apipost_net:
    driver: bridge

启动runnergo

# cd runnergo
# docker-compose -f runnergo.yaml up -d
[+] Running 11/11
 ✔ Network runnergo_apipost_net      Created                                                                                                                                         0.1s 
 ✔ Container runnergo-file-server-1  Started                                                                                                                                         1.9s 
 ✔ Container runnergo-zookeeper-1    Started                                                                                                                                         1.9s 
 ✔ Container runnergo-redis-db-1     Started                                                                                                                                         1.6s 
 ✔ Container runnergo-mongo-db-1     Started                                                                                                                                         1.8s 
 ✔ Container runnergo-mysql-db-1     Started                                                                                                                                         1.8s 
 ✔ Container runnergo-web-ui-1       Started                                                                                                                                         2.1s 
 ✔ Container runnergo-engine-1       Started                                                                                                                                         1.3s 
 ✔ Container runnergo-manage-1       Started                                                                                                                                         2.3s 
 ✔ Container runnergo-kafka-1        Started                                                                                                                                         2.5s 
 ✔ Container runnergo-collector-1    Started 

# docker-compose -f runnergo.yaml ps
NAME                     IMAGE                                                              COMMAND                  SERVICE             CREATED             STATUS              PORTS
runnergo-collector-1     registry.cn-beijing.aliyuncs.com/runnergo/collector:master         "/data/collector/col…"   collector           31 seconds ago      Up 27 seconds       
runnergo-engine-1        registry.cn-beijing.aliyuncs.com/runnergo/engine:releases-v1.0.3   "/data/engine/engine…"   engine              31 seconds ago      Up 28 seconds       
runnergo-file-server-1   registry.cn-beijing.aliyuncs.com/runnergo/file-server:v2.2         "docker-entrypoint.s…"   file-server         31 seconds ago      Up 29 seconds       
runnergo-kafka-1         registry.cn-beijing.aliyuncs.com/runnergo/kafka:2.13-3.2.1         "start-kafka.sh"         kafka               31 seconds ago      Up 28 seconds       
runnergo-manage-1        registry.cn-beijing.aliyuncs.com/runnergo/manage:releases-v1.0.3   "/data/manage/manage…"   manage              31 seconds ago      Up 27 seconds       0.0.0.0:58889->30000/tcp, :::58889->30000/tcp
runnergo-mongo-db-1      registry.cn-beijing.aliyuncs.com/runnergo/mongo:4.4                "docker-entrypoint.s…"   mongo-db            31 seconds ago      Up 29 seconds       27017/tcp
runnergo-mysql-db-1      registry.cn-beijing.aliyuncs.com/runnergo/mysql:5.7.40.v1          "docker-entrypoint.s…"   mysql-db            31 seconds ago      Up 29 seconds       3306/tcp, 33060/tcp
runnergo-redis-db-1      registry.cn-beijing.aliyuncs.com/runnergo/redis:6.2.7              "docker-entrypoint.s…"   redis-db            31 seconds ago      Up 29 seconds       6379/tcp
runnergo-web-ui-1        registry.cn-beijing.aliyuncs.com/runnergo/web-ui:releases-v1.0.5   "/bin/entrypoint.sh …"   web-ui              31 seconds ago      Up 28 seconds       80/tcp, 0.0.0.0:9999->81/tcp, :::9999->81/tcp, 0.0.0.0:58888->82/tcp, :::58888->82/tcp
runnergo-zookeeper-1     registry.cn-beijing.aliyuncs.com/runnergo/zookeeper:latest         "/bin/sh -c '/usr/sb…"   zookeeper           31 seconds ago      Up 29 seconds       22/tcp, 2181/tcp, 2888/tcp, 3888/tcp

这个工具的部分组件很耗CPU

top - 09:34:54 up 36 min,  1 user,  load average: 2.88, 1.47, 1.62
Tasks: 184 total,   2 running, 181 sleeping,   0 stopped,   1 zombie
%Cpu(s): 42.2 us,  8.5 sy,  0.0 ni, 40.5 id,  0.0 wa,  0.0 hi,  8.8 si,  0.0 st
KiB Mem :  8154932 total,  4989536 free,  2124808 used,  1040588 buff/cache
KiB Swap:  4194300 total,  4194300 free,        0 used.  5773104 avail Mem 

   PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                                                                             
  5871 root      20   0 1310548  14176   5304 S 115.6  0.2   0:34.18 collector                                                                                                           
  5957 root      20   0 1935544 664364  11560 R 100.3  8.1   1:42.42 manage                                                                                                              
  4713 polkitd   20   0 1722784 208744   9872 S  85.7  2.6   1:35.88 mysqld                                                                                                              
  5445 root      20   0 4760496 358064  19576 S  19.6  4.4   0:12.71 java                                                                                                                
     9 root      20   0       0      0      0 S  10.3  0.0   1:09.08 rcu_sched                                                                                                           
   434 root      20   0       0      0      0 S   6.0  0.0   0:22.82 xfsaild/dm-0                                                                                                        
  4873 polkitd   20   0 1521764  89352  19104 S   6.0  1.1   0:03.57 mongod                                                                                                              
   735 root      20   0  273196   4892   3732 S   5.6  0.1   0:45.31 vmtoolsd                                                                                                            
  1411 root      20   0 1051588  45376  14688 S   4.3  0.6   0:42.49 containerd                                                                                                          
  4665 polkitd   20   0   52884  11616   2964 S   3.3  0.1   0:01.37 redis-server                                                                                                        
  1060 root      20   0  222740   7364   3872 S   3.0  0.1   0:05.24 rsyslogd                                                                                                            
  1427 root      20   0 1776960  76976  24448 S   2.7  0.9   0:42.81 dockerd                                                                                                             
  5246 root      20   0 3752456  93412  11644 S   2.3  1.1   0:01.92 java                  

四、界面展示

在登录页面注册个用户,然后直接登录即可。

【DockerCE】使用Docker安装运行性能测试工具-RunnerGo

五、组件及其开放端口

【DockerCE】使用Docker安装运行性能测试工具-RunnerGo参考:

https://www.runnergo.com/

https://github.com/Runner-Go-Team/RunnerGo/releases