apache-zookeeper-3.5.7 windows下的使用

ZooKeeper是一个为分布式应用所设计的分布的、开源的协调服务,它主要是用来解决分布式应用中经常遇到的一些数据管理问题,简化分布式应用协调及其管理的难度,提供高性能的分布式服务。ZooKeeper本身可以以Standalone模式安装运行,不过它的长处在于通过分布式ZooKeeper集群(一个Leader,多个Follower),基于一定的策略来保证ZooKeeper集群的稳定性和可用性,从而实现分布式应用的可靠性。ZooKeeper是作为分布式协调服务,是不需要依赖于Hadoop的环境,也可以为其他的分布式环境提供服务。

      zookeeper有单机、伪集群、集群三种部署方式,可根据自己对可靠性的需求选择合适的部署方式。下边对这三种部署方式逐一进行讲解。

安装jdk
安装Zookeeper. 在官网http://zookeeper.apache.org/下载zookeeper.我下载的是zookeeper-3.5.7版本。
解压apache-zookeeper-3.5.7-bin.tar.gz至D:\zkcluster\apache-zookeeper-3.5.7-bin-01
在D:\zkcluster\apache-zookeeper-3.5.7-bin-01 新建data及log目录。
ZooKeeper的安装模式分为三种,分别为:单机模式(stand-alone)、集群模式和集群伪分布模式。ZooKeeper 单机模式的安装相对比较简单,如果第一次接触ZooKeeper的话,建议安装ZooKeeper单机模式或者集群伪分布模式。

安装单击模式。 至D:\zkcluster\apache-zookeeper-3.5.7-bin-01\conf 复制 zoo_sample.cfg 并粘贴到当前目录下,命名zoo.cfg.

# The number of milliseconds of each tick
tickTime=6000
# 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:\\zkcluster\\apache-zookeeper-3.5.7-bin-01\\data
dataLogDir=D:\\zkcluster\\apache-zookeeper-3.5.7-bin-01\\log
# the port at which the clients will connect
clientPort=5181

 cmd命令下进入D:\zkcluster\apache-zookeeper-3.5.7-bin-01\bin目录下运行zkserver.cmd 即可

启动完成后cmd命令下,netstat-ano查看端口监听服务。

 

二、伪集群模式
伪集群模式就是在同一主机启动多个zookeeper并组成集群,下边以在一台主机上创3个zookeeper组集群为例。将单节点的zookeeper,复制成三份。

 apache-zookeeper-3.5.7 windows下的使用_第1张图片

2.1 zookeeper1配置
zookeeper1配置文件修改如下:D:\zkcluster\apache-zookeeper-3.5.7-bin-01\bin\zoo.cfg

# The number of milliseconds of each tick
tickTime=6000
# 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:\\zkcluster\\apache-zookeeper-3.5.7-bin-01\\data
dataLogDir=D:\\zkcluster\\apache-zookeeper-3.5.7-bin-01\\log
# the port at which the clients will connect
clientPort=5181
server.1=localhost:2888:3888
server.2=localhost:4888:5888
server.3=localhost:6888:7888
# 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

每个相应的/data目录下 创建 myid文件,填写对应的编号。

 apache-zookeeper-3.5.7 windows下的使用_第2张图片

apache-zookeeper-3.5.7 windows下的使用_第3张图片 

启动zookeeper,启动顺序随意没要求。

apache-zookeeper-3.5.7 windows下的使用_第4张图片 

你可能感兴趣的:(Zookeeper)