Zookeeper简介和安装(四)
一、简介:
Zookeeper是一个分布式协调服务,提供的服务如下:
命名服务:类似于DNS,但仅对于节点
配置管理:服务配置信息的管理
集群管理:Dubbo使用Zookeeper实现服务治理
分布式锁:选举一个leader,这样某一时刻只有一个服务在干活,当leader出问题时释放锁,立即切到另一个服务
二、下载:
链接:https://pan.baidu.com/s/1ba8eYSxqnR1MdCxvQqWMTA 密码:ie5r
三、三种安装模式:
单机、真分布集群模式、伪分布集群模式
四、伪分布式集群搭建:
1、进入C:zookeeper-3.3.6conf目录,将zoo_sample.cfg拷贝成3份,分别为:zoo1.cfg、zoo2.cfg、zoo3.cfg
zoo1.cfg内容:
#心跳时间 tickTime=2000 #初始连接能容忍最多心跳次数 initLimit=10 #leader与follower之间的通信时长 syncLimit=5 #保存数据的目录 dataDir=C:/zookeeper/zk1 #zk监听端口号 clientPort=2181 # server.1=master:2888:3888 server.2=slave1:2889:3889 server.3=slave2:2890:3890
zoo2.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 an acknowledgement syncLimit=5 # the directory where the snapshot is stored. dataDir=C:/zookeeper/zk2/ # the port at which the clients will connect clientPort=2182 server.1=master:2888:3888 server.2=slave1:2889:3889 server.3=slave2:2890:3890
zoo3.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 an acknowledgement syncLimit=5 # the directory where the snapshot is stored. dataDir=C:/zookeeper/zk3/ # the port at which the clients will connect clientPort=2183 server.1=master:2888:3888 server.2=slave1:2889:3889 server.3=slave2:2890:3890