title | description | weight |
---|---|---|
How to conduct leader election in etcd cluster |
Guide to conducting leader election in an etcd cluster |
900 |
elect
for leader election:
- The
etcdctl
command is used to conduct leader elections in an etcd cluster. It makes sure that only one client become leader at a time. - Ensure the
ENDPOINTS
variable is set with the addresses of each etcd cluster members. - Set a unique name for the election for different clients ('one' in the given code below).
- Lastly, set different leaders name for each clients (p1 and p2).
Command format :
etcdctl --endpoints=$ENDPOINTS elect <election-name> <leader-name>
etcdctl --endpoints=$ENDPOINTS elect one p1
# another client with the same election name block
etcdctl --endpoints=$ENDPOINTS elect one p2