Centos7-4下安裝Consul


1、安裝Consul

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

//我這里出現報錯:-bash: wget: 未找到命令,解決方法

yum -y install wget

//然后在執行上面的命令,將Consul下載下來

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、啟動consul

我的ip地址是192.168.100.129

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

//關閉臨時防火牆

systemctl stop firewalld

5、訪問consul

http://192.168.100.129:8500

6.使用PostMan 注冊Http服務

//地址  使用post請求

http://192.168.100.129:8500/v1/catalog/register

//發送json格式數據
//參數1
{"Datacenter": "dc1",
 "Node":"tomcat",
 "Address":"192.168.0.102",
 "Service": {
	"Id" :"192.168.0.102:8080", 
		"Service": "yangk",
		"tags": ["dev"],
		"Port": 8080
		}}

Datacenter指定數據中心,Address指定服務IP,Service.Id指定服務唯一標識,Service.Service指定服務分組,Service.tags指定服務標簽(如測試環境、預發環境等),Service.Port指定服務端口。

7.發現Http服務


免責聲明!

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



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