Zookeeper入门
发布日期:2021-05-09 09:33:56 浏览次数:14 分类:博客文章

本文共 8281 字,大约阅读时间需要 27 分钟。

zk������������

zk������

ZooKeeper ��������������������������������������������� Apache���ZooKeeper ��������������������������������������������������������������������������������������������������������������������������������� Paxos ���������ZAB ������������������������������������������������������������������������������������������������������������zookeeper ������������ http://zookeeper.apache.org

zk������������������

������������ Zookeeper ������������������zk ������������������������������������zk ������������������������������������������
Leader���������������������������������������������������������������������������
Follower������������������������������������������������������������������������������������������������������
������������������������������������������Leader���������������Leader���������������������������������������
������ Leader ���������������������������Leader ������������������������������������������������������������������
������������������
Observer��������������������������� Leader ��������� Follower������ Leader ������������������������������
��������������������������������� Leader ��������������������������������������� Follower ������������������
������������������Observer ������������������������������������������������������������������������������������
������������������������������ Leader ������������������������������������������

������������ Leader ������

������������zk������������������������������������Leader(���������Observer)������zk������������������������myid���zxid������������������zk���������������myid���������������������zxid������epoch(������������������������������leader������������������������������������������������������������ID���)+xid���������id������������������������������������������ID���������������zk������������������zk������������������������������������������������zxid���������������������zxid������������leader������zxid���������������myid������������leader���

CAP������

CAP ���������������������������������������������Consistency������������������������ Availability������������������������Partition tolerance���������������������������������������������
������������C���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
������������A������������������������������������������������������������������������������������������������������������������������������������������������������������������
������������������P������������������������������������������������������������������������������������������������������������������������������
zookeeper���������CP���������+���������������������eureka������������AP���������+���������������

������������

���������������������������������Leader���������������������Proposal������������Follower���Follower���������������������ACK������Leader���������ACK������������������������������Follower������commit������������������������������observer������proposal���observer���������������Follower���observer������������Leader������ACK���Leader������ACK���������follower���observer������������������������queues���������������Queues������������Follower���observer���������������������������������������������ZK���������������������������������������������������������������������������������������������������������ZK���������������������������������������������������������������������������������������������������������������������ZK������������������

zk������������

1 ���������������������VMware������������������������������������������������������zk���������������������

2 ��� http://zookeeper.apache.org ������������������������������������������������zk������jdk���������������������������������������jdk������������������������������������������������������������������ source /etc/profile ���������������������

 

 

3 ���������������������������������������������������������������myid������������leader���������������myid������������������������������������������������������������������������������������

4 ���������������zoo_sample.cfg���������������������������zoo.cfg

���������������������������������������������������������������������������������������������

# The number of milliseconds of each tick#���������������������������tickTime=2000# The number of ticks that the initial # synchronization phase can take#���������������������10���������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=/home/zk/zookeeper-3.4.14/data# the port at which the clients will connect#������clientPort=2181#������ip ���������������������������������������������������������������server.1=192.168.31.51:2888:3888server.2=192.168.31.39:2888:3888server.3=192.168.31.148:2888:3888server.4=192.168.31.27:2888:3888:observer# 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
View Code

���������observer���������������������������������������������������������

# The number of milliseconds of each tick#���������������������������tickTime=2000# The number of ticks that the initial # synchronization phase can take#���������������������10���������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=/home/zk/zookeeper-3.4.14/data# the port at which the clients will connect#������clientPort=2181#������ip ���������������������������������������������������������������server.1=192.168.31.51:2888:3888server.2=192.168.31.39:2888:3888server.3=192.168.31.148:2888:3888server.4=192.168.31.27:2888:3888:observer#���������������observerpeerType=observer# 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
View Code

5 ������������

 

 

 

 

6 ������������

���������������������������������2���leader���������������������2������������������������������������leader���������4���observer������������������������1 3���3���myid������������������3���leader

 

 

zk������������

���������������

zkCli.sh������������������������������������������������������zk������������������������������������������

 

������������

ls /path/path

zk������������������������������������������������������������������������������zookeeper���������zk������������

������������

������������

create /path value 

���������������������������������������������

������������

create -e /path value

���������������������������������������������

������������������������������������

���������������������������������������������������������������������������������������������������������������������������

 

������������

create -s /path value

���������������������������������������������������������������������������zk���������������������������������������������������������������������

������������������ 

create -e -s /path value

 

������������������

get /path/path/...

������������������������������������������������

������������������

������������

delete /path/path...

������������������������������������������������������������������������������������������������������������������

 

������������������

set /path/path... value

���������������������������������������������

 

 

 

 

 

 

 

 

 
 
 
 
 
 
 
 
 

 

 
 
 
 
上一篇:zuul中FallbackProvider不生效的原因
下一篇:Redis五种数据类型

发表评论

最新留言

留言是一种美德,欢迎回访!
[***.207.175.100]2025年04月12日 01时18分01秒