consul集群部署

浪子不回头ぞ 提交于 2019-12-26 07:51:45

一、环境准备

服务器01:192.168.1.160
服务器02:192.168.1.230
服务器03:192.168.1.177

二、consul安装

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=/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=/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=/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服务器,执行以下命令加入集群

./consul join 192.168.1.160

在这里插入图片描述
6、验证

./consul operator raft list-peers

在这里插入图片描述看到了节点都已加入.
访问:http://192.168.1.160:8500/
在这里插入图片描述成功!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!