zookeeper安装解决

今天安装配置三台zookeeper服务集群,配置内容如下:

# 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=/var/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

server.1=192.168.249.97:2888:3888

server.2=192.168.249.157:2888:3888

server.1=192.168.249.187:2888:3888

安装配置完毕后,逐一启动三台服务器

(1)master

(2)slave0

(3)slave1

集群中三个zookeeper服务显示正常启动。然后在master服务器使用的telnet 命令检测集群工作状态,

[root@master bin]# telnet 127.0.0.1 2181

Trying 127.0.0.1...

Connected to 127.0.0.1.

Escape character is '^]'.

stat

This ZooKeeper instance is not currently serving requests

Connection closed by foreign host.

[root@master bin]# This ZooKeeper instance is not currently serving requestsUnable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect。

显示集群无法进行正常服务,后使用zkCli客户端进行连接测试。

2018-06-08 23:05:37,441 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1161] - Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect

2018-06-08 23:05:38,673 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1028] - Opening socket connection to server localhost/0:0:0:0:0:0:0:1:2181. Will not attempt to authenticate using SASL (unknown error)

2018-06-08 23:05:38,674 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@878] - Socket connection established to localhost/0:0:0:0:0:0:0:1:2181, initiating session

2018-06-08 23:05:38,677 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1161] - Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect

2018-06-08 23:05:39,571 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1028] - Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)

2018-06-08 23:05:39,572 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@878] - Socket connection established to localhost/127.0.0.1:2181, initiating session

2018-06-08 23:05:39,576 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1161] - Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect

2018-06-08 23:05:41,349 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1028] - Opening socket connection to server localhost/0:0:0:0:0:0:0:1:2181. Will not attempt to authenticate using SASL (unknown error)

2018-06-08 23:05:41,351 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@878] - Socket connection established to localhost/0:0:0:0:0:0:0:1:2181, initiating session

2018-06-08 23:05:41,352 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@1161] - Unable to read additional data from server sessionid 0x0, likely server has closed socket, closing socket connection and attempting reconnect

客户端也显示无法进行正常的服务。

这种情况原因是集群没有能够选举出Leader,在启动时正常已经启动三个机器的zookeeper服务,因此,可能是防火墙导致zookeeper服务端口无法进行相互访问。在集群中每台机器中配置防火墙设置。

firewall-cmd --zone=public --add-port=2181/tcp --permanent

firewall-cmd --zone=public --add-port=2888/tcp --permanent

firewall-cmd --zone=public --add-port=3888/tcp --permanent

firewall-cmd --reload

逐次重新启动,zookeeper,OK。

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • ** 今天看了一下kafka官网,尝试着在自己电脑上安装和配置,然后学一下官方document。** Introd...
    RainChang阅读 10,438评论 1 30
  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 135,412评论 19 139
  • 1.配置java环境变量 这部分主要分为两个内容,一是卸载OpenJDK,二是安装Sun JDK。 1.1卸载Op...
    9cain阅读 5,894评论 0 1
  • 1、准备 在分析探索Dubbo架构原理之前,我们需要准备一下环境,用于后面我们来分析dubbo的架构。 1.1 Z...
    墨渊丶阅读 7,497评论 1 20
  • 随便翻看了下 大家写的都非常漂亮!献丑了献丑了 默默地把今天的文章水掉了……
    黄小饼阅读 2,555评论 0 2