3个节点: 这里在我的测试环境,模拟一下外网IP
qcloud 10.0.1.86
aliyun 10.0.1.87
aws 10.0.1.88
启动consul的边界节点
-node 为节点取名
-bind 绑定的IP
-advertise-wan 通告自己的IP(外网IP),
consul agent -server -bootstrap-expect 1 -node=qcloud -bind=10.0.1.86 -advertise-wan=10.0.1.86 -data-dir /tmp
consul agent -server -bootstrap-expect 1 -node=aliyun -bind=10.0.1.87 -advertise-wan=10.0.1.87 -data-dir /tmp
consul agent -server -bootstrap-expect 1 -node=aws -bind=10.0.1.88 -advertise-wan=10.0.1.88 -data-dir /tmp
边界节点组成cluster
consul join -wan 10.0.1.86
在qcloud上查看边界信息
consul members -wan
Node Address Status Type Build Protocol DC Segment
aliyun.dc1 10.0.1.87:8302 alive server 1.2.2 2 dc1 <all>
aws.dc1 10.0.1.88:8302 alive server 1.2.2 2 dc1 <all>
qcloud.dc1 10.0.1.86:8302 alive server 1.2.2 2 dc1 <all>
各自节点的客户端机器机器分别加入各自的区域
-node 申明自己的节点 客户端用IP代替吧,这应该是唯一的
-join 申明自己需要加入的集群
-config-dir 服务注册的目录
consul agent -data-dir /tmp/consul -node=10.0.4.15 -join=10.0.1.86 -config-dir=/etc/consul.d
在个自节点上查询客户端是都加入集群
consul members
这仅仅是在我的虚拟机上测试用的,如何在云服务器上部署需要进一步测试,众所周知,云服务器的外网IP并不会绑定到网卡上,这样我们如何使用 -advertise-wan这个参数。
未完待续