No leader elected
Can not start Nomad cluster cause it can not elect leader. Demo: https://youtu.be/fHDPjS5JGCw
Nomad v0.4.1 Consul v0.7.0
server.hcl:
data_dir = "/var/nomad/server"
datacenter = "dataline"
bind_addr = "0.0.0.0"
advertise {
rpc = "192.168.11.XX:4647"
}
server {
enabled = true
bootstrap_expect = 3
}
consul {
# The address to the Consul agent.
address = "127.0.0.1:8500"
# The service name to register the server and client with Consul.
server_service_name = "nomad"
client_service_name = "nomad-client"
# Enables automatically registering the services.
auto_advertise = true
# Enabling the server and client to bootstrap using Consul.
server_auto_join = true
client_auto_join = true
}
Try to advertise serf address in config like
advertise {
rpc = "192.168.11.XX:4647"
serf = "192.168.11.XX:4648"
}
Oh, sorry. I misunderstood, that you have one DC and serf is not needed.
Even I set explicitly addresses for all services (res, serf, http) for advertise and for addresses I get the same:
2016/11/08 12:22:30 [WARN] raft: Election timeout reached, restarting election
2016/11/08 12:22:30 [INFO] raft: Node at 192.168.11.18:4647 [Candidate] entering Candidate state
2016/11/08 12:22:30 [ERR] raft: Failed to make RequestVote RPC to 127.0.0.1:4647: dial tcp 127.0.0.1:4647: getsockopt: connection refused
2016/11/08 12:22:30 [ERR] raft: Failed to make RequestVote RPC to 127.0.0.1:4647: dial tcp 127.0.0.1:4647: getsockopt: connection refused
2016/11/08 12:22:30 [ERR] raft: Failed to make RequestVote RPC to 127.0.0.1:4647: dial tcp 127.0.0.1:4647: getsockopt: connection refused
2016/11/08 12:22:30.660736 [ERR] worker: failed to dequeue evaluation: No cluster leader
2016/11/08 12:22:32 [WARN] raft: Election timeout reached, restarting election
2016/11/08 12:22:32 [INFO] raft: Node at 192.168.11.18:4647 [Candidate] entering Candidate state
2016/11/08 12:22:32 [ERR] raft: Failed to make RequestVote RPC to 127.0.0.1:4647: dial tcp 127.0.0.1:4647: getsockopt: connection refused
2016/11/08 12:22:32 [ERR] raft: Failed to make RequestVote RPC to 127.0.0.1:4647: dial tcp 127.0.0.1:4647: getsockopt: connection refused
2016/11/08 12:22:32 [ERR] raft: Failed to make RequestVote RPC to 127.0.0.1:4647: dial tcp 127.0.0.1:4647: getsockopt: connection refused
2016/11/08 12:22:33 [WARN] raft: Election timeout reached, restarting election
2016/11/08 12:22:33 [INFO] raft: Node at 192.168.11.18:4647 [Candidate] entering Candidate state
2016/11/08 12:22:33 [ERR] raft: Failed to make RequestVote RPC to 127.0.0.1:4647: dial tcp 127.0.0.1:4647: getsockopt: connection refused
2016/11/08 12:22:33 [ERR] raft: Failed to make RequestVote RPC to 127.0.0.1:4647: dial tcp 127.0.0.1:4647: getsockopt: connection refused
2016/11/08 12:22:33 [ERR] raft: Failed to make RequestVote RPC to 127.0.0.1:4647: dial tcp 127.0.0.1:4647: getsockopt: connection refused
2016/11/08 12:22:35 [WARN] raft: Election timeout reached, restarting election
2016/11/08 12:22:35 [INFO] raft: Node at 192.168.11.18:4647 [Candidate] entering Candidate state
2016/11/08 12:22:35 [ERR] raft: Failed to make RequestVote RPC to 127.0.0.1:4647: dial tcp 127.0.0.1:4647: getsockopt: connection refused
2016/11/08 12:22:35 [ERR] raft: Failed to make RequestVote RPC to 127.0.0.1:4647: dial tcp 127.0.0.1:4647: getsockopt: connection refused
2016/11/08 12:22:35 [ERR] raft: Failed to make RequestVote RPC to 127.0.0.1:4647: dial tcp 127.0.0.1:4647: getsockopt: connection refused
The main question is about: why servers trying to make RPC RequestVote call to 127.0.0.1:4647 when addresses was set explicitly?
This is a sample configuration of server.hcl from one of servers:
data_dir = "/var/nomad/server"
datacenter = "dataline"
bind_addr = "192.168.11.18"
addresses {
rpc = "192.168.11.18"
http = "192.168.11.18"
serf = "192.168.11.18"
}
advertise {
rpc = "192.168.11.18:4647"
http = "192.168.11.18:4648"
serf = "192.168.11.18:4649"
}
server {
enabled = true
bootstrap_expect = 3
retry_join = ["192.168.11.16:4648", "192.168.11.20:4648"]
}
consul {
#address = "127.0.0.1:8500"
address = "192.168.11.18:8500"
server_service_name = "nomad"
client_service_name = "nomad-client"
auto_advertise = true
server_auto_join = true
}
Here is a run string: nomad agent -config=/etc/nomad.d/server.hcl
@AlexSnet We will have an RC2 out shortly. Hopefully you can test on that. There have been a lot of fixes with bind/advertise address and the consul integration
@AlexSnet I think I have an idea of what is happening. Can you do a nomad server-members and also cat <nomad data_dir>/raft/peers.json. My hypothesis is that the nodes advertised localhost and it got added to the raft peers and now you added correct advertise IPs but the nodes think that the cluster size is 6 and not 3 so you are never getting a leader.
The fix will be to stop the servers, modify the peers.json to reflect the correct servers (delete the localhost address) and then restart the servers.
@dadgar I think I am having the same issue, even though I am using nomad 0.5.0. In my peers.json I see only address of the server itself, not other peers. Does it have to be IPs of all three servers?
As a small correction, the path is not <nomad data_dir>/raft/peers.json but <nomad data_dir>/server/raft/peers.json
And do you have an idea how to make this fix reproducible (I mean if I do the deployment to the new environment and get the same issue)? Although it is more or less rhetorical question. Do you know if this file be recreated if I delete it completely?
@mlushpenko It does have contain all the servers. I would check if nomad server-memberscontains the servers. If it does not just issue a server-join. The way to avoid this is when rolling servers you must force-leave the servers after removing them. We will hopefully making this process easier in an upcoming 0.5.x release with a new operator command
@dadgar nomad server-members had servers, they were all alive but without leader. I got the same issue in vagrant dev setup and in production (with IP tables and different network bindings).
In dev, I fixed that by removing server folder - it was recreated during the next Jenkins/Ansible run. In production, however, the server folder didn't recreate itself for some reason, so I had to delete the whole nomad folder to make it work. (we are just configuring production now, in reality I guess I would lose some data by doing that).
In addiiton, my first test was just to remove peers.json file as I checked the source code and looks like it is recreated during the server startup. But it wasn't the case, so I started removing folders.
This issue will be auto-closed because there hasn't been any activity for a few months. Feel free to open a new one if you still experience this problem :+1:
I'm going to lock this issue because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.