1 下载zookeeper
Apache 版本下载地址:https://archive.apache.org/dist/
CDH 版本下载地址:http://archive-primary.cloudera.com/cdh5/cdh/5/
根据需要下载自己的版本即可。
我习惯将软件安装在/data目录下 ,
2 解压Zookeeper
tar -zxvf zookeeper-3.4.5-cdh5.10.0.tar.gz
3 修改配置文件
首先进入config目录下:
拷贝配置文件:
cp zoo_sample.cfg 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=/data/zookeeper/zkdata
#日志目录需要提前创建
dataLogDir=/data/zookeeper/zkdatalog
# the port at which the clients will connect
clientPort=2181
#
# 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
#server.每个节点服务编号=服务器ip地址:集群通信端口:选举端口
server.1=10.1.1.18:2888:3888
#server.2=hadoop02:2888:3888 根据自己的节点情况进行配置
#server.3=hadoop03:2888:3888
注:配置集群 直接将上述配置好的分发到其他节点即可
4 修改每个节点服务编号
进入/data/zookeeper/zkdata 目录,创建myi的文件
主节点可以在myid里面写入1
注:各个节点之前必须保持不同
5 测试运行
/bin/zkServer.sh start
出现如下内容说明启动成功