您好,登录后才能下订单哦!
这期内容当中小编将会给大家带来有关ZooKeeper注册中心重启后会对Dubbo服务发布/订阅造成什么影响,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。
情况:ZooKeeper集群删除所有数据,重启ZooKeeper集群后,im-service没有providers,
重启im-service后,im-service所有dubbo接口没有consumers。
重启im-web之后,一切ok。
问题:如果dubbo服务运行正常,但是ZooKeeper集群宕机,并且丢失了所有的数据。 ZooKeeper集群重启后,需要重启dubbo服务吗? 答案:需要的。 ------------------------------------------------------------- 问题:如果dubbo服务运行正常,但是ZooKeeper集群宕机,没有丢失任何数据(zk数据做了持久化)。 ZooKeeper集群重启后,需要重启dubbo服务吗? 答案:不需要的。
ZooKeeper 3.4.11
dubbo 2.5.3
1、在docker容器中,启动ZooKeeper集群
2、在本地启动gwy-res-web项目。
此项目既是provider又是consumer:
此时在ZooKeeper中看到:
[zk: localhost:2181(CONNECTED) 1] ls /dubbo [com.newbanker.ie.service.CourseService, io.newbanker.modules.sys.service.ExhibitionCenterConfigService, com.newbanker.gwy.res.dubbo.service.ResAdRpcService, com.newbanker.mq.rely.service.MessageSenderService, com.newbanker.gwy.res.dubbo.service.GwyResCourseService, com.newbanker.gwy.res.dubbo.service.MarketingActivityAuthorizeService]
3、停止所有ZooKeeper,并删除所有ZooKeeper容器。之后重新建立ZooKeeper容器并启动:
[root@localhost ~]# docker stop `docker ps -q` ## 停止所有ZooKeeper服务 59533a8fa961 c8836b1a0da7 f1a194bedd53 [root@localhost ~]# docker rm `docker ps -qa` ## 删除所有ZooKeeper容器 59533a8fa961 c8836b1a0da7 f1a194bedd53 [root@localhost ~]# docker-compose -f zookeeper-compose.yml up -d ##重新创建ZooKeeper容器并启动 Creating zk1_cname ... done Creating zk2_cname ... done Creating zk3_cname ... done [root@localhost ~]# docker ps -aq ##查看新建容器id b73250197d7d 263d6efaa028 346334a5513f [root@localhost ~]# docker exec -it zk1_cname sh ##进入一个容器中 /zookeeper-3.4.11/bin # ./bin/zkCli.sh ##在容器中使用zk客户端链接服务端。 Connecting to localhost:2181 2019-09-19 09:03:46,773 [myid:] - INFO [main:Environment@100] - Client environment:zookeeper.version=3.4.11-37e277162d567b55a07d1755f0b31c32e93c01a0, built on 11/01/2017 18:06 GMT 这里省略一些ZooKeeper客户端链接ZooKeeper server的日志。 WATCHER:: WatchedEvent state:SyncConnected type:None path:null [zk: localhost:2181(CONNECTED) 0] ls / ##查看ZooKeeper节点,可以看到,并没有/dubbo节点!!! [zookeeper]
5、gwy-res-web一直在打日志如下。并且根据上一步:在zk中使用 ls / 命令,在zk跟节点下,并没有/dubbo节点。说明服务并没有重新注册到zk。
2019-09-19 17:12:39.677 [main-SendThread(192.168.126.129:2183)] INFO org.apache.zookeeper.ClientCnxn:1158 - Unable to read additional data from server sessionid 0x2000001648c0000, likely server has closed socket, closing socket connection and attempting reconnect 2019-09-19 17:12:40.706 [main-SendThread(192.168.126.129:2182)] INFO org.apache.zookeeper.ClientCnxn:1032 - Opening socket connection to server 192.168.126.129/192.168.126.129:2182. Will not attempt to authenticate using SASL (unknown error) 2019-09-19 17:12:40.707 [main-SendThread(192.168.126.129:2182)] INFO org.apache.zookeeper.ClientCnxn:876 - Socket connection established to 192.168.126.129/192.168.126.129:2182, initiating session 2019-09-19 17:12:40.709 [main-SendThread(192.168.126.129:2182)] INFO org.apache.zookeeper.ClientCnxn:1158 - Unable to read additional data from server sessionid 0x2000001648c0000, likely server has closed socket, closing socket connection and attempting reconnect 2019-09-19 17:12:42.239 [main-SendThread(192.168.126.129:2181)] INFO org.apache.zookeeper.ClientCnxn:1032 - Opening socket connection to server 192.168.126.129/192.168.126.129:2181. Will not attempt to authenticate using SASL (unknown error) 2019-09-19 17:12:42.240 [main-SendThread(192.168.126.129:2181)] INFO org.apache.zookeeper.ClientCnxn:876 - Socket connection established to 192.168.126.129/192.168.126.129:2181, initiating session 2019-09-19 17:12:42.242 [main-SendThread(192.168.126.129:2181)] INFO org.apache.zookeeper.ClientCnxn:1158 - Unable to read additional data from server sessionid 0x2000001648c0000, likely server has closed socket, closing socket connection and attempting reconnect 2019-09-19 17:12:43.310 [main-SendThread(192.168.126.129:2183)] INFO org.apache.zookeeper.ClientCnxn:1032 - Opening socket connection to server 192.168.126.129/192.168.126.129:2183. Will not attempt to authenticate using SASL (unknown error) 2019-09-19 17:12:43.312 [main-SendThread(192.168.126.129:2183)] INFO org.apache.zookeeper.ClientCnxn:876 - Socket connection established to 192.168.126.129/192.168.126.129:2183, initiating session 2019-09-19 17:12:43.314 [main-SendThread(192.168.126.129:2183)] INFO org.apache.zookeeper.ClientCnxn:1158 - Unable to read additional data from server sessionid 0x2000001648c0000, likely server has closed socket, closing socket connection and attempting reconnect 2019-09-19 17:12:43.861 [main-SendThread(192.168.126.129:2182)] INFO org.apache.zookeeper.ClientCnxn:1032 - Opening socket connection to server 192.168.126.129/192.168.126.129:2182. Will not attempt to authenticate using SASL (unknown error) 2019-09-19 17:12:43.863 [main-SendThread(192.168.126.129:2182)] INFO org.apache.zookeeper.ClientCnxn:876 - Socket connection established to 192.168.126.129/192.168.126.129:2182, initiating session 2019-09-19 17:12:43.864 [main-SendThread(192.168.126.129:2182)] INFO org.apache.zookeeper.ClientCnxn:1158 - Unable to read additional data from server sessionid 0x2000001648c0000, likely server has closed socket, closing socket connection and attempting reconnect 2019-09-19 17:12:44.971 [main-SendThread(192.168.126.129:2181)] INFO org.apache.zookeeper.ClientCnxn:1032 - Opening socket connection to server 192.168.126.129/192.168.126.129:2181. Will not attempt to authenticate using SASL (unknown error) 2019-09-19 17:12:44.971 [main-SendThread(192.168.126.129:2181)] INFO org.apache.zookeeper.ClientCnxn:876 - Socket connection established to 192.168.126.129/192.168.126.129:2181, initiating session 2019-09-19 17:12:44.973 [main-SendThread(192.168.126.129:2181)] INFO org.apache.zookeeper.ClientCnxn:1158 - Unable to read additional data from server sessionid 0x2000001648c0000, likely server has closed socket, closing socket connection and attempting reconnect 2019-09-19 17:12:45.845 [main-SendThread(192.168.126.129:2183)] INFO org.apache.zookeeper.ClientCnxn:1032 - Opening socket connection to server 192.168.126.129/192.168.126.129:2183. Will not attempt to authenticate using SASL (unknown error) 2019-09-19 17:12:45.846 [main-SendThread(192.168.126.129:2183)] INFO org.apache.zookeeper.ClientCnxn:876 - Socket connection established to 192.168.126.129/192.168.126.129:2183, initiating session 2019-09-19 17:12:45.848 [main-SendThread(192.168.126.129:2183)] INFO org.apache.zookeeper.ClientCnxn:1158 - Unable to read additional data from server sessionid 0x2000001648c0000, likely server has closed socket, closing socket connection and attempting reconnect 2019-09-19 17:12:46.207 [main-SendThread(192.168.126.129:2182)] INFO org.apache.zookeeper.ClientCnxn:1032 - Opening socket connection to server 192.168.126.129/192.168.126.129:2182. Will not attempt to authenticate using SASL (unknown error) 2019-09-19 17:12:46.208 [main-SendThread(192.168.126.129:2182)] INFO org.apache.zookeeper.ClientCnxn:876 - Socket connection established to 192.168.126.129/192.168.126.129:2182, initiating session 2019-09-19 17:12:46.209 [main-SendThread(192.168.126.129:2182)] INFO org.apache.zookeeper.ClientCnxn:1158 - Unable to read additional data from server sessionid 0x2000001648c0000, likely server has closed socket, closing socket connection and attempting reconnect 2019-09-19 17:12:48.081 [main-SendThread(192.168.126.129:2181)] INFO org.apache.zookeeper.ClientCnxn:1032 - Opening socket connection to server 192.168.126.129/192.168.126.129:2181. Will not attempt to authenticate using SASL (unknown error) 2019-09-19 17:12:48.082 [main-SendThread(192.168.126.129:2181)] INFO org.apache.zookeeper.ClientCnxn:876 - Socket connection established to 192.168.126.129/192.168.126.129:2181, initiating session 2019-09-19 17:12:48.084 [main-SendThread(192.168.126.129:2181)] INFO org.apache.zookeeper.ClientCnxn:1158 - Unable to read additional data from server sessionid 0x2000001648c0000, likely server has closed socket, closing socket connection and attempting reconnect 2019-09-19 17:12:48.847 [main-SendThread(192.168.126.129:2183)] INFO org.apache.zookeeper.ClientCnxn:1032 - Opening socket connection to server 192.168.126.129/192.168.126.129:2183. Will not attempt to authenticate using SASL (unknown error) 2019-09-19 17:12:48.848 [main-SendThread(192.168.126.129:2183)] INFO org.apache.zookeeper.ClientCnxn:876 - Socket connection established to 192.168.126.129/192.168.126.129:2183, initiating session 2019-09-19 17:12:48.850 [main-SendThread(192.168.126.129:2183)] INFO org.apache.zookeeper.ClientCnxn:1158 - Unable to read additional data from server sessionid 0x2000001648c0000, likely server has closed socket, closing socket connection and attempting reconnect
6、结论:也就是说,整个ZooKeeper集群宕机并丢失所有数据后,重启ZooKeeper集群,此时需要重启业务系统。
而当整个ZooKeeper集群宕机,但是没有丢失数据时,重启ZooKeeper集群后不用重启业务系统。(因为ZooKeeper服务端存储的数据包含了服务端和客户端之间session信息。)
dubbo服务会自动探测ZooKeeper运行状态,当ZooKeeper可用后,providers会把服务发布到ZooKeeper注册中心,consumers也会订阅ZooKeeper注册中心。
上述就是小编为大家分享的ZooKeeper注册中心重启后会对Dubbo服务发布/订阅造成什么影响了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注亿速云行业资讯频道。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。