Centos7.*Consul安装配置

目录准备:

  sudo mkdir -p /opt/consul/{conf,data}

下载镜像:

  docker pull consul:latest

启动容器:

  简单配置

  docker run --name myconsul -lnt --restart=always -p 8500:8500 -d consul:latest

  consul-集群-leader

docker run -p 8500:8500 \
-v /opt/consul/data/server1:/consul/data \
-v /opt/consul/conf/server1:/consul/conf \
-h=node1 --net=host \
-e CONSUL_BIND_INTERFACE=ens33 \
--privileged=true \
--name consul_001 \
consul:latest agent \
-bind=192.168.125.156 \
-server=true \
-bootstrap-expect=3 -ui \ -node=consul_server_1 \
-client='0.0.0.0' \ -datacenter=xdp_dc \ -data-dir /consul/data/ \ -config-dir /consul/conf/

  

 consul-集群-flower1

docker run -p 8500:8500 \
-v /opt/consul/data/server2:/consul/data \
-v /opt/consul/conf/server2:/consul/conf \
-h=node1 --net=host \
-e CONSUL_BIND_INTERFACE=ens33 \
--privileged=true \
--name consul_002 \
consul:latest agent \
-bind=192.168.125.157 \
-server=true \
-bootstrap-expect=3 -ui \ -node=consul_002 \
-client='0.0.0.0' \ -datacenter=xdp_dc \ -data-dir /consul/data/ \ -config-dir /consul/conf/ \
-join 192.168.125.156

  

 consul-集群-flower2

docker run -p 8500:8500 \
-v /opt/consul/data/server3:/consul/data \
-v /opt/consul/conf/server3:/consul/conf \
-h=node1 --net=host \
-e CONSUL_BIND_INTERFACE=ens33 \
--privileged=true \
--name consul_003 \
consul:latest agent \
-bind=192.168.125.158 \
-server=true \
-bootstrap-expect=3 \
-ui \ -node=consul_003 \
-client='0.0.0.0' \ -datacenter=xdp_dc \ -data-dir /consul/data/ \ -config-dir /consul/conf/ \
-join 192.168.125.156

  

 consul-集群-client

docker run -p 8500:8500 \
-v /opt/consul/conf/server4:/consul/conf \
-h=node1 --net=host \
-e CONSUL_BIND_INTERFACE=ens33 \
--privileged=true \
--name consul_100 \
consul:latest agent \
-bind=192.168.125.159 \
-server=false \
-ui \ -node=consul_100 \
-client='0.0.0.0' \ -datacenter=xdp_dc \ -config-dir /consul/conf/ \
-join 192.168.125.156

  

  条件不完全具备时配置

#下列配置ok

docker run -d -p 8500:8500 --restart=always \
--name=consul_001 consul:latest \
agent -server \
-bootstrap -ui \
-client='0.0.0.0' \
-node=1 

 

 注意consul 默认存储路径

/consul/data/

/consul/conf/

#下列部分配置待验证
-data-dir /consul/data/ \
-config-dir /consul/conf/ \
-v /opt/consul/data/server1:/consul/data \
-v /opt/consul/conf/server1:/consul/conf \

Consul访问:

  http://宿主机IP:8500/

示例截图:

  

 

posted @ 2021-11-21 10:20  李文学  阅读(35)  评论(0编辑  收藏  举报