Zookeeper study notes

1. View the log method to start zookper
./zkServer.sh start-foreground

Zookeeper's system model Znode
type:
persistent node,
persistent sequential node,
temporary node; the life cycle is bound to the session, temporary nodes cannot create nodes,
temporary sequential nodes

Transaction ID ZID
understand the characteristics of transactions: atomic consistency, isolation, durability,
a transaction idZID will be assigned in Zookeeper

Watcher
sends a message to a specific node and will make certain actions after it is monitored.
ACL-to ensure data security (ie permission)
permission mode
1.Ip
2.Digest BASE64 ((SH-1))
3.World
4.Super
authorization object
The authorization objects of different permission modes are the same. The
permission is the operation of the node
create
delete
read
write
admin

The operation of the zookeeper command on the node

./zkcli.sh -server to connect to the local zookeeper server.
/zkcli.sh -server ip:port to connect to the server

Operations on the node create get ls delete set

Establish a session

Use Api to operate zk

The way of using ZKClient The way of
using Curator is
the application scenario of zk
1. Data publishing/subscribing
combined push-pull method
The storage of public configuration files
Normally, when the application starts, it will go to zk for a configuration file acquisition and specify it at the same time Obtain watcher monitoring on the node of the node. Once a change occurs, all subscribed clients can get notifications of data changes.
2. Naming service
Generates a global unique id using sequential nodes
Each client creates a sequential node according to its own task type

3. Cluster management
Use zk's watcher and the two major features of temporary nodes.
The application of distributed log collection system. The
log collector collects log source
zk scenario steps
. 1. Collector registration and creation node
2. Task distribution:
log source grouping and writing to each Sub-nodes of each node
3. Status report
. Create status when creating a node. Collector's log collection progress at the node can be understood as heartbeat detection
. 4. Dynamic allocation.
If the collector is down or newly added, the log source needs to be allocated
1. Global Dynamic allocation
2. Partial dynamic allocation: The
collector will report its own load when reporting

4. MASTER election
Mass data processing and sharing model
How to use master
1. Under normal circumstances, according to the primary key characteristics of relational databases, insert the successful insert into the database as master
2. Use all clients of zk to create nodes zk nodes are strong Consistency, only one client can be created successfully. If the creation is not successful, a child node will be created on a temporary node. If the master hangs up, it can be re-elected.
5. Exclusive lock
Zk realizes an exclusive lock similar to the master mechanism
1. Definition A lock
2. Acquire the lock
3. Release the lock

6. Distributed barriers
whether the child nodes meet the requirements

zk's zAB protocol

ZAB supports the atomic broadcast protocol for crash recovery.
Two modes:
crash recovery mode and message broadcast mode.
Running state
LOOKING
FOLLOWING
LEADING

Guess you like

Origin blog.csdn.net/weixin_41118077/article/details/113121928