cd 下载
cd ..
在家目录创建一个zookeeper文件夹 然后安装
mkdir zookeeper
接下来将 下载里面的zookerper包 MV到刚刚创建的目录
解压
tar zxvf zookeeper-3.4.13.tar.gz
备份配置文件
cd conf
cp configuration.xsl{,.bak}
cp log4j.properties{,.bak}
cp zoo_sample.cfg{,.bak}
创建文件存放点
在自己创建的zookeeper文件架下创建一个自定义存放数据的目录
mkdir ZKdata
cd ZKdata
pwd
修改配置文件
cp zoo_sample.cfg zoo.cfg
vim 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=/home/ywz/zookeeper/zookeeper-3.4.13/zkdata
# 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
上面的 dataDir 路径改成刚刚配置文件路径
启动
启动的文件在bin目录下
cd bin/
./zkServer.sh start
ZooKeeper JMX enabled by default
Using config: /home/ywz/zookeeper/zookeeper-3.4.13/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
查看状态
./zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /home/ywz/zookeeper/zookeeper-3.4.13/bin/../conf/zoo.cfg
Mode: standalone # 表示的是单个主机
如果没启动查看状态的话就是
ZooKeeper JMX enabled by default
Using config: /home/ywz/zookeeper/zookeeper-3.4.13/bin/../conf/zoo.cfg
Error contacting service. It is probably not running.
停止服务
./zkServer.sh stop
ZooKeeper JMX enabled by default
Using config: /home/ywz/zookeeper/zookeeper-3.4.13/bin/../conf/zoo.cfg
Stopping zookeeper ... STOPPED
bin目录下的客户端
bin 目录下面有很多的客户端 可以直接./启动 后面不用加任何的参数
zkServer.sh
客户端如果进去的话则 quit 退出 ls / 查看当前节点
配置参数解读(# 就是翻译)
# 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=/home/ywz/zookeeper/zookeeper-3.4.13/zkdata
# 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