skywalking 实现收集基于虚拟机环境 dubbo微服务链路跟踪案例

  安装skywalking java agent

  下载链接:https://archive.apache.org/dist/skywalking/java-agent/

 

  dubbo-provider和dubbo-client节点都安装并配置skywalking java agent

  dubbo-provider安装配置skywalking java agent

[root@server1 local]# tar xf apache-skywalking-java-agent-8.8.0.tgz

[root@server1 local]# cd skywalking-agent/
[root@server1 skywalking-agent]# cd config/
[root@server1 config]# vim agent.config
# The agent namespace
agent.namespace=${SW_AGENT_NAMESPACE:java}  #自定义namespace,类似于项目名称

# The service name in UI
agent.service_name=${SW_AGENT_NAME:dubbo}  #自定义service 名称,类似于具体某个微服务的服务名称

# Backend service addresses.
collector.backend_service=${SW_AGENT_COLLECTOR_BACKEND_SERVICES:192.168.100.90:11800}  #指定skywalking地址:gRPC数据端口

 

  dubbo-client节点重复以上操作,修改agent.service_name为dubbo1,其他配置与duboo-server保持一致

 

  安装zookeeper

  官网下载地址:

  https://zookeeper.apache.org/releases.html

 

 

  安装JDK1.8环境

[root@zookeeper1 ~]# java -version
java version "1.8.0_191"
Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)

 

  部署zookeeper单实例

[root@zookeeper1 bin]# vim /etc/profile
export ZOOKEEPER_HOME=/usr/local/zookeeper-3.5.10
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$ZOOKEEPER_HOME/bin:$PATH

[root@zookeeper1 local]# tar xf apache-zookeeper-3.5.10-bin.tar.gz
[root@zookeeper1 local]# mv apache-zookeeper-3.5.10-bin zookeeper-3.5.10
[root@zookeeper1 local]# cd zookeeper-3.5.10/
[root@zookeeper1 zookeeper-3.5.10]# mkdir data
[root@zookeeper1 bin]# cd ../conf/
[root@zookeeper1 conf]# cp zoo_sample.cfg zoo.cfg
[root@zookeeper1 conf]# vim zoo.cfg
dataDir=/usr/local/zookeeper-3.5.10/data
[root@zookeeper1 bin]# zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper-3.5.10/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED

[root@zookeeper1 bin]# lsof -i:2181
COMMAND  PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
java    3100 root   52u  IPv6  31864      0t0  TCP *:eforward (LISTEN)

 

  安装dubbo微服务

  安装dubbo-provider

  配置java8环境

[root@server1 jdk1.8.0_191]# java -version
java version "1.8.0_191"
Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)

 

  上传dubbo-provider到服务器并修改配置连接zookeeper

[root@server1 local]# mkdir dubbo-provider
[root@server1 dubbo-provider]# vim config.properties
dubbo.registry=zookeeper://192.168.100.101:2181
dubbo.port=20880

 

  启动dubbo-provider,并指定skywalking java agent链路追踪

[root@server1 dubbo-provider]# java -javaagent:/usr/local/skywalking-agent/skywalking-agent.jar -jar dubbo-server.jar 

 

  前台启动无误后,放入后台启动

[root@server1 dubbo-provider]# cat start.sh 
#!/bin/bash
nohup java -javaagent:/usr/local/skywalking-agent/skywalking-agent.jar -jar /usr/local/dubbo-provider/dubbo-server.jar >> dubbo-provider.log 2>&1 &

 

[root@server1 dubbo-provider]# sh start.sh 
[root@server1 dubbo-provider]# ll
total 13980
-rw-r--r-- 1 root root      341 Feb 20 21:26 dubbo-provider.log
-rw-r--r-- 1 root root 14301450 Feb 20 21:09 dubbo-server.jar
-rwxr-xr-x 1 root root      160 Feb 20 21:26 start.sh

[root@server1 dubbo-provider]# tail -f dubbo-provider.log 

 

  客户端验证zookeeper的dubbo-provider服务注册信息

 

  登录skywalking验证

 

  安装dubbo-client

  配置java8环境

[root@server2 jdk1.8.0_191]# java -version
java version "1.8.0_191"
Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)

 

  上传dubbo-client.jar,并配置连接zookeeper。

[root@server2 local]# mkdir dubbo-client

[root@server2 dubbo-client]# vim config.properties
zookeeper3.myserver.svc.cluster.local:2181
dubbo.registry=zookeeper://192.168.100.101:2181

 

  前台启动dubbo-client并使用skywalking agent 链路追踪测试

[root@server2 dubbo-client]# java -javaagent:/usr/local/skywalking-agent/skywalking-agent.jar -jar dubbo-client.jar

 

  启动成功后,创建启动脚本

[root@server2 dubbo-client]# vim start.sh
  
#!/bin/bash
nohup java -javaagent:/usr/local/skywalking-agent/skywalking-agent.jar -jar /usr/local/dubbo-client/dubbo-client.jar >> dubbo-client.log 2>&1 &

[root@server2 dubbo-client]# sh start.sh

[root@server2 dubbo-client]# tail -f dubbo-client.log 

 

  客户端验证zookeeper的dubbo-provider服务注册信息

 

  访问dubbo-client,消息传参给dubbo-client,由dubbo-client再发送给dubbo-provider服务端

 

  验证client消息

 

  验证provider 服务端消息

 

  登录skywalking验证provider和client数据

 

 

 

posted @ 2023-03-09 14:56  PunchLinux  阅读(143)  评论(0编辑  收藏  举报