Kubernetes Skywalking 【单Zookeeper + Dubbo Provider + Dubbo Consumer】
一、安装JDK11(8也行)
[root@xianchaonode1 sbin]# java -version
openjdk version "11.0.18" 2023-01-17 LTS
OpenJDK Runtime Environment (Red_Hat-11.0.18.0.10-1.el7_9) (build 11.0.18+10-LTS)
OpenJDK 64-Bit Server VM (Red_Hat-11.0.18.0.10-1.el7_9) (build 11.0.18+10-LTS, mixed mode, sharing)
二、下载Zookeeper 并且安装:192.168.40.181
下载地址:https://dlcdn.apache.org/zookeeper/zookeeper-3.6.4/apache-zookeeper-3.6.4-bin.tar.gz
apache-zookeeper-3.6.3-bin.tar.gz
tar zxvf apache-zookeeper-3.6.3-bin.tar.gz
mkdir -p /data/zookeeper
#/apps/apache-zookeeper-3.6.3-bin/conf
[root@xianchaonode1 conf]# vim zoo.cfg
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/data/zookeeper
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1
## Metrics Providers
#
# https://prometheus.io Metrics Exporter
#metricsProvider.className=org.apache.zookeeper.metrics.prometheus.PrometheusMetricsProvider
#metricsProvider.httpPort=7000
#metricsProvider.exportJvmInfo=true
#集群配置
#server.1=192.168.40.180:2888:3888
#server.2=192.168.40.181:2888:3888
#server.3=192.168.40.182:2888:3888
[root@xianchaonode1 bin]# ./zkServer.sh status
/usr/bin/java
ZooKeeper JMX enabled by default
Using config: /apps/zookeeper/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost. Client SSL: false.
Mode: standalone
[root@xianchaonode1 bin]# ss -nltp | grep 2181
LISTEN 0 50 :::2181 :::* users:(("java",pid=90525,fd=56))
三、Java微服务示例-provider部署:192.168.40.182
#1.java部署环境
[root@xianchaonode2 skywalking]# java -version
openjdk version "11.0.18" 2023-01-17 LTS
OpenJDK Runtime Environment (Red_Hat-11.0.18.0.10-1.el7_9) (build 11.0.18+10-LTS)
OpenJDK 64-Bit Server VM (Red_Hat-11.0.18.0.10-1.el7_9) (build 11.0.18+10-LTS, mixed mode, sharing)
#2.skywalking-agent
#/root/skywalking/skywalking-agent/skywalking-agent.jar
[root@xianchaonode2 ~]# vim /root/skywalking/skywalking-agent/config/agent.config
agent.namespace=${SW_AGENT_NAMESPACE:Zookeeper-Dubbo}
agent.service_name=${SW_AGENT_NAME:xks-zookeeperdubbo}
collector.backend_service=${SW_AGENT_COLLECTOR_BACKEND_SERVICES:192.168.40.182:11800}
#3.当前主机名解析
#4.provider连接zookeeper配置:
#dubbo-server.jar
#windows上配置config.properties 配置zookeeper地址
#dubbo.registry=zookeeper://zookeeper1.myserver.svc.cluster.local:2181?backup=zookeeper2.myserver.svc.cluster.local:2181,zookeeper3.myserver.svc.cluster.local:2181
dubbo.registry=zookeeper://192.168.40.181:2181
dubbo.port=20880
#5.启动provider
#/root/skywalking/skywalking-agent/skywalking-agent.jar
[root@xianchaonode2 skywalking-agent]# java -javaagent:/root/skywalking/skywalking-agent/skywalking-agent.jar -jar /apps/dubbo-server.jar
DEBUG 2023-04-23 09:33:11:588 main AgentPackagePath : The beacon class location is jar:file:/root/skywalking/skywalking-agent/skywalking-agent.jar!/org/apache/skywalking/apm/agent/core/boot/AgentPackagePath.class.
INFO 2023-04-23 09:33:11:589 main SnifferConfigInitializer : Config file found in /root/skywalking/skywalking-agent/config/agent.config.
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v1.3.1.RELEASE)
2023-04-23 09:33:14.020 INFO 42698 --- [ main] com.od.dubbotest.Application : Starting Application v0.0.1-SNAPSHOT on xianchaonode2 with PID 42698 (/apps/dubbo-server.jar started by root in /root/skywalking/skywalking-agent)
2023-04-23 09:33:14.022 INFO 42698 --- [ main] com.od.dubbotest.Application : No active profile set, falling back to default profiles: default
2023-04-23 09:33:14.043 INFO 42698 --- [ main] o.s.b.f.xml.XmlBeanDefinitionReader : Loading XML bean definitions from URL [jar:file:/apps/dubbo-server.jar!/spring-config.xml]
log4j:WARN No appenders could be found for logger (com.alibaba.dubbo.common.logger.LoggerFactory).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
2023-04-23 09:33:14.446 INFO 42698 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@567f476e: startup date [Sun Apr 23 09:33:14 CST 2023]; root of context hierarchy
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils$1 (jar:file:/apps/dubbo-server.jar!/lib/spring-core-4.2.4.RELEASE.jar!/) to method java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain)
WARNING: Please consider reporting this to the maintainers of org.springframework.cglib.core.ReflectUtils$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
2023-04-23 09:33:15.488 INFO 42698 --- [ main] o.s.b.f.c.PropertyPlaceholderConfigurer : Loading properties file from class path resource [config.properties]
[4.396s][warning][exceptions] Class java.lang.Class in throws clause of method com.alibaba.dubbo.rpc.Invoker com.alibaba.dubbo.rpc.Protocol$Adpative.refer(java.lang.Class, com.alibaba.dubbo.common.URL) is not a subtype of class java.lang.Throwable
[4.396s][warning][exceptions] Class com.alibaba.dubbo.rpc.Invoker in throws clause of method com.alibaba.dubbo.rpc.Exporter com.alibaba.dubbo.rpc.Protocol$Adpative.export(com.alibaba.dubbo.rpc.Invoker) is not a subtype of class java.lang.Throwable
[4.405s][warning][exceptions] Class com.alibaba.dubbo.rpc.Invoker in throws clause of method java.lang.Object com.alibaba.dubbo.rpc.ProxyFactory$Adpative.getProxy(com.alibaba.dubbo.rpc.Invoker) is not a subtype of class java.lang.Throwable
[4.405s][warning][exceptions] Class java.lang.Object in throws clause of method com.alibaba.dubbo.rpc.Invoker com.alibaba.dubbo.rpc.ProxyFactory$Adpative.getInvoker(java.lang.Object, java.lang.Class, com.alibaba.dubbo.common.URL) is not a subtype of class java.lang.Throwable
[4.543s][warning][exceptions] Class com.alibaba.dubbo.rpc.cluster.Directory in throws clause of method com.alibaba.dubbo.rpc.Invoker com.alibaba.dubbo.rpc.cluster.Cluster$Adpative.join(com.alibaba.dubbo.rpc.cluster.Directory) is not a subtype of class java.lang.Throwable
[4.565s][warning][exceptions] Class com.alibaba.dubbo.common.URL in throws clause of method com.alibaba.dubbo.remoting.Client com.alibaba.dubbo.remoting.Transporter$Adpative.connect(com.alibaba.dubbo.common.URL, com.alibaba.dubbo.remoting.ChannelHandler) is not a subtype of class java.lang.Throwable
[4.565s][warning][exceptions] Class com.alibaba.dubbo.common.URL in throws clause of method com.alibaba.dubbo.remoting.Server com.alibaba.dubbo.remoting.Transporter$Adpative.bind(com.alibaba.dubbo.common.URL, com.alibaba.dubbo.remoting.ChannelHandler) is not a subtype of class java.lang.Throwable
2023-04-23 09:33:16.145 INFO 42698 --- [ main] org.apache.zookeeper.ZooKeeper : Client environment:zookeeper.version=3.4.6-1569965, built on 02/20/2014 09:09 GMT
2023-04-23 09:33:16.145 INFO 42698 --- [ main] org.apache.zookeeper.ZooKeeper : Client environment:host.name=xianchaonode2
2023-04-23 09:33:16.145 INFO 42698 --- [ main] org.apache.zookeeper.ZooKeeper : Client environment:java.version=11.0.18
2023-04-23 09:33:16.145 INFO 42698 --- [ main] org.apache.zookeeper.ZooKeeper : Client environment:java.vendor=Red Hat, Inc.
2023-04-23 09:33:16.145 INFO 42698 --- [ main] org.apache.zookeeper.ZooKeeper : Client environment:java.home=/usr/lib/jvm/java-11-openjdk-11.0.18.0.10-1.el7_9.x86_64
2023-04-23 09:33:16.145 INFO 42698 --- [ main] org.apache.zookeeper.ZooKeeper : Client environment:java.class.path=/apps/dubbo-server.jar
2023-04-23 09:33:16.145 INFO 42698 --- [ main] org.apache.zookeeper.ZooKeeper : Client environment:java.library.path=/usr/java/packages/lib:/usr/lib64:/lib64:/lib:/usr/lib
2023-04-23 09:33:16.145 INFO 42698 --- [ main] org.apache.zookeeper.ZooKeeper : Client environment:java.io.tmpdir=/tmp
2023-04-23 09:33:16.146 INFO 42698 --- [ main] org.apache.zookeeper.ZooKeeper : Client environment:java.compiler=<NA>
2023-04-23 09:33:16.146 INFO 42698 --- [ main] org.apache.zookeeper.ZooKeeper : Client environment:os.name=Linux
2023-04-23 09:33:16.146 INFO 42698 --- [ main] org.apache.zookeeper.ZooKeeper : Client environment:os.arch=amd64
2023-04-23 09:33:16.146 INFO 42698 --- [ main] org.apache.zookeeper.ZooKeeper : Client environment:os.version=3.10.0-957.el7.x86_64
2023-04-23 09:33:16.146 INFO 42698 --- [ main] org.apache.zookeeper.ZooKeeper : Client environment:user.name=root
2023-04-23 09:33:16.146 INFO 42698 --- [ main] org.apache.zookeeper.ZooKeeper : Client environment:user.home=/root
2023-04-23 09:33:16.146 INFO 42698 --- [ main] org.apache.zookeeper.ZooKeeper : Client environment:user.dir=/root/skywalking/skywalking-agent
2023-04-23 09:33:16.147 INFO 42698 --- [ main] org.apache.zookeeper.ZooKeeper : Initiating client connection, connectString=192.168.40.181:2181 sessionTimeout=30000 watcher=org.I0Itec.zkclient.ZkClient@7956cb1c
2023-04-23 09:33:16.167 INFO 42698 --- [68.40.181:2181)] org.apache.zookeeper.ClientCnxn : Opening socket connection to server 192.168.40.181/192.168.40.181:2181. Will not attempt to authenticate using SASL (unknown error)
2023-04-23 09:33:16.168 INFO 42698 --- [68.40.181:2181)] org.apache.zookeeper.ClientCnxn : Socket connection established to 192.168.40.181/192.168.40.181:2181, initiating session
2023-04-23 09:33:16.191 INFO 42698 --- [68.40.181:2181)] org.apache.zookeeper.ClientCnxn : Session establishment complete on server 192.168.40.181/192.168.40.181:2181, sessionid = 0x1001472619c0000, negotiated timeout = 30000
2023-04-23 09:33:16.436 INFO 42698 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2023-04-23 09:33:16.467 INFO 42698 --- [ main] com.od.dubbotest.Application : Started Application in 2.972 seconds (JVM running for 5.009)
Dubbo server started
Dubbo 服务端已经启动
java微服务-consumer部署:192.168.40.180
#1.java部署环境
[root@xianchaomaster1 data]# java -version
openjdk version "1.8.0_362"
OpenJDK Runtime Environment (build 1.8.0_362-b08)
OpenJDK 64-Bit Server VM (build 25.362-b08, mixed mode)
#2.skywalking-agent
#/root/skywalking/skywalking-agent/skywalking-agent.jar
[root@xianchaonode2 ~]# vim /root/skywalking/skywalking-agent/config/agent.config
agent.namespace=${SW_AGENT_NAMESPACE:Zookeeper-Dubbo}
agent.service_name=${SW_AGENT_NAME:xks-dubboconsumer}
collector.backend_service=${SW_AGENT_COLLECTOR_BACKEND_SERVICES:192.168.40.182:11800}
#3.当前主机名解析
配置ip就不用解析
#4.provider连接zookeeper配置:
#dubbo-client.jar
#windows上配置config.properties 配置zookeeper地址
#dubbo.registry=zookeeper://zookeeper1.myserver.svc.cluster.local:2181?backup=zookeeper2.myserver.svc.cluster.local:2181,zookeeper3.myserver.svc.cluster.local:2181
#dubbo.registry=zookeeper://zookeeper1:2181?backup=zookeeper2:2181,zookeeper3:2181
dubbo.registry=zookeeper://192.168.40.181:2181
#5.启动provider
#/root/skywalking/skywalking-agent/skywalking-agent.jar
[root@xianchaomaster1 skywalking]# java -javaagent:/root/skywalking/skywalking-agent/skywalking-agent.jar -jar dubbo-client.jar
#6.访问192.168.40.180:8080
#6.访问192.168.40.180:8080/hello?name=xks
此时Server端 192.168.40.182 接收到请求
Dubbo server started
Dubbo 服务端已经启动
HelloService接收到消息:null
HelloService接收到消息:xks