linux安装consul
1.下载
wget https://releases.hashicorp.com/consul/1.9.2/consul_1.9.2_linux_amd64.zip
2 解压
unzip consul_1.9.2_linux_amd64.zip
3 检查
./consul 看到如下界面说明安装成功
4 启动
我的linux Ip地址192.168.1.27
./consul agent -dev -ui -node=consul-dev -client=192.168.1.27
5 访问
http://192.168.1.27:8500/
6 使用postman注册服务(put请求)
http://192.168.1.27:8500/v1/catalog/register
参数:
{
"Datacenter": "dc1",
"Node": "tomcat",
"Address": "192.168.1.6",
"Service": {
"Id": "192.168.1.6:8080",
"Service": "user-service",
"tags": [
"dev"
],
"Port": 8080
}
}
{
"Datacenter": "dc1",
"Node": "tomcat",
"Address": "192.168.1.6",
"Service": {
"Id": "192.168.1.6:8081",
"Service": "user-service",
"tags": [
"dev"
],
"Port": 8081
}
}
Datacenter指定数据中心,
Address指定注册服务的IP,
Service.Id指定服务唯一标识,
Service.Service指定服务分组,
Service.tags指定服务标签(如测试环境、发布环境等),
Service.Port指定服务端口
7.存储key/value
http://192.168.1.27:8500/v1/kv/upstreams/user-service/192.168.1.27:8080
http://192.168.1.27:8500/v1/kv/upstreams/user-service/192.168.1.27:8081