将Vagrant连接到OpenStack中的Consul服务器

时间:2014-09-26 18:13:07

标签: vagrant openstack

如何将Vagrant计算机连接到在OpenStack集群中运行的Consul服务器?

我在OpenStack集群中有2个实例。一个作为Consul服务器(agent-one)运行,另一个作为客户端(agent-two)运行。他们加入并报告通过健康检查。

在我的本地机器上,我在本地计算机上启动了一个Vagrant(vagrant-one)并希望加入OpenStack的领事方。

此时,领事登录流浪者 - 读取:

2014/09/26 18:02:42 [INFO] serf: EventMemberJoin: vagrant-one 10.0.2.15
2014/09/26 18:02:42 [ERR] agent: failed to sync remote state: No known Consul servers

我跑了consul join <consul-server-hostname>并报告:

Successfully joined cluster by contacting 1 nodes.

然后日志报告了vagrant-one上的以下事件序列:

2014/09/26 18:07:22 [INFO] agent.rpc: Accepted client: 127.0.0.1:39070
2014/09/26 18:07:22 [INFO] agent: (LAN) joining: [consul-server-hostname]
2014/09/26 18:07:27 [INFO] serf: EventMemberJoin: agent-two 10.4.128.18
2014/09/26 18:07:27 [INFO] serf: EventMemberJoin: agent-one 10.4.128.17
2014/09/26 18:07:27 [INFO] agent: (LAN) joined: 1 Err: <nil>
2014/09/26 18:07:27 [INFO] consul: adding server agent-one (Addr: 10.4.128.17:8300) (DC: dc1)
2014/09/26 18:07:29 [INFO] memberlist: Suspect agent-one has failed, no acks received
2014/09/26 18:07:30 [INFO] memberlist: Suspect agent-two has failed, no acks received
2014/09/26 18:07:31 [INFO] memberlist: Suspect agent-one has failed, no acks received
2014/09/26 18:07:32 [INFO] memberlist: Suspect agent-two has failed, no acks received
2014/09/26 18:07:33 [INFO] memberlist: Suspect agent-two has failed, no acks received
2014/09/26 18:07:34 [INFO] memberlist: Marking agent-one as failed, suspect timeout reached
2014/09/26 18:07:34 [INFO] serf: EventMemberFailed: agent-one 10.4.128.17
2014/09/26 18:07:34 [INFO] consul: removing server agent-one (Addr: 10.4.128.17:8300) (DC: dc1)
2014/09/26 18:07:34 [INFO] memberlist: Suspect agent-one has failed, no acks received
2014/09/26 18:07:35 [INFO] memberlist: Marking agent-two as failed, suspect timeout reached
2014/09/26 18:07:35 [INFO] serf: EventMemberFailed: agent-two 10.4.128.18
2014/09/26 18:07:35 [INFO] memberlist: Suspect agent-two has failed, no acks received
2014/09/26 18:07:37 [ERR] agent: failed to sync remote state: rpc error: failed to get conn: dial tcp 10.4.128.17:8300: i/o timeout
2014/09/26 18:07:47 [INFO] serf: attempting reconnect to agent-one 10.4.128.17:8301
2014/09/26 18:07:57 [ERR] agent: failed to sync remote state: No known Consul servers

所以看起来它最初可以连接。它获取在OpenStack集群中运行的两个consul代理的节点名称。 OpenStack集群中的节点上的健康检查都没有通过,并且流氓 - 最终还原为&#34;没有已知的Consul服务器&#34;。

编辑1

如果我向OpenStack Consul代理添加-advertise <associated-ip>标志,那么vagrant-one似乎能够接收代理二的健康检查,但由于某种原因而不是代理一。虽然此时此问题似乎是一个网络问题。

1 个答案:

答案 0 :(得分:0)

您的Vagrant框在Virtualbox(或VMWare)的虚拟NAT上运行。 Openstack群集中的节点暴露给LAN,但Vagrant盒子不是。最简单的解决方法是将您的Vagrant盒暴露给外部网络。将以下内容添加到您的Vagrant文​​件中。

config.vm.network "public_network"