docker+consul

https://www.cnblogs.com/edisonchou/p/consul_cluster_based_on_docker_introduction.html

1.docker pull consul:1.4.4

2.

.docker run -d -p 127.0.0.1:8510:8500 --restart=always -v C:\dockerV\consul\server1\data:/consul/data -v C:\dockerV\consul\server1\conf:/consul/config -e CONSUL_BIND_INTERFACE='eth0' --privileged=true --name=consul_server_1 consul:1.4.4 agent -server -bootstrap-expect=3 -ui -node=consul_server_1 -client='0.0.0.0' -data-dir /consul/data -config-dir /consul/config -datacenter=xdp_dc

主服务ip

JOIN_IP="$(docker inspect -f '{{.NetworkSettings.IPAddress}}' consul_server_1)";

启动2个从节点

docker run -d -p 127.0.0.1:8520:8500 --restart=always -v C:\dockerV\consul\server2\data:/consul/data -v C:\dockerV\consul\server2\conf:/consul/config -e CONSUL_BIND_INTERFACE='eth0' --privileged=true --name=consul_server_2 consul:1.4.4 agent -server -ui -node=consul_server_2 -client='0.0.0.0' -datacenter=xdp_dc -data-dir /consul/data -config-dir /consul/config -join="JOIN_IP"
docker run -d -p 127.0.0.1:8530:8500 --restart=always -v C:\dockerV\consul\server3\data:/consul/data -v C:\dockerV\consul\server3\conf:/consul/config -e CONSUL_BIND_INTERFACE='eth0' --privileged=true --name=consul_server_3 consul:1.4.4 agent -server -ui -node=consul_server_3 -client='0.0.0.0' -datacenter=xdp_dc -data-dir /consul/data -config-dir /consul/config -join="JOIN_IP"

 

3.检查结果

docker exec consul_server_1 consul operator raft list-peers

 

4.  http://127.0.0.1:8510/ui/xdp_dc/services/consul

posted @ 2020-06-17 15:14  圆明猿  阅读(263)  评论(0编辑  收藏  举报