Zookeeper注册中心的搭建(一) zookeeper安装与启动

林炳文Evankaka原创作品。转载请注明出处http://blog.csdn.net/evankaka

参考:https://blog.csdn.net/evankaka/article/details/47858707

        ZooKeeper是一个分布式的,开放源码的分布式应用程序协调服务,是Google的Chubby一个开源的实现,是Hadoop和Hbase的重要组件。它是一个为分布式应用提供一致性服务的软件,提供的功能包括:配置维护、名字服务、分布式同步、组服务等。

       Dubbo是Alibaba开源的分布式服务框架,它最大的特点是按照分层的方式来架构,使用这种方式可以使各个层之间解耦合(或者最大限度地松耦合)。从服务模型的角度来看,Dubbo采用的是一种非常简单的模型,要么是提供方提供服务,要么是消费方消费服务,所以基于这一点可以抽象出服务提供方(Provider)和服务消费方(Consumer)两个角色。关于注册中心、协议支持、服务监控等内容。

一、zookeeper安装与启动

  首先需要安装JdK,从Oracle的Java网站下载,安装很简单,就不再详述。其中zookeeper的下载地址是http://www.apache.org/dyn/closer.cgi/zookeeper/,下载后直接解压,不用安装。

        在你执行启动脚本之前,还有几个基本的配置项需要配置一下,Zookeeper 的配置文件在 conf 目录下,这个目录下有 zoo_sample.cfg 和 log4j.properties,你需要做的就是将 zoo_sample.cfg 改名为 zoo.cfg,因为 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:\\Java\\Tool\\zookeeper-3.4.6\\tmp
# 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

把dataDir=/tmp/zookeeper改成 dataDir=D:/Tools/apache/zookeeper-3.4.14/tmp

这里可以改成自己喜欢的其中,

 tickTime:这个时间是作为 Zookeeper 服务器之间或客户端与服务器之间维持心跳的时间间隔,
也就是每个 tickTime 时间就会发送一个心跳。
    dataDir:顾名思义就是 Zookeeper 保存数据的目录,默认情况下,Zookeeper 将写数据的日志文件也保存在这个目录里。
    dataLogDir:顾名思义就是 Zookeeper 保存日志文件的目录
    clientPort:这个端口就是客户端连接 Zookeeper 服务器的端口,Zookeeper 会监听这个端口,接受客户端的访问请求。
 
当这些配置项配置好后,你现在就可以启动 Zookeeper 了,启动后要检查 Zookeeper 是否已经在服务,
可以通过 netstat – ano 命令查看是否有你配置的 clientPort 端口号在监听服务

单机安装非常简单,只要获取到 Zookeeper 的压缩包并解压到某个目录如:D:\Java\Tool\zookeeper-3.4.6下,Zookeeper 的启动脚本在 bin 目录下,Windows 下的启动脚本是bin文件下的如,D:\Java\Tool\zookeeper-3.4.6\bin\ zkServer.cmd。
Zookeeper注册中心的搭建(一) zookeeper安装与启动_第1张图片

输入JPS,出现如下,也说明启动成功,则windows单机版zookeeper搭建成功!

Zookeeper注册中心的搭建(一) zookeeper安装与启动_第2张图片

上面的黑色框框不关,就表示注册中心一直开关的,一定要记得注册中心要在程序运行之前就打开,而且是一直开着的 

 

你可能感兴趣的:(Zookeeper)