前言

首先原项目中使用的SkyWalking的版本是8.9.0,而自9.x版本之后SkyWalking的功能及UI都发生了较大的变化,所以决定升级到最新的9.4.0版本,同时本文描述尽量简单。

部署流程

镜像准备

docker部署前需要准备镜像,一种自己制作镜像,另外一种使用官方或别人制作好的镜像,这里使用第二种方式方式;数据存储依然使用elasticsearch

1、自己制作镜像

官网下载apache-skywalking-apm-9.4.0.tar.gz,下载慢可以使用国内地址https://mirrors.tuna.tsinghua.edu.cn/apache/skywalking/(推荐),同时官网github已经提供镜像制作文件https://github.com/apache/skywalking/tree/master/docker,其中.env配置了elasticsearch、oap、ui的镜像版本,自己改动即可,使用Dockerfile制作oap及ui镜像时,注意修改Dockerfile中的一些ARG参数

配置docker-compose.yml

1、Elasticsearch

version: '3.8'
services:
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.17.6
    container_name: elasticsearch
    restart: always
    ports:
      - 9200:9200
      - 9300:9300
    environment:
      - discovery.type=single-node
      - TZ=Asia/Shanghai
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms1024m -Xmx1024m"
    volumes:
      - /home/elasticsearch/data:/usr/share/elasticsearch/data
    ulimits:
      memlock:
        soft: -1
        hard: -1

2、OAP、UI

version: '3.8'
services:
  oap:
    image: docker.io/apache/skywalking-oap-server:9.4.0
    container_name: oap
    restart: always
    ports:
      - 11800:11800
      - 12800:12800
    environment:
      SW_CORE_RECORD_DATA_TTL: 15
      SW_CORE_METRICS_DATA_TTL: 15
      SW_STORAGE: elasticsearch
      SW_STORAGE_ES_CLUSTER_NODES: elasticsearch:9200
      SW_ENABLE_UPDATE_UI_TEMPLATE: true
      TZ: Asia/Shanghai
      JAVA_OPTS: "-Xms2048m -Xmx2048m"
  ui:
    image: docker.io/apache/skywalking-ui:9.4.0
    container_name: ui
    depends_on:
      - oap
    links:
      - oap
    restart: always
    ports:
      - 8080:8080
    environment:
      SW_OAP_ADDRESS: http://oap:12800
      SW_ZIPKIN_ADDRESS: http://oap:9412
启动及一些坑

使用命令依次启动

docker compose up -d

1、启动es报错

java.nio.file.AccessDeniedException: /usr/share/elasticsearch/data/nodes......

由于挂载的目录没有读写权限,赋予它权限即可,命令如下:

chmod 777 /home/elasticsearch/data

2、启动OAP报如下错

pthread_create failed (EPERM) for attributes: stacksize: 1024k, guardsize: 4k, detached.

需要升级docker的版本https://docs.docker.com/engine/install/centos/,这里使用的版本是24.0.2

3、启动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或者重新指定文件目录即可。

客户端配置

这里使用最新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/,启动jar包配置命令如下

-javaagent:/home/skywalking/skywalking-agent/skywalking-agent.jar -Dskywalking.agent.service_name=test::服务名 -Dskywalking.collector.backend_service=192.168.24.22:11800

身未动,心已远。

把一件事做到极致就是天分!

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐