初识dubbo(随笔)

搭建dubbo服务端的时候,出现这个异常:

15:12:51.702 [main-SendThread(192.168.71.143:2181)] WARN  org.apache.zookeeper.ClientCnxn - Session 0x100000035640495 for sever node1/192.168.71.143:2181, Closing socket connection. Attempting reconnect except it is a SessionExpiredException.
org.apache.zookeeper.ClientCnxn$EndOfStreamException: Unable to read additional data from server sessionid 0x100000035640495, likely server has closed socket
	at org.apache.zookeeper.ClientCnxnSocketNIO.doIO(ClientCnxnSocketNIO.java:75) ~[zookeeper-3.6.0.jar:3.6.0]
	at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:348) ~[zookeeper-3.6.0.jar:3.6.0]
	at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1262) ~[zookeeper-3.6.0.jar:3.6.0]
15:12:51.702 [DubboRegistryFailedRetryTimer-thread-1] WARN  c.a.d.r.zookeeper.ZookeeperRegistry -  [DUBBO] Failed to retry register [dubbo://192.168.244.3:20880/com.carlo.service.UserService?anyhost=true&application=dubbo-provider&bean.name=com.carlo.service.UserService&default.timeout=5000&dubbo=2.0.2&generic=false&interface=com.carlo.service.UserService&methods=hello&pid=5840&revision=1.0-SNAPSHOT&side=provider&timeout=3000×tamp=1658819533146], waiting for again, cause: Failed to register dubbo://192.168.244.3:20880/com.carlo.service.UserService?anyhost=true&application=dubbo-provider&bean.name=com.carlo.service.UserService&default.timeout=5000&dubbo=2.0.2&generic=false&interface=com.carlo.service.UserService&methods=hello&pid=5840&revision=1.0-SNAPSHOT&side=provider&timeout=3000×tamp=1658819533146 to zookeeper zookeeper://192.168.71.143:2181/com.alibaba.dubbo.registry.RegistryService?application=dubbo-provider&check=false&dubbo=2.0.2&interface=com.alibaba.dubbo.registry.RegistryService&pid=5840×tamp=1658819533136, cause: KeeperErrorCode = Unimplemented for /dubbo, dubbo version: 2.6.9, current host: 192.168.244.3
com.alibaba.dubbo.rpc.RpcException: Failed to register dubbo://192.168.244.3:20880/com.carlo.service.UserService?anyhost=true&application=dubbo-provider&bean.name=com.carlo.service.UserService&default.timeout=5000&dubbo=2.0.2&generic=false&interface=com.carlo.service.UserService&methods=hello&pid=5840&revision=1.0-SNAPSHOT&side=provider&timeout=3000×tamp=1658819533146 to zookeeper zookeeper://192.168.71.143:2181/com.alibaba.dubbo.registry.RegistryService?application=dubbo-provider&check=false&dubbo=2.0.2&interface=com.alibaba.dubbo.registry.RegistryService&pid=5840×tamp=1658819533136, cause: KeeperErrorCode = Unimplemented for /dubbo
	at com.alibaba.dubbo.registry.zookeeper.ZookeeperRegistry.doRegister(ZookeeperRegistry.java:116) ~[dubbo-2.6.9.jar:2.6.9]
	at com.alibaba.dubbo.registry.support.FailbackRegistry.retry(FailbackRegistry.java:321) ~[dubbo-2.6.9.jar:2.6.9]
	at com.alibaba.dubbo.registry.support.FailbackRegistry$1.run(FailbackRegistry.java:74) [dubbo-2.6.9.jar:2.6.9]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_121]
	at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) [na:1.8.0_121]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) [na:1.8.0_121]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) [na:1.8.0_121]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_121]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_121]
	at java.lang.Thread.run(Thread.java:745) [na:1.8.0_121]
Caused by: java.lang.IllegalStateException: KeeperErrorCode = Unimplemented for /dubbo
	at com.alibaba.dubbo.remoting.zookeeper.curator.CuratorZookeeperClient.createPersistent(CuratorZookeeperClient.java:81) ~[dubbo-2.6.9.jar:2.6.9]
	at com.alibaba.dubbo.remoting.zookeeper.support.AbstractZookeeperClient.create(AbstractZookeeperClient.java:83) ~[dubbo-2.6.9.jar:2.6.9]
	at com.alibaba.dubbo.remoting.zookeeper.support.AbstractZookeeperClient.create(AbstractZookeeperClient.java:78) ~[dubbo-2.6.9.jar:2.6.9]
	at com.alibaba.dubbo.remoting.zookeeper.support.AbstractZookeeperClient.create(AbstractZookeeperClient.java:78) ~[dubbo-2.6.9.jar:2.6.9]
	at com.alibaba.dubbo.remoting.zookeeper.support.AbstractZookeeperClient.create(AbstractZookeeperClient.java:78) ~[dubbo-2.6.9.jar:2.6.9]
	at com.alibaba.dubbo.registry.zookeeper.ZookeeperRegistry.doRegister(ZookeeperRegistry.java:114) ~[dubbo-2.6.9.jar:2.6.9]
	... 9 common frames omitted
Caused by: org.apache.zookeeper.KeeperException$UnimplementedException: KeeperErrorCode = Unimplemented for /dubbo
	at org.apache.zookeeper.KeeperException.create(KeeperException.java:106) ~[zookeeper-3.6.0.jar:3.6.0]
	at org.apache.zookeeper.KeeperException.create(KeeperException.java:54) ~[zookeeper-3.6.0.jar:3.6.0]
	at org.apache.zookeeper.ZooKeeper.create(ZooKeeper.java:1836) ~[zookeeper-3.6.0.jar:3.6.0]
	at org.apache.curator.framework.imps.CreateBuilderImpl$16.call(CreateBuilderImpl.java:1131) ~[curator-framework-5.0.0.jar:5.0.0]
	at org.apache.curator.framework.imps.CreateBuilderImpl$16.call(CreateBuilderImpl.java:1113) ~[curator-framework-5.0.0.jar:5.0.0]
	at org.apache.curator.RetryLoop.callWithRetry(RetryLoop.java:93) ~[curator-client-5.0.0.jar:na]
	at org.apache.curator.framework.imps.CreateBuilderImpl.pathInForeground(CreateBuilderImpl.java:1110) ~[curator-framework-5.0.0.jar:5.0.0]
	at org.apache.curator.framework.imps.CreateBuilderImpl.protectedPathInForeground(CreateBuilderImpl.java:593) ~[curator-framework-5.0.0.jar:5.0.0]
	at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:583) ~[curator-framework-5.0.0.jar:5.0.0]
	at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:561) ~[curator-framework-5.0.0.jar:5.0.0]
	at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:48) ~[curator-framework-5.0.0.jar:5.0.0]
	at com.alibaba.dubbo.remoting.zookeeper.curator.CuratorZookeeperClient.createPersistent(CuratorZookeeperClient.java:78) ~[dubbo-2.6.9.jar:2.6.9]
	... 14 common frames omitted
15:12:51.702 [DubboRegistryFailedRetryTimer-thread-1] INFO  c.a.d.r.zookeeper.ZookeeperRegistry -  [DUBBO] Retry subscribe {provider://192.168.244.3:20880/com.carlo.service.UserService?anyhost=true&application=dubbo-provider&bean.name=com.carlo.service.UserService&category=configurators&check=false&default.timeout=5000&dubbo=2.0.2&generic=false&interface=com.carlo.service.UserService&methods=hello&pid=5840&revision=1.0-SNAPSHOT&side=provider&timeout=3000×tamp=1658819533146=[com.alibaba.dubbo.registry.integration.RegistryProtocol$OverrideListener@74eb909f]}, dubbo version: 2.6.9, current host: 192.168.244.3
15:12:51.802 [main-EventThread] INFO  o.a.c.f.state.ConnectionStateManager - State change: SUSPENDED
15:12:51.802 [DubboRegistryFailedRetryTimer-thread-1] DEBUG org.apache.curator.RetryLoopImpl - Retry-able exception received
org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /dubbo/com.carlo.service.UserService/configurators
	at org.apache.zookeeper.KeeperException.create(KeeperException.java:102) ~[zookeeper-3.6.0.jar:3.6.0]
	at org.apache.zookeeper.KeeperException.create(KeeperException.java:54) ~[zookeeper-3.6.0.jar:3.6.0]
	at org.apache.zookeeper.ZooKeeper.exists(ZooKeeper.java:2246) ~[zookeeper-3.6.0.jar:3.6.0]
	at org.apache.curator.framework.imps.ExistsBuilderImpl$3.call(ExistsBuilderImpl.java:268) ~[curator-framework-5.0.0.jar:5.0.0]
	at org.apache.curator.framework.imps.ExistsBuilderImpl$3.call(ExistsBuilderImpl.java:257) ~[curator-framework-5.0.0.jar:5.0.0]
	at org.apache.curator.RetryLoop.callWithRetry(RetryLoop.java:93) ~[curator-client-5.0.0.jar:na]
	at org.apache.curator.framework.imps.ExistsBuilderImpl.pathInForegroundStandard(ExistsBuilderImpl.java:254) [curator-framework-5.0.0.jar:5.0.0]
	at org.apache.curator.framework.imps.ExistsBuilderImpl.pathInForeground(ExistsBuilderImpl.java:247) [curator-framework-5.0.0.jar:5.0.0]
	at org.apache.curator.framework.imps.ExistsBuilderImpl.forPath(ExistsBuilderImpl.java:206) [curator-framework-5.0.0.jar:5.0.0]
	at org.apache.curator.framework.imps.ExistsBuilderImpl.forPath(ExistsBuilderImpl.java:35) [curator-framework-5.0.0.jar:5.0.0]
	at com.alibaba.dubbo.remoting.zookeeper.curator.CuratorZookeeperClient.checkExists(CuratorZookeeperClient.java:119) [dubbo-2.6.9.jar:2.6.9]
	at com.alibaba.dubbo.remoting.zookeeper.support.AbstractZookeeperClient.create(AbstractZookeeperClient.java:71) [dubbo-2.6.9.jar:2.6.9]
	at com.alibaba.dubbo.registry.zookeeper.ZookeeperRegistry.doSubscribe(ZookeeperRegistry.java:184) [dubbo-2.6.9.jar:2.6.9]
	at com.alibaba.dubbo.registry.support.FailbackRegistry.retry(FailbackRegistry.java:369) [dubbo-2.6.9.jar:2.6.9]
	at com.alibaba.dubbo.registry.support.FailbackRegistry$1.run(FailbackRegistry.java:74) [dubbo-2.6.9.jar:2.6.9]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_121]
	at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) [na:1.8.0_121]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) [na:1.8.0_121]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) [na:1.8.0_121]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_121]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_121]
	at java.lang.Thread.run(Thread.java:745) [na:1.8.0_121]
15:12:52.802 [DubboRegistryFailedRetryTimer-thread-1] DEBUG org.apache.curator.RetryLoopImpl - Retrying operation
15:12:53.144 [main-SendThread(192.168.71.143:2181)] DEBUG o.a.zookeeper.SaslServerPrincipal - Canonicalized address to node1
15:12:53.145 [main-SendThread(192.168.71.143:2181)] INFO  org.apache.zookeeper.ClientCnxn - Opening socket connection to server node1/192.168.71.143:2181.
15:12:53.145 [main-SendThread(192.168.71.143:2181)] INFO  org.apache.zookeeper.ClientCnxn - SASL config status: Will not attempt to authenticate using SASL (unknown error)
15:12:53.145 [main-SendThread(192.168.71.143:2181)] INFO  org.apache.zookeeper.ClientCnxn - Socket connection established, initiating session, client: /192.168.71.130:60939, server: node1/192.168.71.143:2181
15:12:53.145 [main-SendThread(192.168.71.143:2181)] DEBUG org.apache.zookeeper.ClientCnxn - Session establishment request sent on node1/192.168.71.143:2181
15:12:53.148 [main-SendThread(192.168.71.143:2181)] INFO  org.apache.zookeeper.ClientCnxn - Session establishment complete on server node1/192.168.71.143:2181, session id = 0x100000035640495, negotiated timeout = 40000
15:12:53.148 [main-EventThread] DEBUG org.apache.curator.ConnectionState - Negotiated session timeout: 40000

然后去看了下zookeeper 日志,发现如下信息:

2022-07-26 01:46:50,641 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactory@215] - Accepted socket connection from /192.168.71.130:50194
2022-07-26 01:46:50,645 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@949] - Client attempting to establish new session at /192.168.71.130:50194
2022-07-26 01:46:50,647 [myid:] - INFO  [SyncThread:0:ZooKeeperServer@694] - Established session 0x100000035640541 with negotiated timeout 40000 for client /192.168.71.130:50194
2022-07-26 01:46:50,689 [myid:] - WARN  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@756] - Received packet at server of unknown type 15
2022-07-26 01:46:50,689 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxn@1056] - Closed socket connection for client /192.168.71.130:50194 which had sessionid 0x100000035640541
2022-07-26 01:46:51,975 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactory@215] - Accepted socket connection from /192.168.71.130:50196
2022-07-26 01:46:51,976 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@942] - Client attempting to renew session 0x100000035640541 at /192.168.71.130:50196
2022-07-26 01:46:51,977 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@694] - Established session 0x100000035640541 with negotiated timeout 40000 for client /192.168.71.130:50196
2022-07-26 01:46:51,989 [myid:] - WARN  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@756] - Received packet at server of unknown type 15
2022-07-26 01:46:51,990 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxn@1056] - Closed socket connection for client /192.168.71.130:50196 which had sessionid 0x100000035640541
2022-07-26 01:46:54,194 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactory@215] - Accepted socket connection from /192.168.71.130:50198
2022-07-26 01:46:54,194 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@942] - Client attempting to renew session 0x100000035640541 at /192.168.71.130:50198
2022-07-26 01:46:54,194 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@694] - Established session 0x100000035640541 with negotiated timeout 40000 for client /192.168.71.130:50198
2022-07-26 01:46:54,195 [myid:] - WARN  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@756] - Received packet at server of unknown type 15
2022-07-26 01:46:54,196 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxn@1056] - Closed socket connection for client /192.168.71.130:50198 which had sessionid 0x100000035640541
2022-07-26 01:46:55,679 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactory@215] - Accepted socket connection from /192.168.71.130:50201
2022-07-26 01:46:55,680 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@942] - Client attempting to renew session 0x100000035640541 at /192.168.71.130:50201
2022-07-26 01:46:55,680 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@694] - Established session 0x100000035640541 with negotiated timeout 40000 for client /192.168.71.130:50201
2022-07-26 01:46:55,681 [myid:] - WARN  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:ZooKeeperServer@756] - Received packet at server of unknown type 15
2022-07-26 01:46:55,682 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxn@1056] - Closed socket connection for client /192.168.71.130:50201 which had sessionid 0x100000035640541
2022-07-26 01:46:57,796 [myid:] - INFO  [NIOServerCxn.Factory:0.0.0.0/0.0.0.0:2181:NIOServerCnxnFactory@215] - Accepted socket connection from /192.168.71.130:50205

主要就是 这一句 : Received packet at server of unknown type 15

百度了下,都是说  curator 和 zookeeper  jar版本不对应的问题 , 查了下zookeeper服务端版本,是 3.4.13 。 于是 把 pom 中对应的版本改一下(删除Curator中的zookeeper组件,引入与zk匹配的zookeeper客户端版本)

初识dubbo(随笔)_第1张图片

启动运行dubbo服务端,成功了。 

启动时如果提示 qos-server can not bind localhost:22222, dubbo version: 2.6.9, current host: 192.168.244.3
java.net.BindException: Address already in use: bind:

17:11:27.313 [main] DEBUG io.netty.buffer.ByteBufUtil - -Dio.netty.allocator.type: pooled
17:11:27.313 [main] DEBUG io.netty.buffer.ByteBufUtil - -Dio.netty.threadLocalDirectBufferSize: 0
17:11:27.313 [main] DEBUG io.netty.buffer.ByteBufUtil - -Dio.netty.maxThreadLocalCharBufferSize: 16384
17:11:27.328 [main] ERROR com.alibaba.dubbo.qos.server.Server -  [DUBBO] qos-server can not bind localhost:22222, dubbo version: 2.6.9, current host: 192.168.244.3
java.net.BindException: Address already in use: bind
	at sun.nio.ch.Net.bind0(Native Method) ~[na:1.8.0_121]
	at sun.nio.ch.Net.bind(Net.java:433) ~[na:1.8.0_121]
	at sun.nio.ch.Net.bind(Net.java:425) ~[na:1.8.0_121]
	at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223) ~[na:1.8.0_121]
	at io.netty.channel.socket.nio.NioServerSocketChannel.doBind(NioServerSocketChannel.java:134) ~[netty-all-4.1.63.Final.jar:4.1.63.Final]
	at io.netty.channel.AbstractChannel$AbstractUnsafe.bind(AbstractChannel.java:562) ~[netty-all-4.1.63.Final.jar:4.1.63.Final]
	at io.netty.channel.DefaultChannelPipeline$HeadContext.bind(DefaultChannelPipeline.java:1334) ~[netty-all-4.1.63.Final.jar:4.1.63.Final]
	at io.netty.channel.AbstractChannelHandlerContext.invokeBind(AbstractChannelHandlerContext.java:506) ~[netty-all-4.1.63.Final.jar:4.1.63.Final]
	at io.netty.channel.AbstractChannelHandlerContext.bind(AbstractChannelHandlerContext.java:491) ~[netty-all-4.1.63.Final.jar:4.1.63.Final]
	at io.netty.channel.DefaultChannelPipeline.bind(DefaultChannelPipeline.java:973) ~[netty-all-4.1.63.Final.jar:4.1.63.Final]
	at io.netty.channel.AbstractChannel.bind(AbstractChannel.java:260) ~[netty-all-4.1.63.Final.jar:4.1.63.Final]
	at io.netty.bootstrap.AbstractBootstrap$2.run(AbstractBootstrap.java:356) ~[netty-all-4.1.63.Final.jar:4.1.63.Final]
	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164) ~[netty-all-4.1.63.Final.jar:4.1.63.Final]
	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472) ~[netty-all-4.1.63.Final.jar:4.1.63.Final]
	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:500) ~[netty-all-4.1.63.Final.jar:4.1.63.Final]

Qos=Quality of Service,qos是Dubbo的在线运维命令,可以对服务进行动态的配置、控制及查询。

这里提示端口被占用,则可通过配置文件更改qos服务的端口:

配置文件中加上:

dubbo.application.qos.enable=true
dubbo.application.qos.port=33333
dubbo.application.qos.accept.foreign.ip=false

即可。

后记:

curator 和 zookeeper  jar版本是有对应关系的。如果版本不对应,会提示如下的异常:

java.lang.NoClassDefFoundError: org/apache/zookeeper/admin/ZooKeeperAdmin

所以如果使用的是其他版本的zookeeper ,可以自行百度搜一下 《curator与zookeeper的版本之间的关系》,进行正确版本的配置。

你可能感兴趣的:(dubbo,dubbo,java-zookeeper,zookeeper)