在云服务器CentOS7系统下搭建zookeeper集群遇到的问题

在要开启的三个zookeeper服务器的配置文件都配置完后,我开始运行服务器。
xshell开启三个窗口。运行第一个服务器时时显示如下:

[root@iZ2zef08gmoio8jyeyjvi7Z ~]# cd /usr/local/zookeeper-cluster/
[root@iZ2zef08gmoio8jyeyjvi7Z zookeeper-cluster]# ./zk1/bin/zkServer.sh start
/usr/bin/java
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper-cluster/zk1/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@iZ2zef08gmoio8jyeyjvi7Z zookeeper-cluster]# ./zk1/bin/zkServer.sh status
/usr/bin/java
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper-cluster/zk1/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost. Client SSL: false.
Error contacting service. It is probably not running.

一个服务器不足以选举Leader。那开启第二个服务器。

[root@iZ2zef08gmoio8jyeyjvi7Z ~]# cd /usr/local/zookeeper-cluster/
[root@iZ2zef08gmoio8jyeyjvi7Z zookeeper-cluster]# ./zk1/bin/zkServer.sh start
/usr/bin/java
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper-cluster/zk2/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@iZ2zef08gmoio8jyeyjvi7Z zookeeper-cluster]# ./zk2/bin/zkServer.sh status
/usr/bin/java
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper-cluster/zk2/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost. Client SSL: false.
Error contacting service. It is probably not running.

结果还是一样的…
Client port found: 2181. Client address: localhost. Client SSL: false.
Error contacting service. It is probably not running.

开启第三个服务器依然是这样。这让我又去检查了一遍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=/usr/local/zookeeper-cluster/zk1/data
#zookeeper的日志目录
dataLogDir=/usr/local/zookeeper-cluster/zk1/log
# the port at which the clients will connect
clientPort=2181
# 集群的配置文件
#第几个服务器(123来自数据目录的一个myid文件,该文件里面保存着当前集群的标识(123))
# 后面的ip代表将绑定那个ip地址 第一个端口:代表在集群内部,数据复制的接口 第二个端口代表:选举##端口
server.1=172.27.36.23:2888:3888
server.2=172.27.36.23:2889:3889
server.3=172.27.36.23:2887:3887

# the maximum number of client connections.
"./zk1/conf/zoo.cfg" 37L, 1421C            

感觉没啥问题。想了半天突然想到是不是ip地址写错了,我写的是公网ip,那换成私网ip。更改完成后再按上面步骤来一遍。结果如下:

在这里插入图片描述

终于成功了。Mode:follower。虽然还是不太明白为啥要用私网ip。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

墨末..

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值