WIndows下Consul的簡單使用

2022-07-28 05:03:08 字數 1139 閱讀 6754

consul最常用的就是服務註冊與發現,健康檢查,接下來演示一下在windows上如何使用

step2:cmd到這個路徑下,輸入consul.exe agent -dev開啟後,開啟http://localhost:8500/

step3:在**中,進行服務註冊

public

static

class

consulhelper

);string ip = _configuration["ip"

];

int port = int.parse(_configuration["

port

"]);

clinet.agent.serviceregister(

newagentserviceregistration() :/api/health/index",

timeout = timespan.fromseconds(52),//

檢測等待時間

deregistercriticalserviceafter = timespan.fromseconds(60)//

失敗多久後移除,最小值60秒

} }).wait();}}

view code

step4:示例 同乙個服務,用三個不同的埠開啟

step5:此時檢視consuly頁面,可以看到已經有3個service

暫停乙個服務後,頁面可看到乙個x,並在你配置的一段時間後,會在列表裡移除,這就是健康檢查。

配置consul為windows服務

配置系統服務 1 拷貝consul.exe的目錄 如 e consul consule.exe 2 以管理員身份啟動命令提示符,執行 sc.exe create consul binpath e consul consule.exe agent dev 如果出現下圖錯誤,就在等號後面加乙個空格就行。...

Windows伺服器安裝consul

最近看到surging框架,感覺比較好,想要學習研究一下。這個框架用到了consul,首先安裝一下,我是在windows環境中安裝。consul是乙個用來實現分布式系統的服務發現與配置的開源工具。他主要由多個組成部分 2 配置環境變數,在path中最後面加上 f consul 1.6.2 windo...

單節點下使用docker部署consul

目前consul使用的版本是 v1.0.1 部署server端 本環境僅僅部署乙個server端和乙個client端!docker run d p 1234 8500 h node1 name node1 consul agent server bootstrap expect 1 node nod...