Build a Zookeeper cluster version [graphic tutorial]

In the production environment, the stand-alone mode is no longer applicable and needs to be changed to replicated mode.
In this mode, all nodes use the same configuration file.

Preparation

Zookeeper cluster rules

The Zookeeper cluster has the following rules:

  • 2N+1 machines, N > 0. An odd number of servers is recommended
  • The mechanism of the ZK cluster is that if more than half of the nodes are normal, the cluster is normal
  • When voting, by default, you will vote for yourself first

Why is an odd number of servers recommended? [ It can be seen here that a cluster of 3 machines has the same effect as a cluster of 4 machines, and only one machine can fail at most, so it must be that a cluster of 3 machines is better ]

  • If using 2 machines: 1 cannot fail
    • When one machine fails, there is one normal node, less than half, and the cluster is unavailable
  • If 3 machines are used: up to 1 machine failure is supported
    • When one machine fails, there are two normal machines, more than half, and the cluster is available
    • When two machines fail, there is one normal machine, not more than half, and the cluster is unavailable
  • If 4 machines are used: up to 1 machine failure is supported
    • When 1 machine fails, there are 3 normal machines, more than half, and the cluster is available
    • When 2 machines fail, there are 2 normal machines, not more than half, and the cluster is unavailable
  • If 5 machines are used: up to 2 machine failures are supported
    • When 1 machine fails, there are 4 normal machines, more than half of themÿ

Guess you like

Origin blog.csdn.net/u012383839/article/details/130574524