0)下载地址https://zookeeper.apache.org/releases.html
1) 解压安装包
[root@master soft]# tar xvf apache-zookeeper-3.6.3-bin.tar.gz -C /opt/moudel/
2)修改解压后的文件名称:
[root@master moudel]#mv apache-zookeeper-3.6.3-bin zookeeper-3.6.3
3)进入/opt/moudel/zookeeper-3.6.3/conf目录下修改文件名称
[root@master conf]#mv zoo_sample.cfg zoo.cfg
4)新建两个文件夹
mkdir /opt/moudel/zookeeper-3.6.3/zkdata
mkdir /opt/moudel/zookeeper-3.6.3/zklogs
5)修改/opt/moudel/zookeeper-3.6.3/conf下的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=/opt/moudel/zookeeper-3.6.3/zkdata
dataLogDir=/opt/moudel/zookeeper-3.6.3/zklogs
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1
## Metrics Providers
#
# https://prometheus.io Metrics Exporter
#metricsProvider.className=org.apache.zookeeper.metrics.prometheus.PrometheusMetricsProvider
#metricsProvider.httpPort=7000
#metricsProvider.exportJvmInfo=true
server.1=master:2888:3888
server.2=slave1:2888:3888
server.3=slave2:2888:3888
6) 进入到/opt/moudel/zookeeper-3.6.3/zkdata目录下创建文件myid
vim myid
输入1
7)将zookeeper-3.6.3包复到其它两台机子上
scp -r zookeeper-3.6.3 root@slave1:/opt/moudel/
scp -r zookeeper-3.6.3 root@slave2:/opt/moudel/
8)修改其它两台机子上的myid分别输入2和3
9)设置环境变量
#ZOOKEEPER_HOME
export ZOOKEEPER_HOME=/opt/moudel/zookeeper-3.6.3
export PATH=$PATH:$ZOOKEEPER_HOME/bin
source /etc/profile
10)启动
bin/zkServer.sh start
bin/zkServer.sh start
11)查看结点状态
bin/zkServer.sh status
12)关闭结点
bin/zkServer.sh stop