我是 Consul 的新手,我创建了一个带有 2 个服务器节点的数据中心。我按照本文档中提供的步骤进行操作, https://learn.hashicorp.com/tutorials/consul/deployment-guide? in=consul/datacenter-deploy
节点已成功创建,并且在我启动服务时它们都处于同步状态。直到这一步,一切都运行良好。
但是,如果领导节点发生故障(脱机),我将面临一个问题。在这种情况下,follower 节点不会自动承担leader 节点的角色,并且 Consul 整体变得无法访问服务。即使跟随节点仍在运行,它也会停止响应请求。
谁能帮我理解我的设置到底出了什么问题,我怎样才能让我的设置仍然在跟随节点自动成为领导节点并响应来自 API Gateway 的查询的情况下工作?
下面的文档给出了一些指导,并讨论了实现“法定人数”以自动选择领导者。我不确定它是否适用于我的这种情况?
编辑:
领事.hcl
First Server:
datacenter = "dc1"
data_dir = "D:/Hashicorp/Consul/data"
encrypt = "<key>"
ca_file = "D:/Hashicorp/Consul/certs/consul-agent-ca.pem"
cert_file = "D:/Hashicorp/Consul/certs/dc1-server-consul-0.pem"
key_file = "D:/Hashicorp/Consul/certs/dc1-server-consul-0-key.pem"
verify_incoming = true
verify_outgoing = true
verify_server_hostname = true
retry_join = ["<ip1>", "<ip2>"]
Second Server:
datacenter = "dc1"
data_dir = "D:/Hashicorp/Consul/data"
encrypt = "<key>"
ca_file = "D:/Hashicorp/Consul/certs/consul-agent-ca.pem"
cert_file = "D:/Hashicorp/Consul/certs/dc1-server-consul-1.pem"
key_file = "D:/Hashicorp/Consul/certs/dc1-server-consul-1-key.pem"
verify_incoming = true
verify_outgoing = true
verify_server_hostname = true
retry_join = ["<ip1>", "<ip2>"]
服务器.hcl:
第一个服务器:
server = true
bootstrap_expect = 2
client_addr = "<ip1>"
ui = true
第二服务器:
server = true
bootstrap_expect = 2
client_addr = "<ip2>"
ui = true