(十四)springmvc+mybatis+dubbo+zookeeper分布式架构 整合

考虑到我们的开发环境是在window上,为了部署运行方便,今天来简单介绍一下window安装zookeeper注册中心。

1. 简介

ZooKeeper是Hadoop的正式子项目,它是一个针对大型分布式系统的可靠协调系统,提供的功能包括:配置维护、名字服务、分布式同步、组服务等。ZooKeeper的目标就是封装好复杂易出错的关键服务,将简单易用的接口和性能高效、功能稳定的系统提供给用户。

2. 安装和配置

在apache的官方网站提供了好多镜像下载地址,然后找到对应的版本,目前最新的是3.3.6

下载地址:

http://mirrors.cnnic.cn/apache/zookeeper/zookeeper-3.3.6/zookeeper-3.3.6.tar.gz

Windows下安装

把下载的zookeeper的文件解压到指定目录

D:antzookeeper-3.3.6>

修改conf下增加一个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 anacknowledgement

syncLimit=5

# the directory where the snapshot isstored.  //镜像数据位置

dataDir=D:\data\zookeeper

#日志位置

dataLogDir=D:\logs\zookeeper

# the port at which the clients willconnect  客户端连接的端口

clientPort=2181

注:如果启动有报错提示cfg文件有错误,可以用zoo_sample.cfg内内容替代也是可以的

进入到bin目录,并且启动zkServer.cmd,这个脚本中会启动一个java进程

也可以双击zkServer.cmd启动即可:



 架构代码如下:

资料和源码来源

原文地址:https://www.cnblogs.com/xiamudaren/p/8440797.html