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