最新的版本可以通过官网 http://hadoop.apache.org/zookeeper/来获取,Zookeeper 的安装非常简单,下面将从单机模式和集群模式两个方面介绍 Zookeeper 的安装和配置。
单机模式
解压安装包zookerper-3.4.7.tar.gz
1tar -xzvf zookerper-3.4.7.tar.gz创建Zookeeper子目录
1cp -r zookerper-3.4.7 zookerper修改Zookeeper配置文件conf/zoo.cfg
1234567891011121314151617181920212223242526272829# The number of milliseconds of each ticktickTime=2000# The number of ticks that the initial# synchronization phase can takeinitLimit=10# The number of ticks that can pass between# sending a request and getting an acknowledgementsyncLimit=5# the directory where the snapshot is stored.# do not use /tmp for storage, /tmp here is just# example sakes.dataDir=./datadataLogDir=./logs# the port at which the clients will connectclientPort=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运行
12$ cd bin$ ./zkServer.sh start查看运行状态
1./zkServer.sh status
伪集群模式
新建两个directory
12cp -r zookeeper/ zookerper1/cp -r zookeeper/ zookerper2/修改Zookeeper配置文件conf/zoo.cfg,这里配置了3个实例
123server.1=localhost:2887:3887server.2=localhost:2888:3888server.3=localhost:2889:3889分别在data目录下添加myid文件
123echo "1" > myidecho "2" > myidecho "3" > myid分别运行3个实例