consul无client模式
1、推consul的镜像到生产应用全部服务器。
每个consul的server模式的容器,都需要单独的物理服务器。
主节点:
docker run -d --net=host --name=consul_pre1 consul:0.9.0 agent -server -bind=10.0.0.20 -node=consul_pre1 -bootstrap-expect 2 -client 0.0.0.0 -ui
#docker run -d --net=host --name=consul_node_1 consul:0.9.0 agent -server -bootstrap-expect=2 -ui -client=0.0.0.0 -node=consul_node1 -advertise=10.0.0.8
从节点:
docker run -d --net=host --name=consul_pre2 consul:0.9.0 agent -bind=10.0.0.12 -node=consul_pre2 -retry-join=10.0.0.20
#docker run -d --net=host --name=consul_node_2 consul:0.9.0 agent -server -ui -client=0.0.0.0 -node=consul_node2 -retry-join=10.0.0.8 -advertise=10.0.0.9
#docker run -d --net=host --name=consul_node_3 consul:0.9.0 agent -server -ui -client=0.0.0.0 -node=consul_node3 -retry-join=10.0.0.8 -advertise=10.0.0.10
nginx反向代理consul:
vim /usr/local/nginx/conf/nginx.conf
server {
listen 8500;
server_name consul.server.com;
location / {
include proxy.conf;
proxy_pass http://consul;
}
}
vim /usr/local/nginx/conf/upstream.conf
upstream consul {
server 10.0.0.8:8500;
server 10.0.0.9:8500;
server 10.0.0.10:8500;
dns解析添加A记录:
vim /var/named/chroot/var/named/server.com.zone
consul.server.com. IN A 192.168.1.30
参考:
https://hub.docker.com/_/consul/