1,要搭建zookeeper集群先得装好java环境.

2,做好时间同步,关掉防火墙和selinux.

3,配置文件内容:

zookeeper配置文件内容:

[root@t01 zookeeper-3.4.6]# cat conf/zoo.cfg 

tickTime=2000

initLimit=5

syncLimit=2

dataDir=/tmp/zookeeper

clientPort=2181

server.1=zoo1:2888:3888

server.2=zoo2:2888:3888

server.3=zoo3:2888:3888

maxClientCnxns=500

4,还需要在hosts文件里做个绑定:

[root@t01 zookeeper-3.4.6]# cat /etc/hosts

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4

::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

172.16.226.11 zoo1

172.16.226.12 zoo2

172.16.226.13 zoo3

5,在zookeeper配置文件定义的数据目录下写上每个节点数字比如:

[root@t01 zookeeper-3.4.6]# cat /tmp/zookeeper/myid 

1

然后启动zookeeper服务:bash bin/zkServer.sh start,后查看zookeeper进程.