首先SkyWalking主要需要oapService、webApp、Elasticsearch(可选存储)三个,接下来讲一下这三个的安装步骤,安装过程中出现了一些细小的配置错误,导致用了快两天才弄好,麻木了(主要是不同版本有差异性)。
版本及对应下载:
名称 | 版本 | 下载地址(个人存放地址,不稳定) |
---|---|---|
SkyWalking | 8.5.0 | apache-skywalking-apm-9.5.0.tar.gz |
SkyWalking-agent | 8.16.0 | apache-skywalking-java-agent-8.16.0.tgz |
Elasticsearch | 8.5.3 | elasticsearch-8.5.3-linux-x86_64.tar |
解压文件:
# 创建存储目录
mkdir -p /opt/skywalking /opt/elasticsearch
# 解压压缩包
tar -xvf apache-skywalking-apm-9.5.0.tar.gz
tar -xvf apache-skywalking-java-agent-8.16.0.tgz
tar -xvf elasticsearch-8.5.3-linux-x86_64.tar
# 移动到指定位置
mv apache-skywalking-apm /opt/skywalking
mv apache-skywalking-java-agent /opt/skywalking
mv elasticsearch-8.5.3 /opt/elasticsearch
修改配置文件:
# 设置不需要ce认证,可以根据场景选择,这里我选择取消
# xpack.security.enabled: true
xpack.security.enabled: false
添加用户:
# 添加用户
adduser elasticsearch
# 设置文件权限
chown -R elasticsearch:elasticsearch /opt/elasticsearch
运行:
# 设置后台运行
sh elasticsearch -c '/opt/elasticsearch/elasticsearch-8.5.3/bin/elasticsearch -d'
第一次运行,会显示:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✅ Elasticsearch security features have been automatically configured!
✅ Authentication is enabled and cluster connections are encrypted.
ℹ️ Password for the elastic user (reset with `bin/elasticsearch-reset-password -u elastic`):
aaaaa*
ℹ️ HTTP CA certificate SHA-256 fingerprint:
asdfasdfasdfasdfasdvcdxvsdfhfgfghsdfgvadfvad
ℹ️ Configure Kibana to use this cluster:
• Run Kibana and click the configuration link in the terminal when Kibana starts.
• Copy the following enrollment token and paste it into Kibana in your browser (valid for the next 30 minutes):
eyJ2ZXIiOiI4LjUuMyIsImasdfasdfasdfsdvjadfkvajlvjladfjvdfvjadlfjvadifQ==
ℹ️ Configure other nodes to join this cluster:
• On this node:
⁃ Create an enrollment token with `bin/elasticsearch-create-enrollment-token -s node`.
⁃ Uncomment the transport.host setting at the end of config/elasticsearch.yml.
⁃ Restart Elasticsearch.
• On other nodes:
⁃ Start Elasticsearch with `bin/elasticsearch --enrollment-token `, using the enrollment token that you generated.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
注意:这里的aaaaa*
位置就是elastic用户的初始密码。
(可选项):
vim /usr/lib/systemd/system/elasticsearch.service
# 服务文件内容:
[Unit]
Description=elasticsearch service
After=syslog.target network.target rc-local.service
[Service]
Type=forking
User=elasticsearch
Group=elasticsearch
ExecStart=/bin/bash -c "/opt/elasticsearch/elasticsearch-8.5.3/bin/elasticsearch > /opt/elasticsearch/elasticsearch-8.5.3/logs/startup.log &"
ExecReload=/bin/sh -c "/bin/kill -d HUP $MAINPID"
ExecStop=/bin/sh -c "/bin/kill -s TERM $MAINPID"
SuccessExitStatus=143
[Install]
WantedBy=multi-user.target
# 杀死正在运行Elasticsearch程序
ps -ef | grep elasticsearch
# 杀死查询到的pid,xxx填写是ps -ef查到的内容
kill xxx
# 配置服务
systemctl daemon-reload
systemctl restart elasticsearch.service
systemctl enable elasticsearch.service
# 查询服务状态
systemctl status elasticsearch.service
Elasticsearch修改密码有两种,第一种是用http请求的方式,第二种是使用bin
目录下的可执行文件操作,具体的可以搜下相关文章
修改oap服务配置文件:
# 编辑配置application.yml文件
vim /opt/skywalking/apache-skywalking-apm-bin/config/application.yml
storage:
selector: ${SW_STORAGE:elasticsearch} # 选择ES存储
elasticsearch:
namespace: ${SW_NAMESPACE:"skywalking-index"} # 命名空间
#namespace: ${SW_NAMESPACE:"elasticsearch"}
clusterNodes: ${SW_STORAGE_ES_CLUSTER_NODES:localhost:9200} # 节点地址,多个用,逗号间隔
protocol: ${SW_STORAGE_ES_HTTP_PROTOCOL:"http"}
connectTimeout: ${SW_STORAGE_ES_CONNECT_TIMEOUT:3000}
socketTimeout: ${SW_STORAGE_ES_SOCKET_TIMEOUT:30000}
responseTimeout: ${SW_STORAGE_ES_RESPONSE_TIMEOUT:15000}
numHttpClientThread: ${SW_STORAGE_ES_NUM_HTTP_CLIENT_THREAD:0}
user: ${SW_ES_USER:"elastic"} # 账号
password: ${SW_ES_PASSWORD:"76B6UvSrcp1N5dX3nuq*"} # 密码
更改安装好的ES信息:storage.selector
存储方式使用elasticsearch
、storage.elasticsearch.namespace
命名空间根据个人喜好填写、storage.elasticsearch.clusterNodes
ES集群节点地址、storage.elasticsearch.user
ES账号、storage.elasticsearch.password
ES密码。
修改ui配置文件:
# 编辑配置application.yml文件
vim /opt/skywalking/apache-skywalking-apm-bin/wabapp/application.yml
修改内容:
# 避免冲突,将默认的8080修改为12880
serverPort: ${SW_SERVER_PORT:-12880}
运行服务:
# 单独运行oap服务
/opt/skywalking/apache-skywalking-apm-bin/bin/oapService.sh
# 单独运行webapp(UI)
/opt/skywalking/apache-skywalking-apm-bin/bin/webappService.sh
# 直接运行等于运行oap服务与webapp服务
/opt/skywalking/apache-skywalking-apm-bin/bin/startup.sh
查看日志是否运行成功:
oap服务日志位置/opt/skywalking/apache-skywalking-apm-bin/logs/skywalking-oap-server.log
、webapp服务日志位置/opt/skywalking/apache-skywalking-apm-bin/logs/skywalking-webapp.log
打开ui地址:http://192.168.254.130:12880就会出现安装好后的界面啦(注意:这里192.168.254.130是我安装的服务器地址,12880是webapp配置文件中配置的端口)。
/opt/skywalking/skywalking-agent/skywalking-agent.jar是探针的jar包,使用java -jar
运行jar包时添加参数-javaagent:/opt/skywalking/skywalking-agent/skywalking-agent.jar=agent.service_name=OS_Gateway,collector.backend_service=192.168.1.80:11800
,例:
nohup java -Xms8G -Xmx8G -XX:MetaspaceSize=512M -XX:MaxNewSize=512m -XX:MaxMetaspaceSize=1G -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=heapdump.hprof -XX:+PrintGCDetails -Xloggc:loggc-apic.log -javaagent:/opt/skywalking/skywalking-agent/skywalking-agent.jar=agent.service_name=OS_Gateway,collector.backend_service=192.168.1.80:11800 -jar ${jar_name} >> ${log_name} 2>&1 &