1.首先通过zookeeper官网下载zookeeper的压缩包
2.将zookeeper的压缩包上传到服务器上
3.进入zookeeper目录下的bin目录,编辑zkEnv.sh文件
if [ "x${ZOO_LOG_DIR}" = "x" ]
then
ZOO_LOG_DIR="$ZOOKEEPER_PREFIX/runlogs"
fi
if [ "x${ZOO_LOG4J_PROP}" = "x" ]
then
ZOO_LOG4J_PROP="INFO,CONSOLE"
fi
更改ZOO_LOG_DIR属性和ZOO_LOG4J_PROP属性
ZOO_LOG_DIR: 生成zookeeper运行日志文件目录
- 进入zookeeper的conf目录,执行命令
cp zoo_sample.cfg zoo.cfg
将zoo_sample.cfg文件另存为zoo.cfg新文件 。 - 更改zoo.cfg配置文件内容
# The number of milliseconds of each tick
tickTime=5000
# The number of ticks that the initial
# synchronization phase can take
initLimit=30
# 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=/home/zookeeper/data
# the port at which the clients will connect
clientPort=2181
server.1=192.168.80.106:2188:3188
server.2=192.168.80.107:2188:3188
server.3=192.168.80.108:2188:3188
server.1 第一个node节点
server.2 第二个node节点
server.3 第三个node节点 2188
节点之间通讯端口 3188 节点之间选举leader端口
6.在你配置的zoo.cfg 的dataDir属性目录下新建myid文件,用来标识自己的broker id ,注意集群的话broker id不要重复
执行touch myid命令新建myid文件
7.在另外两台服务器上重复2-6步骤
8. 在zookeeper的bin目录下运行启动批处理文件
./zkServer.sh start
通过./zkServer.sh status来查看当前机器运行状态
mode: follower 代表是一个节点
mode: leader 代表是leader