https://www.itsvse.com/thread-6173-1-1.html
elasticsearch-6.5.2.tar.gz
apache-skywalking-apm-incubating-6.0.0-GA.tar.gz
SkyWalking 是针对分布式系统的 APM 系统,也被称为分布式追踪系统
全自动探针监控,不需要修改应用程序代码。查看支持的中间件和组件库列表:https://github.com/apache/incubator-skywalking
支持手动探针监控, 提供了支持 OpenTracing 标准的SDK。覆盖范围扩大到 OpenTracing-Java 支持的组件。查看OpenTracing组件支持列表:https://github.com/opentracing-contrib/meta
自动监控和手动监控可以同时使用,使用手动监控弥补自动监控不支持的组件,甚至私有化组件。
纯 Java 后端分析程序,提供 RESTful 服务,可为其他语言探针提供分析能力。
高性能纯流式分析
下载JDK1.8
wget http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144-linux-x64.tar.gz #wget命令可能下载不了,自行想办法下载 |
解压JDK1.8
#解压到指定目录 tar -zxvf ./jdk-8u144-linux-x64.tar.gz -C /usr/local/ #最终结果/usr/local/jdk1.8.0_144 |
配置环境变量
#vim /etc/profile |
JAVA_HOME=/usr/local/jdk1.8.0_144 JRE_HOME=/usr/local/jdk1.8.0_144/jre PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin CLASSPATH=:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib export PATH=$PATH:$JAVA_HOME:$JRE_HOME:$CLASSPATH |
#wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.5.2.tar.gz |
解压安装包
#解压到指定目录 tar -zxvf ./elasticsearch-5.5.2.tar.gz -C /usr/local/ #最终结果/usr/local/elasticsearch-5.5.2 #改变权限 chown -R es:es /usr/local/elasticsearch-5.5.2/ |
编辑limits.conf配置文件, 添加类似如下内容:
vi /etc/security/limits.conf #添加如下内容: * soft nofile 65536 * hard nofile 131072 * soft nproc 2048 * hard nproc 4096 |
修改90-nproc.conf配置文件
vi /etc/security/limits.d/90-nproc.conf #修改如下内容: * soft nproc 1024 #修改为 * soft nproc 2048 |
修改配置sysctl.conf
vi /etc/sysctl.conf #添加下面配置: vm.max_map_count=655360 #并执行命令: sysctl -p |
直接运行elasticsearch
#创建elasticsearch用户 useradd elk #切换用户 su elk #进入目录 cd /usr/local/elasticsearch-5.5.2 #运行 ./bin/elasticsearch -d |
下载skywalking
#wget http://www-eu.apache.org/dist/incubator/skywalking/5.0.0-beta2/apache-skywalking-apm-incubating-5.0.0-beta2.tar.gz |
解压skywalking
tar -xf apache-skywalking-apm-incubating-5.0.0-beta2.tar.gz mv apache-skywalking-apm-incubating skywalking |
修改配置文件,将以下Localhost修改成本机IP地址,如果elasticsearch是分开安装,修改成elasticsearch本机ip
vim /root/skywalking/config/application.yml naming: jetty: #OS real network IP(binding required), for agent to find collector cluster host: localhost port: 10800 contextPath: / cache: # guava: caffeine: remote: gRPC: # OS real network IP(binding required), for collector nodes communicate with each other in cluster. collectorN --(gRPC) --> collectorM host:localhost port: 11800 agent_gRPC: gRPC: #OS real network IP(binding required), for agent to uplink data(trace/metrics) to collector. agent--(gRPC)--> collector host: localhost port: 11800 # Set these two setting to open ssl #sslCertChainFile: $path #sslPrivateKeyFile: $path
# Set your own token to active auth #authentication: xxxxxx agent_jetty: jetty: # OS real network IP(binding required), for agent to uplink data(trace/metrics) to collector through HTTP. agent--(HTTP)--> collector # SkyWalking native Java/.Net/node.js agents don't use this. # Open this for other implementor. host: localhost port: 12800 contextPath: / analysis_register: default: analysis_jvm: default: analysis_segment_parser: default: bufferFilePath: ../buffer/ bufferOffsetMaxFileSize: 10M bufferSegmentMaxFileSize: 500M bufferFileCleanWhenRestart: true ui: jetty: # Stay in `localhost` if UI starts up in default mode. # Change it to OS real network IP(binding required), if deploy collector in different machine. host:localhost port: 12800 contextPath: / storage: elasticsearch: clusterName: CollectorDBCluster clusterTransportSniffer: true clusterNodes:localhost:9300 indexShardsNumber: 2 indexReplicasNumber: 0 highPerformanceMode: true |
修改web控制信息,将127.0.0.1修改成本地真实ip
vim skywalking/webapp/webapp.yml
server: port: 8080
collector: path: /graphql ribbon: ReadTimeout: 10000 listOfServers:127.0.0.1:10800
security: user: admin: password: admin |
启动skywalking
cd skywalking/bin #启动Collector、WebUI ./startup.sh |
SkyWalking监控界面URL: http://127.0.0.1:8080/#/monitor/dashboard
部署探针
拷贝skywalking-agent目录到需要监控的节点服务器上,探针包含整个目录,请不要改变目录结构
+-- skywalking-agent +-- activations apm-toolkit-log4j-1.x-activation.jar apm-toolkit-log4j-2.x-activation.jar apm-toolkit-logback-1.x-activation.jar ... +-- config agent.config +-- plugins apm-dubbo-plugin.jar apm-feign-default-http-9.x.jar apm-httpClient-4.x-plugin.jar ..... skywalking-agent.jar |
修改agent配置文件,将127.0.0.1修改成skywalking服务器ip地址
vim /usr/local/agent/config/agent.config
# 当前的应用编码,最终会显示在webui上。 # 建议一个应用的多个实例,使用有相同的application_code。请使用英文 agent.application_code=Your_ApplicationName
# 每三秒采样的Trace数量 # 默认为负数,代表在保证不超过内存Buffer区的前提下,采集所有的Trace # agent.sample_n_per_3_secs=-1
# 设置需要忽略的请求地址 # 默认配置如下 # agent.ignore_suffix=.jpg,.jpeg,.js,.css,.png,.bmp,.gif,.ico,.mp3,.mp4,.html,.svg
# 探针调试开关,如果设置为true,探针会将所有操作字节码的类输出到/debugging目录下 # skywalking团队可能在调试,需要此文件 # agent.is_open_debugging_class = true
# 对应Collector的config/application.yml配置文件中 agent_server/jetty/port 配置内容 # 例如: # 单节点配置:SERVERS="127.0.0.1:8080" # 集群配置:SERVERS="10.2.45.126:8080,10.2.45.127:7600" collector.servers=127.0.0.1:10800
# 日志文件名称前缀 logging.file_name=skywalking-agent.log
# 日志文件最大大小 # 如果超过此大小,则会生成新文件。 # 默认为300M logging.max_file_size=314572800
# 日志级别,默认为DEBUG。 logging.level=DEBUG
|
如果是容器用到tomcat话,添加catalina.sh如下配置
# vim /root/test/bin/catalina.sh CATALINA_OPTS="$CATALINA_OPTS -javaagent:/usr/local/agent/skywalking-agent.jar -Dskywalking.agent.application_code=test" ; export CATALINA_OPTS |
如果一台服务器上跑多个tomcat实例, 只需修改-Dskywalking.agent.application_code=test(将这个值修改成应用名)
如果是jar包启动,添加 以下信息到启动脚本中
java -javaagent:/root/skywalking/agent/skywalking-agent.jar -Dskywalking.agent.application_code=test
如果没有启动脚本,直接在命令行中启动
java -javaagent:/root/skywalking/agent/skywalking-agent.jar -Dserver.port=8084 -Dskywalking.agent.application_code=test -jar test.jar &
-Dserver.port 应用端口
-Dskywalking.agent.application_code 监控时显示的应用名称,如有多个应用,根据自行应用程序修改
test.jar jar包名称
监控画面
安装参考上面的单机部署,以下仅演示配置及集群部署
#安装ElasticSearch索引数据库,提供数据存储及快速查询
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.6.10.tar.gz
tar -xf elasticsearch-5.6.10.tar.gz
mv elasticsearch-5.6.10 elasticsearch
#创建Skywalking数据及日志存储目录
cd elasticsearch/
mkdir data
mkdir log
cd config/
#配置ElasticSearch单机节点信息,date、logs目录使用绝对路径
cat >> elasticsearch.yml << EOF
cluster.name: CollectorDBCluster
node.name: node-1
path.data: /home/mon/apps/elasticsearch/data
path.logs: /home/mon/apps/elasticsearch/logs
network.host: 0.0.0.0
thread_pool.bulk.queue_size: 1000
http.port: 9200
discovery.zen.ping.unicast.hosts: ["10.20.30.123:9300", "10.20.30.124:9300","10.20.30.125:9300"]
discovery.zen.minimum_master_nodes: 2
EOF
#同步ElasticSearch到同集群其他机器
scp -r ./elasticsearch [email protected]:/home/mon/apps
scp -r ./elasticsearch [email protected]:/home/mon/apps
#开启防火墙端口
firewall-cmd --zone=public --add-port=9200/tcp --permanent
firewall-cmd --zone=public --add-port=9300/tcp --permanent
firewall-cmd --reload
#安装zookeeper注册发现中心
wget https://archive.apache.org/dist/zookeeper/zookeeper-3.4.10/zookeeper-3.4.10.tar.gz
tar -xf zookeeper-3.4.10.tar.gz
mv zookeeper-3.4.10 zookeeper
cd zookeeper/conf/
#写入Zookeeper集群配置文件,data目录使用绝对路径
cat > zoo.cfg < /home/mon/apps/zookeeper/tmp/myid
#分发安装包
#将配置好的zookeeper拷贝到其他节点
scp -r ./zookeeper [email protected]:/home/mon/apps
scp -r ./zookeeper [email protected]:/home/mon/apps
#注意:修改另外两台服务器对应/home/mon/apps/zookeeper/tmp/myid内容
#server.2
echo 2 > /home/mon/apps/zookeeper/tmp/myid
#server.3
echo 2 > /home/mon/apps/zookeeper/tmp/myid
#开放防火墙端口
firewall-cmd --zone=public --add-port=2181/tcp --permanent
firewall-cmd --zone=public --add-port=2888/tcp --permanent
firewall-cmd --zone=public --add-port=3888/tcp --permanent
firewall-cmd --reload
#启动集群,按server.1、server.2、server.3的顺序分别启动Zookeeper服务
cd /home/mon/apps/zookeeper/bin
./zkServer.sh start
#停止集群,分别停止Zookeeper服务
./zkServer.sh stop
#查询Zookeeper节点状态
./zkServer.sh status
#包括Collector收集器,Agent探针,WebUI响应界面
wget http://www-eu.apache.org/dist/incubator/skywalking/5.0.0-beta2/apache-skywalking-apm-incubating-5.0.0-beta2.tar.gz
tar -xf apache-skywalking-apm-incubating-5.0.0-beta2.tar.gz
mv apache-skywalking-apm-incubating skywalking
#配置Zookeeper、ElasticSearch集群
cd skywalking/config
find . -name 'application.yml' |grep admin |xargs sed -i 's/#cluster:/cluster:/g'
find . -name 'application.yml' |grep admin |xargs sed -i 's/# zookeeper:/ zookeeper:/g'
find . -name 'application.yml' |grep admin |xargs sed -i 's/# hostPort: localhost:2181/ hostPort: 10.20.30.123:2181,10.20.30.124:2181,10.20.30.125:2181/g'
find . -name 'application.yml' |grep admin |xargs sed -i 's/# sessionTimeout: 100000/ sessionTimeout: 100000/g'
find . -name 'application.yml' |grep admin |xargs sed -i 's/ host: localhost/ host: 0.0.0.0/g'
find . -name 'application.yml' |grep admin |xargs sed -i 's/ clusterNodes: localhost:9300/ clusterNodes: 10.20.30.123:9300,10.20.30.124:9300,10.20.30.125:9300/g'
#配置WebUI访问Collector集群
cd ../webapp
find . -name 'webapp.yml' |grep admin |xargs sed -i 's/ listOfServers: 127.0.0.1:10800/ listOfServers: 10.20.30.123:10800,10.20.30.124:10800,10.20.30.125:10800/g'
#配置WebUI端口号,可使用默认8080,以下仅做示例,根据实际需求修改
find . -name 'application.yml' |grep admin |xargs sed -i 's/ port: 8080/ port: 8081/g'
#开放防火墙端口
#8080为WebUI组件使用的端口号,可在webapp.yml中修改
firewall-cmd --zone=public --add-port=8080/tcp --permanent
firewall-cmd --zone=public --add-port=10800/tcp --permanent
firewall-cmd --zone=public --add-port=11800/tcp --permanent
firewall-cmd --zone=public --add-port=12800/tcp --permanent
firewall-cmd --reload
#启动Collector、WebUI,在集群机器上分别启动
cd ../bin
./startup.sh
#也可分别启动Collector和WebUI
./collectorService.sh
./webappService.sh
#配置SkyWalking集群
cd ../agent/config
find . -name 'application.yml' |grep admin |xargs sed -i 's/# collector.direct_servers=www.skywalking.service.io/collector.direct_servers=10.20.30.123:11800,10.20.30.124:11800,10.20.30.125:11800/g'
#分发Agent探针,在部署SkyWalking的机器上
cd skywalking
scp -r agent [email protected]:/home/mon/apps/
#探针启动方式参考上面单机模式部署
小礼物走一走,来简书关注我