consul集群配置


一、環境准備

服務器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服務器,執行以下命令加入集群

 

 6、驗證

./consul operator raft list-peers

 

看到了節點都已加入。
訪問:http://192.168.1.160:8500/

在這里插入圖片描述

成功!


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM