arj
arj

Reputation: 983

Consul Leader not found while writing data to consul

I am new in consul.In my case i have three servers.all are tuning state. When i checked leader information using following url "http://localhost:8500/v1/status/leader" getting the correct information

"192.168.10.7:8300"

Consul\data\raft have the following information

enter image description here

I could see some answers in stack.it didn't help me. Also try following command

-bootstrap-expect=3

showing an error given below

enter image description here

Error Log

Consul request failed with status [500]: No cluster leader

Am totally stuck.How can i fix this issue

Upvotes: 0

Views: 2062

Answers (1)

sunny jha
sunny jha

Reputation: 41

Use docker run -d -p 8400:8400 -p 8500:8500 -p 8600:53/udp --name node1 -h node1 progrium/consul -server -bootstrap-expect 3

Since we have given expect 3 it means its looking for three peers to get connected first and then it will bootstrap the servers.

1. docker run -d -p 8400:8400 -p 8500:8500 -p 8600:53/udp --name node1 -h node1 progrium/consul -server -bootstrap-expect 3 

docker inspect -f '{{.NetworkSettings.IPAddress}}' node1
Use the inspected IP to join with, in next three commands.

2. docker run -d  --name node2 -h node2 progrium/consul -server -join 172.17.0.2

3. docker run -d --name node3 -h node3 progrium/consul -server -join 172.17.0.2

4. docker run -d --name node4 -h node4 progrium/consul -server -join 172.17.0.2

And you can start your service now, it will get connected with consul.

Explanation:-

As said in docs Before a Consul cluster can begin to service requests, a server node must be elected leader. And this is reason of your exception on start of spring-boot service the leader has not been elected yet!!

Why the leader has not been elected? The list of servers involved in the cluster should be bootstrapped. And the servers can be bootstrapped using the -bootstrap-expect configuration option. Recommended

Note:- Just for testing/learning purpose you can go ahead and create a single server because A single server deployment is highly discouraged as data loss is inevitable in a failure scenario.

Upvotes: 2

Related Questions