1.从Apache开源官网下载(二进制版,源码版本根据需要下载)
https://mirrors.tuna.tsinghua.edu.cn/apache/zookeeper/
2.下载二进制版
apache-zookeeper-3.5.6-zookpeeper-bin
3.直接放到你想要安装的目录
/home/virtul-cluster-zookeeper/
4.配置zoo.cfg
tickTime=2000
initLimit=10
syncLimit=5
dataDir=/home/virtul-cluster-zookeeper/apache-zookeeper-3.5.6-zookpeeper1-bin/zookeeper
clientPort=2181
server.1=127.0.0.1:2882:3882
server.2=127.0.0.1:2883:3883
server.3=127.0.0.1:2884:3884
在$dataDir 目录下创建 myid 内容为1 三个节点myid (1,2,3)
5.启动前配置JAVA环境变量
export JAVA_HOME=/home/jdk1.8.0_131
或者 echo "export JAVA_HOME=/home/jdk1.8.0_131" >> /etc/profile && source /etc/profile
6.启动zookeeper
./bin/zkServer.sh start
7.查看状态
./bin/zkServer.sh status
注意事项:
1.zoo.cfg 的server.x 中的x 对应myid值
2.dataDir 目录要配置正确
3.zookeeper 运行需要JAVA_HOME 环境变量
4.若要去除集群变成单机注释zoo.cfg 其它server.x
#server.1=127.0.0.1:2882:3882
#server.2=127.0.0.1:2883:3883
#server.3=127.0.0.1:2884:3884
启动后zookeeper 状态:Mode: standalone
原文地址:https://blog.51cto.com/13396187/2447826