ZK common interview questions

1.1.  ZAB what protocol is?

ZAB protocol for distributed coordination services Zookeeper an atomic broadcast protocol support crash recovery designed.

ZAB protocol includes two basic modes: the broadcast message and crash recovery.

When the whole zookeeper cluster has just started or Leader server is down, restart or network failure resulting in more than half of server and there is no Leader server to maintain normal communication, all processes (server) into the crash recovery mode, first elected a new Leader server and cluster in Follower server begins with the new Leader for data server synchronization, when a cluster than half of the machine with the Leader to complete the data server synchronization, exit recovery mode incoming messages broadcast mode, Leader server starts receiving the client's transaction request generating things proposals for transaction request processing.

 

1.2.  Znode What are the different types of

PERSISTENT- lasting node

Unless manually deleted, or node has been present in Zookeeper on

 

EPHEMERAL- temporary node

Lifecycle temporary node with the client session binding, once the client session expires (the client and the zookeeper disconnected session is not necessarily failure), then the client creates all temporary nodes will be removed.

 

PERSISTENT_SEQUENTIAL- lasting order of nodes

The basic characteristics of the same enduring node, only increased the order attribute, node name is appended behind an auto-incremented integer numbers maintained by the parent.

 

EPHEMERAL_SEQUENTIAL- temporary order of nodes

The basic characteristics of the node with the temporary increase of the order of attributes, node name is appended behind an auto-incremented integer numbers maintained by the parent.

 

 

1.3.  ACL access control mechanisms

UGOUser/Group/Others

Currently in Linux / Unix using the file system, but also the most widely used access control mode. It is a coarse-grained file system access control mode.

 

ACL ( Access Control List ) Access Control Lists

It includes three aspects:

 

Permissions mode ( Scheme )

IP : the IP authority control address size

Digest : The most commonly used, with similar username: password authority identification permission to configure, easy to distinguish between different applications to access control

World : access control most open way, is a special digest mode, there is only one authority identifier "world: anyone"

Super : Super User

Authorization object

Authorization object refers to permissions granted to a user or a designated entity, e.g. IP address or machine lights.

 

Permissions Permission

The CREATE : Create permission data node, allowing the authorization object in the Znode create a child node under

DELETE : delete child nodes permissions to allow authorization object to delete the data node's children

The READ : read permission data node, permitting authorized access to the data objects and read the data contents of the node or sub-node list, etc.

WRITE : data node update permissions to allow authorized object to update the data node

ADMIN : data node management authority that allows authorized data node object to the ACL settings operations

 

1.4.  ZK role which

Leader

Scheduling and unique transaction request handlers, assure an orderly cluster transaction

Within a cluster each service dispatcher

 

Follower

Non-transaction processing the client's request, forwarding the transaction request to the Leader server

Participating in a transaction request Proposal vote

Participation Leader elections

 

Observer

3.3.0 version introduced after a server role, without affecting the cluster transaction processing capabilities of the non-transactional capabilities to enhance the cluster

Non-transaction processing the client's request, forwarding the transaction request to the Leader server

Voting does not participate in any form of

 

1.5.  ZK Server operating condition which, can be more specific description

The server has four states, namely, LOOKING , FOLLOWING , LEADING , the observing .

LOOKING : looking Leader status. When the server is in this state, it does not think the current cluster Leader , it is necessary to enter the Leader election state.

FOLLOWING : follower state. It indicates that the current server role is Follower .

LEADING : leader state. It indicates that the current server role is a Leader .

The observing : observer status. It indicates that the current server role is the Observer .

 

1.6.  ZK of the watch mechanism is permanent

 no.

 

1.7.  ZK common client what

java client: ZK comes zkclient and Apache open source Curator

 

1.8.  Distributed Lock with zk how to achieve

  There are two implementations, look at the specific course code

 

1.9.  Zk What is the default communication framework

Nio, can change netty

 

1.10.  Message broadcasting process

 

 

l Leader After receiving the request message, the message is assigned a globally unique 64 position self-increasing ID , it is called: zxid , by zxid size to achieve more orderly cause this feature.

l Leader by FIFO queue ( via TCP to implement the protocol, in order to achieve this feature global order ) will with zxid message as a proposal (Proposal) distributed to all follower .

When the follower receives a proposal , first proposal is written to the hard drive, write to the hard disk after a successful leader back an ACK .

When the leader receiving the valid number of ACKs after, leader on all follower send COMMIT command, the message will be performed locally.

When the follower received message COMMIT command, the message will be performed

 

 

1.11.  Leadership election process

 

 

Each Server will issue a vote , for the first time they are to vote themselves. Voting information :( myid , ZXID )

collect votes from each server

processing voting and vote again, the processing logic: first Compare ZXID, then compare myid

Statistical vote, as long as more than half of the voting machines receive the same information, you can determine the leader

change the server status

Guess you like

Origin www.cnblogs.com/Soy-technology/p/11404347.html