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服务