• 初识dubbo(随笔)


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

    1. 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.
    2. org.apache.zookeeper.ClientCnxn$EndOfStreamException: Unable to read additional data from server sessionid 0x100000035640495, likely server has closed socket
    3. at org.apache.zookeeper.ClientCnxnSocketNIO.doIO(ClientCnxnSocketNIO.java:75) ~[zookeeper-3.6.0.jar:3.6.0]
    4. at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:348) ~[zookeeper-3.6.0.jar:3.6.0]
    5. at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1262) ~[zookeeper-3.6.0.jar:3.6.0]
    6. 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
    7. 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
    8. at com.alibaba.dubbo.registry.zookeeper.ZookeeperRegistry.doRegister(ZookeeperRegistry.java:116) ~[dubbo-2.6.9.jar:2.6.9]
    9. at com.alibaba.dubbo.registry.support.FailbackRegistry.retry(FailbackRegistry.java:321) ~[dubbo-2.6.9.jar:2.6.9]
    10. at com.alibaba.dubbo.registry.support.FailbackRegistry$1.run(FailbackRegistry.java:74) [dubbo-2.6.9.jar:2.6.9]
    11. at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_121]
    12. at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) [na:1.8.0_121]
    13. at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) [na:1.8.0_121]
    14. at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) [na:1.8.0_121]
    15. at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_121]
    16. at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_121]
    17. at java.lang.Thread.run(Thread.java:745) [na:1.8.0_121]
    18. Caused by: java.lang.IllegalStateException: KeeperErrorCode = Unimplemented for /dubbo
    19. at com.alibaba.dubbo.remoting.zookeeper.curator.CuratorZookeeperClient.createPersistent(CuratorZookeeperClient.java:81) ~[dubbo-2.6.9.jar:2.6.9]
    20. at com.alibaba.dubbo.remoting.zookeeper.support.AbstractZookeeperClient.create(AbstractZookeeperClient.java:83) ~[dubbo-2.6.9.jar:2.6.9]
    21. at com.alibaba.dubbo.remoting.zookeeper.support.AbstractZookeeperClient.create(AbstractZookeeperClient.java:78) ~[dubbo-2.6.9.jar:2.6.9]
    22. at com.alibaba.dubbo.remoting.zookeeper.support.AbstractZookeeperClient.create(AbstractZookeeperClient.java:78) ~[dubbo-2.6.9.jar:2.6.9]
    23. at com.alibaba.dubbo.remoting.zookeeper.support.AbstractZookeeperClient.create(AbstractZookeeperClient.java:78) ~[dubbo-2.6.9.jar:2.6.9]
    24. at com.alibaba.dubbo.registry.zookeeper.ZookeeperRegistry.doRegister(ZookeeperRegistry.java:114) ~[dubbo-2.6.9.jar:2.6.9]
    25. ... 9 common frames omitted
    26. Caused by: org.apache.zookeeper.KeeperException$UnimplementedException: KeeperErrorCode = Unimplemented for /dubbo
    27. at org.apache.zookeeper.KeeperException.create(KeeperException.java:106) ~[zookeeper-3.6.0.jar:3.6.0]
    28. at org.apache.zookeeper.KeeperException.create(KeeperException.java:54) ~[zookeeper-3.6.0.jar:3.6.0]
    29. at org.apache.zookeeper.ZooKeeper.create(ZooKeeper.java:1836) ~[zookeeper-3.6.0.jar:3.6.0]
    30. at org.apache.curator.framework.imps.CreateBuilderImpl$16.call(CreateBuilderImpl.java:1131) ~[curator-framework-5.0.0.jar:5.0.0]
    31. at org.apache.curator.framework.imps.CreateBuilderImpl$16.call(CreateBuilderImpl.java:1113) ~[curator-framework-5.0.0.jar:5.0.0]
    32. at org.apache.curator.RetryLoop.callWithRetry(RetryLoop.java:93) ~[curator-client-5.0.0.jar:na]
    33. at org.apache.curator.framework.imps.CreateBuilderImpl.pathInForeground(CreateBuilderImpl.java:1110) ~[curator-framework-5.0.0.jar:5.0.0]
    34. at org.apache.curator.framework.imps.CreateBuilderImpl.protectedPathInForeground(CreateBuilderImpl.java:593) ~[curator-framework-5.0.0.jar:5.0.0]
    35. at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:583) ~[curator-framework-5.0.0.jar:5.0.0]
    36. at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:561) ~[curator-framework-5.0.0.jar:5.0.0]
    37. at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:48) ~[curator-framework-5.0.0.jar:5.0.0]
    38. at com.alibaba.dubbo.remoting.zookeeper.curator.CuratorZookeeperClient.createPersistent(CuratorZookeeperClient.java:78) ~[dubbo-2.6.9.jar:2.6.9]
    39. ... 14 common frames omitted
    40. 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
    41. 15:12:51.802 [main-EventThread] INFO o.a.c.f.state.ConnectionStateManager - State change: SUSPENDED
    42. 15:12:51.802 [DubboRegistryFailedRetryTimer-thread-1] DEBUG org.apache.curator.RetryLoopImpl - Retry-able exception received
    43. org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /dubbo/com.carlo.service.UserService/configurators
    44. at org.apache.zookeeper.KeeperException.create(KeeperException.java:102) ~[zookeeper-3.6.0.jar:3.6.0]
    45. at org.apache.zookeeper.KeeperException.create(KeeperException.java:54) ~[zookeeper-3.6.0.jar:3.6.0]
    46. at org.apache.zookeeper.ZooKeeper.exists(ZooKeeper.java:2246) ~[zookeeper-3.6.0.jar:3.6.0]
    47. at org.apache.curator.framework.imps.ExistsBuilderImpl$3.call(ExistsBuilderImpl.java:268) ~[curator-framework-5.0.0.jar:5.0.0]
    48. at org.apache.curator.framework.imps.ExistsBuilderImpl$3.call(ExistsBuilderImpl.java:257) ~[curator-framework-5.0.0.jar:5.0.0]
    49. at org.apache.curator.RetryLoop.callWithRetry(RetryLoop.java:93) ~[curator-client-5.0.0.jar:na]
    50. at org.apache.curator.framework.imps.ExistsBuilderImpl.pathInForegroundStandard(ExistsBuilderImpl.java:254) [curator-framework-5.0.0.jar:5.0.0]
    51. at org.apache.curator.framework.imps.ExistsBuilderImpl.pathInForeground(ExistsBuilderImpl.java:247) [curator-framework-5.0.0.jar:5.0.0]
    52. at org.apache.curator.framework.imps.ExistsBuilderImpl.forPath(ExistsBuilderImpl.java:206) [curator-framework-5.0.0.jar:5.0.0]
    53. at org.apache.curator.framework.imps.ExistsBuilderImpl.forPath(ExistsBuilderImpl.java:35) [curator-framework-5.0.0.jar:5.0.0]
    54. at com.alibaba.dubbo.remoting.zookeeper.curator.CuratorZookeeperClient.checkExists(CuratorZookeeperClient.java:119) [dubbo-2.6.9.jar:2.6.9]
    55. at com.alibaba.dubbo.remoting.zookeeper.support.AbstractZookeeperClient.create(AbstractZookeeperClient.java:71) [dubbo-2.6.9.jar:2.6.9]
    56. at com.alibaba.dubbo.registry.zookeeper.ZookeeperRegistry.doSubscribe(ZookeeperRegistry.java:184) [dubbo-2.6.9.jar:2.6.9]
    57. at com.alibaba.dubbo.registry.support.FailbackRegistry.retry(FailbackRegistry.java:369) [dubbo-2.6.9.jar:2.6.9]
    58. at com.alibaba.dubbo.registry.support.FailbackRegistry$1.run(FailbackRegistry.java:74) [dubbo-2.6.9.jar:2.6.9]
    59. at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_121]
    60. at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) [na:1.8.0_121]
    61. at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) [na:1.8.0_121]
    62. at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) [na:1.8.0_121]
    63. at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_121]
    64. at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_121]
    65. at java.lang.Thread.run(Thread.java:745) [na:1.8.0_121]
    66. 15:12:52.802 [DubboRegistryFailedRetryTimer-thread-1] DEBUG org.apache.curator.RetryLoopImpl - Retrying operation
    67. 15:12:53.144 [main-SendThread(192.168.71.143:2181)] DEBUG o.a.zookeeper.SaslServerPrincipal - Canonicalized address to node1
    68. 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.
    69. 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)
    70. 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
    71. 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
    72. 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
    73. 15:12:53.148 [main-EventThread] DEBUG org.apache.curator.ConnectionState - Negotiated session timeout: 40000

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

    1. 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
    2. 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
    3. 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
    4. 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
    5. 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
    6. 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
    7. 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
    8. 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
    9. 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
    10. 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
    11. 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
    12. 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
    13. 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
    14. 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
    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
    16. 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
    17. 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
    18. 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
    19. 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
    20. 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
    21. 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服务端,成功了。 

    启动时如果提示 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:

    1. 17:11:27.313 [main] DEBUG io.netty.buffer.ByteBufUtil - -Dio.netty.allocator.type: pooled
    2. 17:11:27.313 [main] DEBUG io.netty.buffer.ByteBufUtil - -Dio.netty.threadLocalDirectBufferSize: 0
    3. 17:11:27.313 [main] DEBUG io.netty.buffer.ByteBufUtil - -Dio.netty.maxThreadLocalCharBufferSize: 16384
    4. 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
    5. java.net.BindException: Address already in use: bind
    6. at sun.nio.ch.Net.bind0(Native Method) ~[na:1.8.0_121]
    7. at sun.nio.ch.Net.bind(Net.java:433) ~[na:1.8.0_121]
    8. at sun.nio.ch.Net.bind(Net.java:425) ~[na:1.8.0_121]
    9. at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223) ~[na:1.8.0_121]
    10. at io.netty.channel.socket.nio.NioServerSocketChannel.doBind(NioServerSocketChannel.java:134) ~[netty-all-4.1.63.Final.jar:4.1.63.Final]
    11. at io.netty.channel.AbstractChannel$AbstractUnsafe.bind(AbstractChannel.java:562) ~[netty-all-4.1.63.Final.jar:4.1.63.Final]
    12. at io.netty.channel.DefaultChannelPipeline$HeadContext.bind(DefaultChannelPipeline.java:1334) ~[netty-all-4.1.63.Final.jar:4.1.63.Final]
    13. at io.netty.channel.AbstractChannelHandlerContext.invokeBind(AbstractChannelHandlerContext.java:506) ~[netty-all-4.1.63.Final.jar:4.1.63.Final]
    14. at io.netty.channel.AbstractChannelHandlerContext.bind(AbstractChannelHandlerContext.java:491) ~[netty-all-4.1.63.Final.jar:4.1.63.Final]
    15. at io.netty.channel.DefaultChannelPipeline.bind(DefaultChannelPipeline.java:973) ~[netty-all-4.1.63.Final.jar:4.1.63.Final]
    16. at io.netty.channel.AbstractChannel.bind(AbstractChannel.java:260) ~[netty-all-4.1.63.Final.jar:4.1.63.Final]
    17. at io.netty.bootstrap.AbstractBootstrap$2.run(AbstractBootstrap.java:356) ~[netty-all-4.1.63.Final.jar:4.1.63.Final]
    18. at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164) ~[netty-all-4.1.63.Final.jar:4.1.63.Final]
    19. at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:472) ~[netty-all-4.1.63.Final.jar:4.1.63.Final]
    20. 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服务的端口:

    配置文件中加上:

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

    即可。

    后记:

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

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

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

  • 相关阅读:
    docker中DVWA的安装
    自媒体账号如何快速涨粉打造爆款,快来get这份运营技巧
    Python学生公寓管理系统的设计与实现毕业设计源码181047
    设计模式 建造者模式介绍、案例应用、建造者模式和工厂模式的区别
    git-secret:在 Git 存储库中加密和存储密钥(下)
    csdn_export_md
    linux 下安装安装rzsz命令
    springcloud之项目实战环境准备
    C#策略模式、策略与简单工厂结合模式——商场收银系统
    算法必刷系列之位运算
  • 原文地址:https://blog.csdn.net/cwh056056/article/details/125995704