天天看點

consul叢集搭建及使用

下載下傳consul: www.consul.io

1、解壓,設定環境變量,建立檔案夾consul1、consul2、consul3,分别在其目錄下建立basic.json配置檔案:

basic.json:

{
 
    "ports": {
 
    "http": 8500,
 
    "dns": 8600,
 
    "rpc": 8400,
 
    "serf_lan": 8301,
    
    "serf_wan": 8302,
 
    "server": 8300
 
    }
 
}

           
{
 
    "ports": {
 
    "http": 8501,
 
    "dns": 8601,
 
    "rpc": 8401,
 
    "serf_lan": 8311,
    
    "serf_wan": 8312,
 
    "server": 8301
 
    }
 
}

           
{
 
    "ports": {
 
    "http": 8502,
 
    "dns": 8602,
 
    "rpc": 8402,
 
    "serf_lan": 8321,
    
    "serf_wan": 8322,
 
    "server": 8302
 
    }
 
}

           

2、啟動consul server

nohup consul agent -server -node=server-1 -bind=192.168.20.201 -bootstrap-expect 1 -client 0.0.0.0 -ui -dc=zxdc  -config-dir=/Users/zhongxing/JavaTools/consul-new/consul1  -data-dir=/tmp/consul1  >  /Users/zhongxing/JavaTools/consul-new/consul1/consul1.log  2>&1 & 
           

3、啟動consul client

nohup consul agent -node=server2 -bind=192.168.20.201 -dc=zxdc  -retry-join 192.168.20.201:8301 -config-dir=/Users/zhongxing/JavaTools/consul-new/consul2  -data-dir=/tmp/consul2  >  /Users/zhongxing/JavaTools/consul-new/consul2/consul2.log  2>&1 & 

nohup consul agent -node=server3 -bind=192.168.20.201  -dc=zxdc  -retry-join 192.168.20.201:8301 -config-dir=/Users/zhongxing/JavaTools/consul-new/consul3  -data-dir=/tmp/consul3  >  /Users/zhongxing/JavaTools/consul-new/consul3/consul3.log  2>&1 & 

           

4、通路http://localhost:8500

5、建立項目:https://github.com/ZXingg/demo-ms

https://blog.csdn.net/qq_35119422/article/details/82152438

繼續閱讀