Big data: zookeeper interview questions collection (3)

How the servers in the Zookeeper cluster communicate with each other

The communication between the follower and the leader is mainly because the follower receives commands such as ( create, delete, setData, setACL , createSession, closeSession, sync ) that require the leader to coordinate the final result, which will cause the follower and the leader to generate communication. Due to the one-to-many relationship between the leader and the follower , it is very suitable for the client/server mode. Therefore, the c/s mode is used between them. The leader creates a socket server to monitor the coordination requests of each follower .

How Zookeeper Clusters Work

https://blog.csdn.net/WYpersist/article/details/80189732

Zookeeper election mechanism

https://blog.csdn.net/WYpersist/article/details/80189709

 

The Leader server is the core of the entire zookeeper cluster work, responsible for the initiation and resolution of election votes, and updating the system status.

The Follower server is the follower of the zookeeper cluster state, which is used to receive the client's request and return the result to the client, and participate in voting in the election process.

1. After each Sever server starts, it will ask other Sever servers who to vote for

2. For inquiries from other servers, the server will restore the id of the recommended leader and the zxid of the last transaction according to its own status each time , but each server will recommend its own when the system starts.

3. After the server receives the replies from all other servers, it calculates the server with the largest zxid , and sets the relevant information of this server as the Sever to vote next time.

4. The server with the most votes obtained in the calculation process, and the server with more than half of the votes is selected as the leader , otherwise the election process must continue until the leader is elected.

5. The selected Leader starts to wait for the connection of the Follower of other servers

6. The Follower connects to the Leader and sends the largest zxid to the Leader

7. The Leader determines the synchronization point according to the zxid of the Follower . After the synchronization is completed, the Follower is notified that it has become the update (current) state.

8. After the Follower receives the update message, it can accept the Client 's request service.

zookeeper- port description , role

Port for synchronization and communication between different nodes of Zookeeper: election port (leader election)

1. Zookeeper has three ports (can be modified)

12181

23888

32888

Second, the role of 3 ports

1. 2181 : Provide services to the cline side

2. 3888 : used for electing the leader

3. 2888 : used for machine communication in the cluster ( leader listens to this port)

3. Pay attention when deploying

1. Single machine and single instance, as long as the port is not occupied

2. Stand-alone pseudo-cluster (single-machine, deploying multiple instances), the three ports must be modified to different groups

Such as: myid1 : 2181,3888,2888

myid2 : 2182,3788,2788

myid3 : 2183,3688,2688

3. Cluster (one machine deploys one instance)

Fourth, the cluster is greater than or equal to 3 cardinal numbers, such as 3 , 5 , 7.... It should not be too many. There are too many cluster machines. Election and data synchronization take a long time and are unstable. At present, I feel that the three elections + N observes are very good.

Why is zookeeper cluster singular?

https://blog.csdn.net/wypersist/article/details/80189573

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325551259&siteId=291194637