zl程序教程

您现在的位置是:首页 >  其他

当前栏目

Consul 集群6

2023-03-20 15:35:24 时间

查看状态

可以使用HTTP API来检查配置

[root@h104 consul]# curl http://localhost:8500/v1/health/state/critical
[{"Node":"a2","CheckID":"service:web","Name":"Service 'web' check","Status":"critical","Notes":"","Output":"","ServiceID":"web","ServiceName":"web","CreateIndex":593,"ModifyIndex":593}][root@h104 consul]# 
[root@h104 consul]#
----------
[root@docker ~]# curl http://localhost:8500/v1/health/state/critical
[{"Node":"a2","CheckID":"service:web","Name":"Service 'web' check","Status":"critical","Notes":"","Output":"","ServiceID":"web","ServiceName":"web","CreateIndex":593,"ModifyIndex":593}][root@docker ~]# 
[root@docker ~]#

可以在任意一个节点上进行检查

和服务一样,健康检查也可以使用 HTTP API 来动态地进行添加,删除和修改


键值存储

Consul 提供了一个简单的键值存储机制,可以使用这个特性来存储动态配置,服务协调,主节点选举和其它一些功能

[root@h104 consul]# curl -v http://localhost:8500/v1/kv/?recurse
* About to connect() to localhost port 8500 (#0)
*   Trying ::1...
* Connection refused
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 8500 (#0)
> GET /v1/kv/?recurse HTTP/1.1
> User-Agent: curl/7.29.0
> Host: localhost:8500
> Accept: */*
> 
< HTTP/1.1 404 Not Found
< X-Consul-Index: 1
< X-Consul-Knownleader: true
< X-Consul-Lastcontact: 0
< Date: Fri, 18 Mar 2016 16:14:49 GMT
< Content-Length: 0
< Content-Type: text/plain; charset=utf-8
< 
* Connection #0 to host localhost left intact
[root@h104 consul]# 

因为没有任何值,所以反馈结果为 404