1. 程式人生 > >linux安裝consul

linux安裝consul

1.下載consul_0.7.5_linux_amd64.zip

wget https://releases.hashicorp.com/consul/0.7.5/consul_0.7.5_linux_amd64.zip

2.解壓consul_0.7.5_linux_amd64.zip

unzip consul_0.7.5_linux_amd64.zip

解決辦法-bash: unzip: 未找到命令如果解壓出現該錯誤

yum -y install unzip

3.檢查

./consul 看到如下介面說明安裝成功

4.啟動

我的linux Ip地址192.168.128.149

./consul agent -dev -ui -node=consul-dev -client=192.168.128.149

 5.訪問

192.168.128.149:8500

如果訪問不了,臨時關閉防火牆

systemctl stop firewalld 

6.使用postMan註冊服務(Post請求)

http://192.168.128.149:8500/v1/catalog/register

引數

{
    "Datacenter": "dc1", 
    "Node": "tomcat", 
    "Address": "192.168.1.100", 
    "Service": {
        "Id": "192.168.1.100:8080", 
        "Service": "itmayiedu", 
        "tags": [
            "dev"
        ], 
        "Port": 8080
    }
}

引數

{
    "Datacenter": "dc1", 
    "Node": "tomcat", 
    "Address": "192.168.1.100", 
    "Service": {
        "Id": "192.168.1.100:8081", 
        "Service": "itmayeidu", 
        "tags": [
            "dev"
        ], 
        "Port": 8081
    }
}

Datacenter指定資料中心,Address指定註冊服務的IP,Service.Id指定服務唯一標識,Service.Service指定服務分組,Service.tags指定服務標籤(如測試環境、釋出環境等),Service.Port指定服務埠

7.儲存key/value

使用postmen 傳送put請求

http://192.168.128.149:8500/v1/kv/upstreams/itmayiedu/192.168.1.100:8080

http://192.168.128.149:8500/v1/kv/upstreams/itmayiedu/192.168.1.100:8081