consul install

前置条件

服务器三台,分别是:
172.16.6.100
172.16.6.101
172.16.6.102

容器启动

节点1:
启动脚本:

1
2
3
4
5
docker run -d --net=host \
--name=consul-100 --hostname=consul-100 consul:0.8.4 agent \
-server -disable-host-node-id \
-client=0.0.0.0 -bootstrap-expect=3 \
-bind=172.16.6.100 -ui

该节点带ui启动参数,端口默认8500

节点2:
启动脚本:

1
2
3
docker run -d --net=host --name=consul-101 --hostname=consul-101 consul:0.8.4 agent \
-server -bind=172.16.6.101 -disable-host-node-id \
-client=0.0.0.0 -bootstrap-expect=3 -join=172.16.6.100

节点3:
启动脚本:

1
2
3
4
docker run -d --net=host --name=consul-102 --hostname=consul-102 consul:0.8.4 agent \
-server -disable-host-node-id \
-bind=172.16.6.102 \
-client=0.0.0.0 -bootstrap-expect=3 -join=172.16.6.100

说明

consul也是用的–net=host的网络,用calico网络其实也可以,但8500端口publish不出到宿主机网络,其他client连接consul的时候,网络需要控制权限,只需将ingress全部allrow即可。