安装配置Consul集群

1、配置ssh免密登录:

参考

2、官网下载Consul安装包:

wget https://releases.hashicorp.com/consul/1.2.1/consul_1.2.1_linux_amd64.zip

3、解压文件,配置环境变量:

unzip consul_1.2.1_linux_amd64.zip -d consul_1.2.1
#配置环境变量
vim ~/.bashrc
export CONSUL_HOME=/opt/consul_1.2.1
export PATH=$PATH:$CONSUL_HOME
#更新配置
source .bashrc

4、启动集群,Leader。

一共3台服务器(201、202、203),其中201为Leader。

#第一台(leader)

nohup consul agent -server -ui -bootstrap-expect=3 -data-dir=/opt/consul_1.2.1/data -node=consul-1 -client=0.0.0.0 -bind=192.168.1.201 -datacenter=dc1 &

5、启动集群,Flower。

202、203

#第二台

nohup consul agent -server -ui -bootstrap-expect=3 -data-dir=/opt/consul_1.2.1/data -node=consul-2 -client=0.0.0.0 -bind=192.168.1.202 -datacenter=dc1 -join 192.168.1.201 &

#第三台

nohup consul agent -server -ui -bootstrap-expect=3 -data-dir=/opt/consul_1.2.1/data -node=consul-3 -client=0.0.0.0 -bind=192.168.1.203 -datacenter=dc1 -join 192.168.1.201 &

6、查看集群

consul member

7、集群管理Web UI端口:8500

8、清除Consul服务注册失败信息:

在consul-data-dir配置目录中,checks目录中记录了服务注册时的检测信息,services目录中记录了服务注册时的服务信息。

#查看checks信息
cat 016bda0365e468cb5f65d9917cc7c5cf
#删除checks信息
rm -f 016bda0365e468cb5f65d9917cc7c5cf
#查看services信息
cat 12631a5eedf41644caf235410d23a2e4
#删除services信息
rm -rf 12631a5eedf41644caf235410d23a2e4

#重新加载配置
consul reload

猜你喜欢

转载自blog.csdn.net/fishinhouse/article/details/81079914