环境信息
系统:CentOS7.6
安装docker
使用官方安装脚本自动安装
安装命令如下:
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
或者使用国内 daocloud 一键安装命令:
curl -sSL https://get.daocloud.io/docker | sh
手动安装
- 卸载旧版本
$ sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
- 使用yum进行安装
$ sudo yum install -y yum-utils \
device-mapper-persistent-data \
lvm2
- 设置国内镜像
$ sudo yum-config-manager \
--add-repo \
http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
- 安装 Docker Engine-Community
$ sudo yum install docker-ce docker-ce-cli containerd.io
- 启动docker
$ sudo systemctl start docker
安装docker-compose
可以从 Github 上下载它的二进制包来使用,最新发行的版本地址:https://github.com/docker/compose/releases。
或者执行命令:
curl -L "https://github.com/docker/compose/releases/download/v2.2.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
修改文件权限
chmod +x /usr/local/bin/docker-compose
创建软链接
ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
查看安装版本
docker-compose --version
当前安装版本
Docker Compose version v2.4.1
docker-compose安装skywalking
- 创建docker-compose.yml文件,内容如下
version: '3.8'
services:
es:
image: docker.elastic.co/elasticsearch/elasticsearch-oss:7.4.2
container_name: es
ports:
- "9200:9200"
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
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- "TZ=Asia/Shanghai"
ulimits:
memlock:
soft: -1
hard: -1
oap:
image: apache/skywalking-oap-server:8.9.1
container_name: oap
depends_on:
- es
links:
- es
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: es:9200
SW_HEALTH_CHECKER: default
TZ: Asia/Shanghai
SW_TELEMETRY: prometheus
JAVA_OPTS: "-Xms2048m -Xmx2048m"
ui:
image: apache/skywalking-ui:8.9.1
container_name: ui
depends_on:
- oap
links:
- oap
ports:
- "8080:8080"
environment:
SW_OAP_ADDRESS: http://oap:12800
TZ: Asia/Shanghai
再依次启动
docker-compose up -d es
docker-compose up -d oap
docker-compose up -d ui
关闭防火墙或者启用端口
firewall-cmd --zone=public --add-port=9200/tcp --permanent
firewall-cmd --zone=public --add-port=11800/tcp --permanent
firewall-cmd --zone=public --add-port=12800/tcp --permanent
firewall-cmd --zone=public --add-port=8002/tcp --permanent
firewall-cmd --reload
skywalking部署完成
配置agent,springboot启动服务器命令修改
在agent中 skywalking-agent/config/agent.config 修改以下配置项,可按需配置值
collector.backend_service=${SW_AGENT_COLLECTOR_BACKEND_SERVICES:127.0.0.1:11800}
agent.span_limit_per_segment=${SW_AGENT_SPAN_LIMIT:1000}
java jar包启动,命令中添加agent参数
java -javaagent:/opt/skywalking-agent/skywalking-agent.jar -DSW_AGENT_NAME=Your_Application_name -jar application.jar
至此,配置完成;
注:-DSW_AGENT_NAME 配置的值可以按 [groupName]::[applicaitonName] 配置,拓扑生成的时候会按分组进行处理。