本文小编为大家详细介绍“skywalking在docker中怎么应用”,内容详细,步骤清晰,细节处理妥当,希望这篇“skywalking在docker中怎么应用”文章能帮助大家解决疑惑,下面跟着小编的思路慢慢深入,一起来学习新知识吧。
准备工作
下载源码包,下面会用到agent
https://archive.apache.org/dist/skywalking/6.6.0/apache-skywalking-apm-6.6.0.tar.gz
拉取镜像
docker pull elasticsearch:7.5.1 docker pull apache/skywalking-oap-server:6.6.0-es7 docker pull apache/skywalking-ui:6.6.0
安装elasticsearch
修改系统参数
vi /etc/sysctl.conf vm.max_map_count=262144 #调整参数 sysctl -p #刷新参数
启动elasticsearch
docker run -d --name=es7 -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" elasticsearch:7.5.1
创建持久化目录 并拷贝数据
mkdir -p /data/elasticsearch docker cp es7:/usr/share/elasticsearch/data /data/elasticsearch/ docker cp es7:/usr/share/elasticsearch/logs /data/elasticsearch/ docker rm -f es7
docker-compose编排部署es,skywalking
创建编排文件
cd /data && touch docker-compose.yml tar -zxvf apache-skywalking-apm-6.6.0.tar.gz #解压源码以便后续使用agent
编辑编排文件
version: '3' networks: cq-data-security: ##我这里选择了已有网卡,与我java项目网卡一致可以容器之间相互通信,具体需求看自己 external: true services: es7: image: elasticsearch:7.5.1 container_name: es7 expose: - 9200 - 9300 restart: always volumes: - /data/elasticsearch/data:/usr/share/elasticsearch/data - /data/elasticsearch/logs:/usr/share/elasticsearch/logs environment: - TZ=Asia/Shanghai - LANG=en_US.UTF-8 - discovery.type=single-node networks: cq-data-security: ipv4_address: 172.62.0.51 skywalking-oap-server: image: apache/skywalking-oap-server:6.6.0-es7 container_name: skywalking-oap-server expose: - 12800 - 11800 privileged: true restart: always environment: - TZ=Asia/Shanghai - LANG=en_US.UTF-8 - SW_STORAGE=elasticsearch - SW_STORAGE_ES_CLUSTER_NODES=172.62.0.51:9200 networks: cq-data-security: ipv4_address: 172.62.0.52 skywalking-ui: image: apache/skywalking-ui:6.6.0 container_name: skywalking-ui ports: - 28080:8080 privileged: true restart: always environment: - SW_OAP_ADDRESS=172.62.0.52:12800 networks: cq-data-security: ipv4_address: 172.62.0.53
docker-compose up -d 直接启动即可
访问localhost:28080 ui访问
agent部署
cd /data cp -r apache-skywalking-apm-bin/agent /你的项目目录/dockerfile所在目录
#编辑dockerfile将以下参数加入dockerfile RUN mkdir /root/agent COPY ./agent /root/agent
#修改java应用启动参数
java -javaagent:/root/agent/skywalking-agent.jar=agent.service_name=group_module -Dskywalking.collector.backend_service=172.62.0.52:11800 -jar /root/group-module-1.0-SNAPSHOT.jar --server.port=8890
至此客户端和服务端部署完成,可以打开ui界面进行访问