服务器01:192.168.1.160
服务器02:192.168.1.230
服务器03:192.168.1.177
1、下载:https://www.consul.io/downloads.html
2、解压
3、配置环境变量
export PATH=$PATH:/opt/consul/consul1.6.2/bin
4、创建consul配置文件(三台均需配置,根据不同服务器调整IP地址)
vi /opt/consul/consul1.6.2/conf/consul.json{
"datacenter": "BMS",
"data_dir": "/opt/consul/consul1.6.2/data/consul",
"log_level": "INFO",
"node_name": "BMS201",
"server": true,
"ui": true,
"bootstrap_expect": 2,
"bind_addr": "192.168.1.160",
"client_addr": "192.168.1.160",
"retry_join": ["192.168.1.230","192.168.1.177"],
"retry_interval": "10s",
"protocol": 3,
"raft_protocol": 3,
"enable_debug": false,
"rejoin_after_leave": true,
"enable_syslog": false
}
5、启动集群
./consul agent -server -bootstrap-expect=3 -data-dir=http://www.likecs.com/opt/consul/consul1.6.2/data -node=192.168.1.160 -bind=192.168.1.160 -client=0.0.0.0 -datacenter=dc1 -ui
./consul agent -server -bootstrap-expect=3 -data-dir=http://www.likecs.com/opt/consul/consul1.6.2/data -node=192.168.1.177 -bind=192.168.1.177 -client=0.0.0.0 -datacenter=dc1 -ui
./consul agent -server -bootstrap-expect=3 -data-dir=http://www.likecs.com/opt/consul/consul1.6.2/data -node=192.168.1.230 -bind=192.168.1.230 -client=0.0.0.0 -datacenter=dc1 -ui
登录170和230服务器,执行以下命令加入集群
6、验证
./consul operator raft list-peers
看到了节点都已加入。
访问::8500/