一、SkyWalking-9.4.0 docker部署流程
- docker-compse.yml
sky-oap:image: apache/skywalking-oap-server:9.3.0container_name: ruoyi-sky-oapports:- "11800:11800"- "12800:12800"environment:JAVA_OPTS: -Xms1G -Xmx2G#记录数据的有效期,单位天SW_CORE_RECORD_DATA_TTL: 7#分析指标数据的有效期,单位天SW_CORE_METRICS_DATA_TTL: 7SW_STORAGE: elasticsearchSW_STORAGE_ES_CLUSTER_NODES: 192.168.1.8:9200TZ: Asia/Shanghai#network_mode: "host"sky-ui:image: apache/skywalking-ui:9.3.0container_name: ruoyi-sky-uiports:- "18080:18080"environment:SW_SERVER_PORT: 18080SW_OAP_ADDRESS: http://192.168.1.8:12800#SW_ZIPKIN_ADDRESS: http://oap:9412TZ: Asia/Shanghaidepends_on:- sky-oaplinks:- sky-oap#network_mode: "host"
- 因为要将数据存储在es,以下给出es docker-compose文件
version: '3.8'
services:elasticsearch:image: docker.elastic.co/elasticsearch/elasticsearch:7.17.6container_name: elasticsearchrestart: alwaysports:- 9200:9200- 9300:9300environment:- discovery.type=single-node- TZ=Asia/Shanghai- bootstrap.memory_lock=true- "ES_JAVA_OPTS=-Xms1024m -Xmx1024m"volumes:- /home/elasticsearch/data:/usr/share/elasticsearch/dataulimits:memlock:soft: -1hard: -1
- 如果OAP报如下错
oap | 2023-06-14 01:18:55,913 org.apache.skywalking.oap.server.core.storage.model.ModelInstaller 54 [main] INFO [] - table: ui_template does not exist
oap | 2023-06-14 01:18:55,960 org.apache.skywalking.oap.server.core.storage.model.ModelInstaller 54 [main] INFO [] - table: zipkin_span does not exist
oap | 2023-06-14 01:18:56,017 org.apache.skywalking.library.elasticsearch.client.TemplateClient 139 [armeria-eventloop-epoll-6-3] ERROR [] - [9.4.0-520d531] Failed to create / update index template sw_zipkin_span
oap | java.util.concurrent.CompletionException: java.lang.RuntimeException: {"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"composable template [sw_zipkin_span] template after composition is invalid"}],"type":"illegal_argument_exception","reason":"composable template [sw_zipkin_span] template after composition is invalid","caused_by":{"type":"illegal_argument_exception","reason":"invalid composite mappings for [sw_zipkin_span]","caused_by":{"type":"mapper_parsing_exception","reason":"Failed to parse mapping [_doc]: analyzer [oap_analyzer] has not been configured in mappings","caused_by":{"type":"illegal_argument_exception","reason":"analyzer [oap_analyzer] has not been configured in mappings"}}}},"status":400}
在官方issue中找到解答,由于挂载的es目录为原来8.7.0版本生成及采集的数据,导致es初始化数据失败
,需要删除原目录数据/home/elasticsearch/data或者重新指定文件目录即可。
二、集成RuoyiCloudPlus
- 下载java探针
这里使用最新8.16.0版本的java-gent客户端
,配置文件在config/agent.config,参考配置文档https://skywalking.apache.org/docs/skywalking-java/v8.16.0/en/setup/service-agent/java-agent/configurations/
- 普通的java文件,启动jar包配置命令如下
-javaagent:/home/skywalking/skywalking-agent/skywalking-agent.jar -Dskywalking.agent.service_name=test::服务名 -Dskywalking.collector.backend_service=192.168.24.22:11800
- 结合Dockerfile及容器docker-compose,制作微服务镜像
- Dockerfile
FROM anapsix/alpine-java:8_server-jre_unlimitedRUN mkdir -p /ruoyi/system/logs \/ruoyi/system/temp \/ruoyi/skywalking/agentWORKDIR /ruoyi/systemENV SERVER_PORT=9201EXPOSE ${SERVER_PORT}# 拷贝打包后的jar到容器内
ADD ./target/ruoyi-system.jar ./app.jarENTRYPOINT ["java", \"-Djava.security.egd=file:/dev/./urandom", \"-Dserver.port=${SERVER_PORT}", \"-Dskywalking.agent.service_name=ruoyi-system", \
#指定探针数据上报的网络地址"-Dskywalking.collector.backend_service=192.168.1.8:11800", \
#该句只是指定配置,真正的探针文件在部署服务时,在docker-compose中指定"-javaagent:/ruoyi/skywalking/agent/skywalking-agent.jar", \"-jar", "app.jar"]
- docker-compose
ruoyi-gateway:image: ruoyi/ruoyi-gateway:1.6.0container_name: ruoyi-gatewayenvironment:# 时区上海TZ: Asia/Shanghaiports:- "8080:8080"volumes:# 配置文件- /docker/ruoyi-gateway/logs/:/ruoyi/gateway/logs# 指定skywalking 探针位置- /docker/skywalking/agent/:/ruoyi/skywalking/agentprivileged: true#network_mode: "host"
- 启动gateway微服务模块后,发起请求,便可以在sky-ui中看到数据