Zookeeper interview questions with answers

Zookeeper interview questions with answers

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. Its functions include: configuration maintenance, domain name service, distributed synchronization, group service, etc.

What functions does zookeeper have?

Cluster management: monitor node survival status, running requests, etc.
Master node election: After the master node hangs up, a new round of master election can be started from the standby node. The master node election refers to the election process, and zookeeper can assist in completing this process.
Distributed locks: zookeeper provides two types of locks: exclusive locks and shared locks. An exclusive lock means that only one thread can use a resource at a time. A shared lock is shared by a read lock. Read-write mutual exclusion means that multiple threads can read the same resource at the same time. If you want to use a write lock, only one thread can use it. Zookeeper can control distributed locks.
Naming service: In a distributed system, by using the naming service, the client application can obtain information such as the address of the resource or service, the provider, etc. according to the specified name.

How many deployment modes does zookeeper have?

Zookeeper has three deployment modes:

Stand-alone deployment: running on one cluster;
cluster deployment: running on multiple clusters;
pseudo-cluster deployment: running multiple zookeeper instances on one cluster.

How does zookeeper ensure the state synchronization of master and slave nodes?

The core of zookeeper is atomic broadcast, which ensures the synchronization between servers. The protocol that implements this mechanism is called the zab protocol. The zab protocol has two modes, recovery mode (master election) and broadcast mode (synchronization). When the service starts or after the leader crashes, zab enters the recovery mode. When the leader is elected and most servers complete the state synchronization with the leader, the recovery mode ends. State synchronization ensures that the leader and server have the same system state.

Why is there a master node in the cluster?

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

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

It can continue to be used, and the singular server can continue to be used as long as no more than half of the servers are down.

Tell me about the notification mechanism of zookeeper?

The client will create a watcher event for a certain znode. When the znode changes, these clients will receive a notification from zookeeper, and then the client can make business changes according to the change of the znode.

Guess you like

Origin blog.csdn.net/seeseeyoua/article/details/128224655