Zookeeper--伪分布式集群

简介

zookeepr 动物管理员
动物管理员管理大象、海豚等动物(实例)
Welcome to Apache ZooKeeper™
Apache ZooKeeper is an effort to develop and maintain an open-source server which enables highly reliable distributed coordination.
Apache ZooKeeper致力于开发和维护一个支持高度可靠分布式协调的开源服务器。
What is ZooKeeper?
ZooKeeper is a centralized service for maintaining configuration information, naming, providing distributed synchronization, and providing group services. All of these kinds of services are used in some form or another by distributed applications. Each time they are implemented there is a lot of work that goes into fixing the bugs and race conditions that are inevitable. Because of the difficulty of implementing these kinds of services, applications initially usually skimp on them, which make them brittle in the presence of change and difficult to manage. Even when done correctly, different implementations of these services lead to management complexity when the applications are deployed.

zookeeper管理用户存放的数据采用类似于文件树的结构,每一个节点为node,每个node数据大小<1M

伪分布式部署

  1. zookeeper安装包解压三份
  2. /config/ 下创建配置文件zoo.cfg

tickTime=2000

initLimit=10

syncLimit=5

dataDir=/home/fcc/opt/zookeeper/apache-zookeeper-3.5.6-bin/data

clientPort=2181

server.0=zookeeper0:2888:3888
server.1=zookeeper1:2889:3889
server.2=zookeeper2:2890:3890

  1. 工作目录(zoo.cfg中配置)下创建myid文件,内容为server索引,如上myid文件内容为0,1,2
  2. 启动集群,三个节点各自启动,bin/zkServer.sh start。关闭集群,zkServer.sh stop
    查看节点状态
    ./zkServer.sh status
    在这里插入图片描述
    在这里插入图片描述

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 an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just 
# example sakes. 工作目录,存储数据的地方
dataDir=/tmp/zookeeper
# the port at which the clients will connect 客户端连接端口
clientPort=2181

ZK的shell客户端

zkCli.sh
在这里插入图片描述
在这里插入图片描述
create /fcc_node 1000
get /fcc_node
set /fcc_node 2000

发布了317 篇原创文章 · 获赞 76 · 访问量 56万+

猜你喜欢

转载自blog.csdn.net/feicongcong/article/details/104187264