CentOS系统下docker-compose安装SkyWalking – 记忆角落

CentOS系统下docker-compose安装SkyWalking

/ 0评 / 1

CentOS系统下docker-compose安装SkyWalking

基本环境

sysctl.conf 参数调整

#vi /etc/sysctl.conf
##开启内核转发
net.ipv4.ip_forward = 1
##ES参数
vm.max_map_count=262144

# sysctl -p

limits.conf 参数调整

# vi /etc/security/limits.conf
* soft nofile 65536
* hard nofile 65536
* soft nproc 65536
* hard nproc 65536
* hard memlock unlimited
* soft memlock unlimited

docker-compose.yml 文件准备

参考官网:https://github.com/apache/skywalking/tree/master/docker

version: '3.8'
services:
  elasticsearch:
    image: elasticsearch:7.9.0
    container_name: elasticsearch
    restart: always
    ports:
      - "9200:9200"
      - "9300:9300"
    healthcheck:
      test: [ "CMD-SHELL", "curl --silent --fail localhost:9200/_cluster/health || exit 1" ]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 10s
    environment:
      - discovery.type=single-node
      #  锁定物理内存地址,防止elasticsearch内存被交换出去,也就是避免es使用swap交换分区,频繁的交换,会导致IOPS变高
      - bootstrap.memory_lock=true
      - "ES_JAVA_OPTS=-Xms1024m -Xmx1024m"
      - TZ=Asia/Shanghai
    volumes:
      - ./elasticsearch/data:/usr/share/elasticsearch/data
      - ./elasticsearch/logs:/usr/share/elasticsearch/logs
    ulimits:
      memlock:
        soft: -1
        hard: -1

  oap:
    image: apache/skywalking-oap-server:8.9.1
    container_name: oap
    depends_on:
      elasticsearch:
        condition: service_healthy
    links:
      - elasticsearch
    restart: always
    ports:
      - "11800:11800"
      - "12800:12800"
    healthcheck:
      test: [ "CMD-SHELL", "/skywalking/bin/swctl ch" ]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 10s
    environment:
      # 指定存储方式
      SW_STORAGE: elasticsearch
      # 指定存储的地址
      SW_STORAGE_ES_CLUSTER_NODES: elasticsearch:9200
      SW_HEALTH_CHECKER: default
      SW_TELEMETRY: prometheus
      JAVA_OPTS: "-Xms2048m -Xmx2048m"
      TZ: Asia/Shanghai

  ui:
    image: apache/skywalking-ui:8.9.1
    container_name: ui
    depends_on:
      oap:
        condition: service_healthy
    links:
      - oap
    restart: always
    ports:
      - "8080:8080"
    environment:
      SW_OAP_ADDRESS: http://oap:12800
      TZ: Asia/Shanghai

运行docker-compose up -d

浏览器验证

访问网址 http://ip:8080/

java服务接入skywalking

因为现在新版skywalking已经没有自带agent了

下载JavaAgent:https://skywalking.apache.org/downloads/,根据需求下载

image-20221014174751276

宿主机方式运行

java -javaagent:/usr/local/src/skywalking-agent/skywalking-agent.jar
-Dskywalking.agent.service_name=test-demo
-Dskywalking.collector.backend_service=10.80.210.122:11800
-jar test-demojar &

docker方式运行

需要把下载下来的agent目录全部复制到docker容器,再启动命令加上对应命令即可

参考:https://skywalking.apache.org/zh/2020-04-19-skywalking-quick-start/

发表评论

您的电子邮箱地址不会被公开。