windows安装zookeeper(单机模式)

Zookeeper是一个高效的分布式协调服务,可以提供配置信息管理、命名、分布式同步、集群管理、数据库切换等服务。它不适合用来存储大量信息,可以用来存储一些配置、发布与订阅等少量信息。Hadoop、Storm、消息中间件、RPC服务框架、分布式数据库同步系统,这些都是Zookeeper的应用场景。

它有如下的一些特点:

  • 简单:Zookeeper的核心是一个精简的文件系统,它支持一些简单的操作和一些抽象操作,例如,排序和通知。
  • 丰富:Zookeeper的原语操作是很丰富的,可实现一些协调数据结构和协议。例如,分布式队列、分布式锁和一组同级别节点中的“领导者选举”。
  • 高可靠:Zookeeper支持集群模式,可以很容易的解决单点故障问题。
  • 松耦合交互:不同进程间的交互不需要了解彼此,甚至可以不必同时存在,某进程在zookeeper中留下消息后,该进程结束后其它进程还可以读这条消息。
  • 资源库:Zookeeper实现了一个关于通用协调模式的开源共享存储库,能使开发者免于编写这类通用协议。

zookeeper的安装分为三种模式:单机模式、集群模式和伪集群模式。本节介绍windows下zookeeper的单机模式。

1. 下载zookeeper

从zookeeper官网下载3.4.13版本官网下载

2. 安装zookeeper

解压zookeeper-3.4.13.tar.gz到D:\devtool\zookeeper
在conf文件下zoo_sample.cfg复制一个文件为zoo.cfg

3. 修改配置文件

这里主要修改zookeeper的日志目录

# 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=D:\\devtool\\zookeeper\\data
dataLogDir=D:\\devtool\\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
  1. tickTime:这个时间是作为 Zookeeper 服务器之间或客户端与服务器之间维持心跳的时间间隔,也就是每个 tickTime 时间就会发送一个心跳。
  2. dataDir:顾名思义就是 Zookeeper 保存数据的目录,默认情况下,Zookeeper 将写数据的日志文件也保存在这个目录里。
  3. dataLogDir:顾名思义就是 Zookeeper 保存日志文件的目录
  4. clientPort:这个端口就是客户端连接 Zookeeper 服务器的端口,Zookeeper 会监听这个端口,接受客户端的访问请求。
4. 启动服务

进入D:\devtool\zookeeper\bin目录下,运行zkServer.cmd启动服务
zkServer

5. 测试服务

命令行进入D:\devtool\zookeeper\bin执行zkCli 127.0.0.1:2181
zkServer

猜你喜欢

转载自blog.csdn.net/AaronSimon/article/details/83066354