简介:
ZooKeeper是一个分布式的,开放源码的分布式应用程序协调服务,是Google的Chubby一个开源的实现,是Hadoop和Hbase的重要组件。它是一个为分布式应用提供一致性服务的软件,提供的功能包括:配置维护、域名服务、分布式同步、组服务等。 ZooKeeper的目标就是封装好复杂易出错的关键服务,将简单易用的接口和性能高效、功能稳定的系统提供给用户。 ZooKeeper包含一个简单的原语集,提供Java和C的接口。 ZooKeeper代码版本中,提供了分布式独享锁、选举、队列的接口,代码在$zookeeper_home\src\recipes。其中分布锁和队列有Java和C两个版本,选举只有Java版本。
1.安装JDK,这里就不再多说
2.安装Zookeeper
下载网址:https://zookeeper.apache.org/releases.html
下载解压后放到放入自己电脑文件夹(尽量文件夹中间不要有空格),我的位置是:D:\install\develop\registerCenter
下面是对文件的修改:
1.进入apache-zookeeper的conf目录下将zoo_sample.cfg重命名为zoo.cfg
2.配置文件中里面修改信息:
dataDir=D:\install\apache-zookeeper-3.5.7-bin\data
dataLogDir=D:\install\apache-zookeeper-3.5.7-bin\log
注:为你自己电脑下存储Zookeeper数据|日志的文件夹
我的配置文件如下:
# The number of milliseconds of each tick
#Zookeeper服务器之间或客户端与服务器之间维持心跳的时间间隔。就是每个这个时间段会发送一个心跳
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=D:\install\apache-zookeeper-3.5.7-bin\data
#保存日志的文件目录
dataLogDir=D:\install\apache-zookeeper-3.5.7-bin\log
# the port at which the clients will connect
#客户端连接Zookeeper服务器的商品,Zookeeper会监听这个端口,接受客户端的访问请求
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
admin.serverPort=8888
配置完成后bin目录下的zkServer.cmd
启动成功:
成功后可以启动一下bin目录下的zkCli.cmd来测试是否启动成功
成功: