小白学习centos7安装skywalking

环境版本

  • centos: 7
  • skywalking: 9.0.0
  • skywalking-java-agent: 8.10.0

安装

1. 安装Elasticsearch

参考 小白学习centos7部署ELK(一):搭建ELK

2. 下载skywalking

下载好skywalking,将资源上传到服务器

3. 将skywalking解压到指定目录

shell 复制代码
cd /home/download

tar -zxvf apache-skywalking-apm-9.0.0.tar.gz -C /opt

4. 修改 OAP 配置文件 /opt/apache-skywalking-apm-bin/config/application.yml

shell 复制代码
vi /opt/apache-skywalking-apm-bin/config/application.yml

通过storage.selector配置项来设置具体使用的存储器。修改内容如下:

5. 启动 SkyWalking OAP 服务

shell 复制代码
/opt/apache-skywalking-apm-bin/bin/oapService.sh

是否真正 启动成功,胖友打开 logs/skywalking-oap-server.log 日志文件,查看是否有错误日志。 首次启动时,因为 SkyWalking OAP 会创建 Elasticsearch 的索引,所以会"疯狂"的打印日志。 最终,我们看到如下日志,基本可以代表 SkyWalking OAP 服务启动成功:

log 复制代码
2022-04-17 00:41:53,692 - org.apache.skywalking.oap.server.starter.OAPServerBootstrap - 53 [main] INFO [] - Version of OAP: 9.0.0-89644fe (20220217220813)

6. 安装SkyWalking UI

  • 修改/opt/apache-skywalking-apm-bin/webapp/webapp.yml,内容如下:
vi 复制代码
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

server:
  port: 6395

spring:
  cloud:
    gateway:
      routes:
        - id: oap-route
          uri: lb://oap-service
          predicates:
            - Path=/graphql/**
    discovery:
      client:
        simple:
          instances:
            oap-service:
              - uri: http://127.0.0.1:12800
            # - uri: http://<oap-host-1>:<oap-port1>
            # - uri: http://<oap-host-2>:<oap-port2>

  mvc:
    throw-exception-if-no-handler-found: true

  web:
    resources:
      add-mappings: true

management:
  server:
    base-path: /manage

【可选】如果想要修改 SkyWalking UI 服务的参数,可以编辑 webapp/webapp.yml 配置文件。例如说:

  • server.port :SkyWalking UI 服务端口。默认的端口号为8080,修改为6395

  • spring.cloud.discovery.client.simple.instances.oap-service :SkyWalking OAP 服务地址数组。因为 SkyWalking UI 界面的数据,是通过请求 SkyWalking OAP 服务来获得的。

  • 启动SkyWalking UI 服务

shell 复制代码
bin/webappService.sh
  • 访问 UI 界面 ,浏览器输入ip:port

7. 开机自启动

  • 编写oap的停止脚本
shell 复制代码
vi /opt/apache-skywalking-apm-bin/bin/oapShutdown.sh

内容如下:

vi 复制代码
#!/bin/bash

# Stop SkyWalking-oap 9.0.0 by killing the process

PID=$(ps aux | grep skywalking-oap | grep -v grep | awk '{print $2}')

if [ -n "$PID" ]; then
    sudo kill $PID
    echo "SkyWalking-oap stopped successfully."
else
    echo "SkyWalking-oap is not running."
fi
  • 编写UI的停止脚本
shell 复制代码
vi /opt/apache-skywalking-apm-bin/bin/webappShutdown.sh

内容如下:

vi 复制代码
#!/bin/bash

# Stop SkyWalking 9.0.0 by killing the process
PID=$(ps aux | grep skywalking-webapp | grep -v grep | awk '{print $2}')

if [ -n "$PID" ]; then
    sudo kill $PID
    echo "SkyWalking-ui stopped successfully."
else
    echo "SkyWalking-ui is not running."
fi
  • 编写oapservice
shell 复制代码
vi /etc/systemd/system/skywalking-oap.service

内容如下:

vi 复制代码
[Unit]
Description=skywalking oap
After=syslog.target network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
User=root
Group=root
Environment="JAVA_HOME=/opt/jdk-11"
ExecStart=/opt/apache-skywalking-apm-bin/bin/oapService.sh
ExecStop=/opt/apache-skywalking-apm-bin/bin/oapShutdown.sh
Restart=always
PrivateTmp=true
LimitNOFILE=65536
WorkingDirectory=/opt/apache-skywalking-apm-bin/bin
  • 编写UIservice
shell 复制代码
cat /etc/systemd/system/skywalking-ui.service

内容如下:

vi 复制代码
[Unit]
Description=skywalking
After=network.target

[Service]
Type=forking
User=root
Environment="JAVA_HOME=/opt/jdk-11"
ExecStart=/opt/apache-skywalking-apm-bin/bin/webappService.sh
ExecStop=/opt/apache-skywalking-apm-bin/bin/webappShutdown.sh
PrivateTmp=true

[Install]
WantedBy=multi-user.target
  • 启动和停止oapUI
shell 复制代码
systemctl start skywalking-oap
systemctl start skywalking-ui

systemctl stop skywalking-oap
systemctl stop skywalking-ui
  • 设置自启动
shell 复制代码
systemctl enable skywalking-oap
systemctl enable skywalking-ui

使用SkyWalking Java Agent【Shell】

1. 服务器上部署

shell 复制代码
vi /etc/profile

添加如下内容:

vi 复制代码
# SkyWalking Agent 配置 

# 配置 Agent 名字。一般来说,我们直接使用 Spring Boot 项目的 `spring.application.name` 。 
export SW_AGENT_NAME=demo-application 

# 配置 Collector 地址。 
export SW_AGENT_COLLECTOR_BACKEND_SERVICES=127.0.0.1:11800 

# 配置链路的最大 Span 数量。一般情况下,不需要配置,默认为 300 。主要考虑,有些新上 SkyWalking Agent 的项目,代码可能比较糟糕。 
export SW_AGENT_SPAN_LIMIT=2000 

# SkyWalking Agent jar 地址。 
export JAVA_AGENT=-javaagent:/opt/skywalking-agent/skywalking-agent.jar

更多的变量,可以在 /Users/yunai/skywalking/skywalking-agent/config/agent.config 查看。要注意,可能有些变量是被注释掉的,例如说 SW_AGENT_SPAN_LIMIT 对应的 agent.span_limit_per_segment

  • 使变量生效
shell 复制代码
source /etc/profile

2. idea部署

参考下图配置: 运行springboot项目,查看skywalking如下图:

参考

相关推荐
IT利刃出鞘几秒前
SecureCRT--使用sftp上传和下载文件
linux·运维·服务器
WolvenSec2 小时前
网络基础:EIGRP
运维·网络·安全·智能路由器
踩着阴暗的自己向上爬3 小时前
Day05-04-持续集成总结
linux·运维·ci/cd
TiDB_PingCAP4 小时前
国产化新标杆:TiDB 助力广发银行新一代总账系统投产上线
运维·数据库·开源·tidb
qyhua4 小时前
Linux内网端口转公网端口映射
linux·运维·服务器
coisini.cn5 小时前
基于CentOS Stream 9平台搭建MinIO以及开机自启
运维·minio·centos stream 9
Python私教6 小时前
docker部署onlyoffice,开启JWT权限校验Token
运维·docker·容器
Ramboooooooo7 小时前
Nginx Lua Waf 插件一键部署
运维·nginx·lua·waf·lua waf·nginx waf
掘根8 小时前
【Linux】压缩命令——gzip,bzip2,xz
大数据·linux·运维