Consul 基础5

2021-12-01 17:09:32 浏览数 (1)

查看成员

使用member命令

代码语言:javascript复制
[root@h104 ~]# consul members --help 
Usage: consul members [options]

  Outputs the members of a running Consul agent.

Options:

  -detailed                 Provides detailed information about nodes

  -rpc-addr=127.0.0.1:8400  RPC address of the Consul agent.

  -status=<regexp>          If provided, output is filtered to only nodes matching
                            the regular expression for status

  -wan                      If the agent is in server mode, this can be used to return
                            the other peers in the WAN pool
[root@h104 ~]# consul members -detailed 
Node  Address               Status  Tags
h104  192.168.100.104:8301  alive   build=0.6.4:26a0ef8c,dc=dc1,port=8300,role=consul,vsn=2,vsn_max=3,vsn_min=1
[root@h104 ~]# 

使用HTTP API

还可以使用 HTTP API (RESTful API) 的方式查看信息

代码语言:javascript复制
[root@h104 ~]# curl localhost:8500/v1/catalog/nodes?pretty
[
    {
        "Node": "h104",
        "Address": "192.168.100.104",
        "TaggedAddresses": {
            "wan": "192.168.100.104"
        },
        "CreateIndex": 3,
        "ModifyIndex": 5
    }
][root@h104 ~]# 
[root@h104 ~]#

使用DNS API

启动服务后,本地的 8600 一直处于监听状态,可以接受DNS请求

代码语言:javascript复制
[root@h104 ~]# netstat  -tunpea | grep consul | grep 8600
tcp        0      0 127.0.0.1:8600          0.0.0.0:*               LISTEN      0          52147      13641/consul        
udp        0      0 127.0.0.1:8600          0.0.0.0:*                           0          52979      13641/consul        
[root@h104 ~]# 

0 人点赞