服務發現(consul)搭建 下載最新版 consul 本人使用的版本為1.5.1,操作系統:window server 2008 consul部署的時候分為客戶端和服務端,本次操作伺服器2台,客戶端1台 伺服器2台:222.222.222.8,222.222.222.16 客戶端:222.222. ...
服務發現(consul)搭建
下載最新版 consul
本人使用的版本為1.5.1,操作系統:window server 2008
consul部署的時候分為客戶端和服務端,本次操作伺服器2台,客戶端1台
伺服器2台:222.222.222.8,222.222.222.16
客戶端:222.222.222.15
- 222.222.222.8 伺服器配置文件(server.json):
{ "datacenter":"dcl", "data_dir":"data", "node_name":"consul-server01", "server":true, "bootstrap_expect":2, "bind_addr":"222.222.222.8", "client_addr":"0.0.0.0", "ui":true }
啟動服務
用bat 使用 sc 命令 設置為window server 服務自動啟動
sc create "ZctGroup.ConsulServer" binPath= "E:\consul_1.5.1_windows_amd64\consul.exe agent -config-dir E:\consul_1.5.1_windows_amd64\server.json " start= auto
sc description "ZctGroup.ConsulServer" "服務發現"
sc start "ZctGroup.ConsulServer"
pause
- 222.222.222.16 伺服器配置文件(server.json):
{ "datacenter":"dcl", "data_dir":"data", "node_name":"consul-server02", "server":true, "bind_addr":"222.222.222.16", "client_addr":"0.0.0.0", "ui":true, "retry_join":["222.222.222.8"], "retry_interval":"30s", "rejoin_after_leave":true, "start_join":["222.222.222.8"] }
啟動服務
用bat 使用 sc 命令 設置為window server 服務自動啟動
sc create "ZctGroup.ConsulServer" binPath= "E:\consul_1.5.1_windows_amd64\consul.exe agent -config-dir E:\consul_1.5.1_windows_amd64\server.json " start= auto
sc description "ZctGroup.ConsulServer" "服務發現"
sc start "ZctGroup.ConsulServer"
pause
- 222.222.222.15 客戶端配置文件
{ "datacenter":"dcl", "data_dir":"data", "node_name":"consul-client01", "server":false, "bind_addr":"222.222.222.15", "client_addr":"222.222.222.15", "ui":true, "retry_join":["222.222.222.8"], "retry_interval":"30s", "rejoin_after_leave":true, "start_join":["222.222.222.8"] }
啟動服務
用bat 使用 sc 命令 設置為window server 服務自動啟動
sc create "ZctGroup.ConsulClient" binPath= "E:\consul_1.5.1_windows_amd64\consul.exe agent -config-dir E:\consul_1.5.1_windows_amd64\server.json " start= auto
sc description "ZctGroup.ConsulClient" "服務發現"
sc start "ZctGroup.ConsulClient"
pause
查看結果: