version: '3.3' services: skywalking-oap: image: apache/skywalking-oap-server:9.3.0 container_name: skywalking-oap restart: always ports: - 11800:11800 - 12800:12800 environment: SW_CORE_RECORD_DATA_TTL: 7 #记录数据的有效期,单位天 SW_CORE_METRICS_DATA_TTL: 7 #分析指标数据的有效期,单位天 SW_ENABLE_UPDATE_UI_TEMPLATE: "true" # 开启dashboard编辑修改功能 SW_HEALTH_CHECKER: default TZ: Asia/Shanghai SW_STORAGE: elasticsearch SW_NAMESPACE:es集群名称 JAVA_OPTS: "-Xms2048m -Xmx2048m" #SW_STORAGE: elasticsearch7 SW_STORAGE_ES_CLUSTER_NODES: es01:9200,es02:9200,es03:9200 volumes: - /apps/skywalking/config:/skywalking/config networks: - skywalking skywalking-ui: image: apache/skywalking-ui:9.3.0 #image: apache/skywalking-ui:9.0.0 container_name: skywalking-ui restart: always depends_on: - skywalking-oap links: - skywalking-oap ports: - 8980:8080 environment: TZ: Asia/Shanghai SW_HEALTH_CHECKER: default SW_OAP_ADDRESS: http://skywalking-oap:12800 #指向oap networks: - skywalking es01: image: docker.elastic.co/elasticsearch/elasticsearch:7.10.1 container_name: es01 environment: - node.name=es01 - cluster.name=es-docker-cluster - discovery.seed_hosts=es02,es03 - cluster.initial_master_nodes=es01,es02,es03 - bootstrap.memory_lock=true - "ES_JAVA_OPTS=-Xms512m -Xmx512m" ulimits: memlock: soft: -1 hard: -1 volumes: - ./es01/data:/usr/share/elasticsearch/data ports: - 9200:9200 networks: - skywalking es02: image: docker.elastic.co/elasticsearch/elasticsearch:7.10.1 container_name: es02 environment: - node.name=es02 - cluster.name=es-docker-cluster - discovery.seed_hosts=es01,es03 - cluster.initial_master_nodes=es01,es02,es03 - bootstrap.memory_lock=true - "ES_JAVA_OPTS=-Xms512m -Xmx512m" ulimits: memlock: soft: -1 hard: -1 volumes: - ./es02/data:/usr/share/elasticsearch/data networks: - skywalking es03: image: docker.elastic.co/elasticsearch/elasticsearch:7.10.1 container_name: es03 environment: - node.name=es03 - cluster.name=es-docker-cluster - discovery.seed_hosts=es01,es02 - cluster.initial_master_nodes=es01,es02,es03 - bootstrap.memory_lock=true - "ES_JAVA_OPTS=-Xms512m -Xmx512m" ulimits: memlock: soft: -1 hard: -1 volumes: - ./es03/data:/usr/share/elasticsearch/data networks: - skywalking networks: skywalking: driver: bridge
es作为数据存储,所以在es集群里需要挂载数据存储,另外需要注意的是网络,因为使用了容器名称,需要docker网络解析。创建成功后就需要在客户端配置,这里使用java服务启动时增加启动参数。
JAVA_START="java \${JAVA_OPTS} -DJM.LOG.PATH=/apps/works/logs -DJM.SNAPSHOT.PATH=/apps/works/conf -javaagent:/opt/skywalking-agent/skywalking-agent.jar -Dskywalking.agent.service_name=${K8S_NAMESPACE}::${item} -Dskywalking.collector.backend_service=skywalking.skywalking:11800 -Dlog4j2.formatMsgNoLookups=true -Dfile.encoding=UTF-8 -Duser.timezone=Asia/Shanghai -jar /apps/works/server/${list[1]}-server.jar"
这里需要注意变量K8S_NAMESPACE是组名,item是服务名称,避免同名服务,另外需要把客户端放到可执行的节点上,避免找不到客户端启动失败。
整个链路追踪部署完成。没有了看些其他的吧。
您可以选择一种方式赞助本站
支付宝扫一扫赞助
微信钱包扫描赞助
赏