Some issues related to zookeeper


1. What is zookeeper?

zookeeper is a distributed, open source distributed application coordination service, an open source implementation of google chubby, and an important component of hadoop and hbase. It is a software that provides consistent services for distributed applications. The functions provided include: configuration maintenance, domain name services, distributed synchronization, group services, etc.

2. What are the functions of zookeeper?

Cluster management: monitor the survival status of nodes, operation requests, etc.
Primary node election: After the primary node hangs up, a new round of primary election can be started from the standby node. The primary node election refers to this election process, and zookeeper can assist in this process.
Distributed locks: Zookeeper provides two types of locks: exclusive locks and shared locks. Exclusive lock means that only one thread can use resources at a time. Shared lock means read lock sharing and read-write mutual exclusion. That is, multiple threads can read the same resource at the same time. If a write lock is to be used, only one thread can use it. Zookeeper can control distributed locks.
Naming service: In a distributed system, by using a naming service, client applications can obtain resource or service address, provider and other information based on the specified name.

3. How many deployment modes does zookeeper have?

There are mainly three deployment modes
1. Single-machine deployment: one zk deployed on one server (run on one cluster;)
2. Cluster deployment: multiple zk deployed on multiple servers (multiple clusters run;)
3. Pseudo cluster deployment: One server deploys multiple zk (a cluster starts multiple zookeeper instances to run;)

Fourth, how does zookeeper ensure that the status of the master and slave nodes are synchronized?

The core of zk is atomic broadcasting. This mechanism ensures synchronization between various servers. The protocol that implements this mechanism is called the zab protocol. The zab protocol has two modes, namely recovery mode (primary selection) and broadcast mode (synchronization). When the service is started or after the leader collapses, zab enters the recovery mode. When the leader is elected and most of the servers are synchronized with the leader's state, the recovery mode ends. State synchronization ensures that the leader and server have the same system state.

5. Why is there a master node in the cluster?

In a distributed environment, some business logic only needs to be executed by a machine in the cluster, and other machines can share this result, which can greatly reduce repeated calculations and improve performance, so a master node is required.

6. There are 3 servers in the cluster, and one of the nodes is down. Can zookeeper still be used at this time?

It can be used. The singular server can still be used as long as no more than half of the nodes in the cluster are down.

Seven, talk about the notification mechanism of zookeeper?

The client will create a watcher event for a znode. When the znode changes, these clients will be notified by zk, and then the client can make business changes based on the znode changes.

Guess you like

Origin blog.csdn.net/qq_42697271/article/details/113957764
Recommended