部署data-streaming集群

准备好环境变量文件、compose 文件,三台机器部署一样

环境变量文件 .env

  1. vim .env #参考ms的.env文件进行修改
  2. MS_KAFKA_TOPIC=JMETER_METRICS
  3. MS_MYSQL_HOST=10.1.240.110 #修改MS的数据库
  4. MS_KAFKA_LOG_TOPIC=JMETER_LOGS
  5. MS_TAG=v1.9.3
  6. MS_JMETER_DATA_PATH=metersphere/data/jmeter
  7. MS_BASE=/opt
  8. MS_KAFKA_TEST_TOPIC=LOAD_TESTS
  9. MS_MYSQL_USER=root
  10. MS_EXTERNAL_MYSQL=true
  11. MS_PREFIX=registry.cn-qingdao.aliyuncs.com/metersphere
  12. MS_MYSQL_DB=metersphere
  13. MS_MYSQL_PASSWORD=Password123@mysql
  14. MS_JMETER_TAG=5.4.1-ms3-jdk8
  15. MS_MYSQL_PORT=3307
  16. MS_KAFKA_BOOTSTRAP_SERVERS=10.1.240.154:9092,10.1.240.155:9092,10.1.240.156:9092 #新加

docker-compose-base.yml

  1. vim docker-compose-base.yml #拷贝ms服务器的docker-compose-base.yml
  2. version: "2.1"
  3. volumes:
  4. ms-conf:
  5. driver_opts:
  6. type: none
  7. device: ${MS_BASE}/metersphere/conf
  8. o: bind
  9. ms-logs:
  10. driver_opts:
  11. type: none
  12. device: ${MS_BASE}/metersphere/logs
  13. o: bind
  14. ms-data:
  15. driver_opts:
  16. type: none
  17. device: ${MS_BASE}/metersphere/data
  18. o: bind
  19. networks:
  20. ms-network:
  21. driver: bridge
  22. ipam:
  23. driver: default
  24. config:
  25. - subnet: ${MS_DOCKER_SUBNET}

docker-compose-ds.yml

  1. vim docker-compose-ds.yml #新加ds yaml文件
  2. version: "2.1"
  3. services:
  4. ms-data-streaming:
  5. image: ${MS_IMAGE_PREFIX}/ms-data-streaming:${MS_IMAGE_TAG}
  6. container_name: ms-data-streaming
  7. environment:
  8. HOST_HOSTNAME: $HOSTNAME
  9. SPRING_DATASOURCE_URL: jdbc:mysql://${MS_MYSQL_HOST}:${MS_MYSQL_PORT}/${MS_MYSQL_DB}?autoReconnect=false&useUnicode=true&characterEncoding=UTF-8&characterSetResults=UTF-8&zeroDateTimeBehavior=convertToNull&allowPublicKeyRetrieval=true&useSSL=false
  10. SPRING_DATASOURCE_USERNAME: ${MS_MYSQL_USER}
  11. SPRING_DATASOURCE_PASSWORD: ${MS_MYSQL_PASSWORD}
  12. KAFKA_PARTITIONS: 4
  13. KAFKA_REPLICAS: 1
  14. KAFKA_TOPIC: ${MS_KAFKA_TOPIC}
  15. KAFKA_LOG_TOPIC: ${MS_KAFKA_LOG_TOPIC}
  16. KAFKA_TEST_TOPIC: ${MS_KAFKA_TEST_TOPIC}
  17. KAFKA_REPORT_TOPIC: ${MS_KAFKA_REPORT_TOPIC}
  18. KAFKA_BOOTSTRAP-SERVERS: ${MS_KAFKA_HOST}:${MS_KAFKA_PORT}
  19. FORMAT_MESSAGES_PATTERN_DISABLE_LOOKUPS: 'true'
  20. healthcheck:
  21. test: ["CMD", "nc", "-zv", "localhost", "8084"]
  22. interval: 6s
  23. timeout: 10s
  24. retries: 20
  25. restart: always
  26. volumes:
  27. - ./conf/metersphere.properties:/opt/metersphere/conf/metersphere.properties
  28. - ${MS_BASE}/metersphere/logs/data-streaming:/opt/metersphere/logs/data-streaming
  29. networks:
  30. - ms-network

启动data-streaming,执行命令:

  1. source .env
  2. docker-compose -f docker-compose-base.yml -f docker-compose-ds.yml up -d