I will update what I did:
Little Background: We scaled down the AWS Autoscaling so lost the leader. But we had one server still running but without any leader.
What I did was:
- I scaled up to 3 servers(don't make 2-4)
- stopped consul in all 3 servers.
sudo service consul stop
(you can do status/stop/start)
- created peers.json file and put it in old server(/opt/consul/data/raft)
- start the 3 servers (peers.json should be placed on 1 server only)
- For other 2 servers join it to leader using
consul join 10.201.8.XXX
- check peers are connected to leader using
consul operator raft list-peers
Sample peers.json file
[
{
"id": "306efa34-1c9c-acff-1226-538vvvvvv",
"address": "10.201.n.vvv:8300",
"non_voter": false
},
{
"id": "dbeeffce-c93e-8678-de97-b7",
"address": "10.201.X.XXX:8300",
"non_voter": false
},
{
"id": "62d77513-e016-946b-e9bf-0149",
"address": "10.201.X.XXX:8300",
"non_voter": false
}
]
These id you can get from each server in /opt/consul/data/
[root@ip-10-20 data]# ls
checkpoint-signature node-id raft serf
[root@ip-10-1 data]# cat node-id
Some useful commands:
consul members
curl http://ip:8500/v1/status/peers
curl http://ip:8500/v1/status/leader
consul operator raft list-peers
cd opt/consul/data/raft/
consul info
sudo service consul status
consul catalog services