1.在apache官网找到下载地址
$ wget http://mirror.bit.edu.cn/apache/zookeeper/stable/zookeeper-3.4.10.tar.gz
2.解压tar.gz包
$ tar zxvf zookeeper-3.4.10.tar.gz
3.切换到conf目录下
$ cd zookeeper-3.4.10/conf
4.复制zoo_sample.cfg并重命名为zoo.cfg
$ cp zoo_sample.cfg zoo.cfg
4.修改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=/usr/zookeeper
dataLogDir=/usr/zookeeper/log
# 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
5.配置环境变量,分别执行以下命令(这里/home/sj/environment/是我的zookeeper解压目录)
$ export ZOOKEEPER_INSTALL=/home/sj/environment/zookeeper-3.4.10
$ export PATH=$PATH:$ZOOKEEPER_INSTALL/bin
6.启动zookeeper服务(切换到bin目录),需要root权限
$ cd bin
$ sudo ./zkServer.sh start
7.停止zookeeper服务
$ ./zkServer.sh stop