两台服务器搭建zookeeper集群

两台服务器搭建zookeeper集群

ZooKeeper做三节点集群,启动后报错如下:

[root@centos conf]# zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /usr/local/src/zookeeper-3.4.10/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@centos conf]# zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/local/src/zookeeper-3.4.10/bin/../conf/zoo.cfg
Error contacting service. It is probably not running.



解决方案:

1.首先关闭防火墙,三台机器之间无法正常通信。

2.创建数据目录,zoo.cfg配置文件里dataDir指定的那个目录下创建myid文件,并且指定id,改id为你zoo.cfg文件中server.1=ip:2888:3888中的1.只要在myid头部写入1即可.同理其它两台机器的id对应上。

比如第一台机器cfg文件:



配置相应的myid为:1


配置文件

# 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-3/data
dataLogDir=/usr/local/zookeeper-3/data
# the port at which the clients will connect
clientPort=12183
server.1=172.35.36.210:2888:3387
server.2=172.35.36.210:2889:3388
server.3=172.35.36.211:2890:3390

# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60

这里有个坑
server.1=172.35.36.210:2888:3387
server.2=172.35.36.210:2889:3388
server.3=172.35.36.211:2890:3390

2888
2889
2890
不能和端口一致,否则会报错

你可能感兴趣的:(两台服务器搭建zookeeper集群)