consul簡介與安裝
1.consul簡介:
1.1是什麼?
1.2 能幹嗎?
1.3 在哪下? https://www.consul.io/downloads.html
1.4 怎麼用?
官網簡介:https://www.consul.io/intro/index.html
小結:consul提供了一種完整的服務網格的解決方案,從它的特性可以看出:
主要特性:
2.linux安裝與啓動
1.下載好consul的zip文件
2.我使用的是阿里的服務器,也是Centos7的linux服務器,上傳如圖:
3.解壓zip
unzip consul_1.7.2_linux_amd64.zip
解壓出現報錯,沒有unzip需要取下載
yum install -y unzip zip
4.啓動
consul agent 命令詳解:
./consul agent --help
1.直接啓動
-dev表示開發模式運行,另外還有-server表示服務模式運行
./consul agent -dev
2.遠程訪問
由於阿里服務器有公網,所以我設置允許所有訪問:
./consul agent -dev -client 0.0.0.0
測試結果:http://www.topgamelxw.top:8500/ui/dc1/services
我綁定了域名,如果是自己本地的linux可以直接是: ip:8500/ui/dc1/services
允許項目報錯問題:
yml文件:
server:
port: 8006
spring:
cloud:
consul:
# 阿里服務器已綁定此域名
host: www.topgamelxw.top
port: 8500
discovery:
service-name: ${spring.application.name}
# 保持和host一致,默認是127.0.0.1
hostname: www.topgamelxw.top
解決critica紅叉:發送心跳
spring:
cloud:
consul:
heartbeat:
enabled: true