查询节点
可以通过 DNS API 或 HTTP API 来查询节点
如果使用DNS API,查询结构为 NAME.node.consul
和 NAME.node.DATACENTER.consul
[root@h104 consul]# dig @127.0.0.1 -p 8600 a2.node.consul
; <<>> DiG 9.9.4-RedHat-9.9.4-29.el7_2.1 <<>> @127.0.0.1 -p 8600 a2.node.consul
; (1 server found)
;; global options: cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 57955
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; WARNING: recursion requested but not available
;; QUESTION SECTION:
;a2.node.consul. IN A
;; ANSWER SECTION:
a2.node.consul. 0 IN A 192.168.100.103
;; Query time: 1 msec
;; SERVER: 127.0.0.1#8600(127.0.0.1)
;; WHEN: Fri Mar 18 23:03:36 CST 2016
;; MSG SIZE rcvd: 62
[root@h104 consul]# dig @127.0.0.1 -p 8600 a2.node.dc1.consul
; <<>> DiG 9.9.4-RedHat-9.9.4-29.el7_2.1 <<>> @127.0.0.1 -p 8600 a2.node.dc1.consul
; (1 server found)
;; global options: cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 45949
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; WARNING: recursion requested but not available
;; QUESTION SECTION:
;a2.node.dc1.consul. IN A
;; ANSWER SECTION:
a2.node.dc1.consul. 0 IN A 192.168.100.103
;; Query time: 1 msec
;; SERVER: 127.0.0.1#8600(127.0.0.1)
;; WHEN: Fri Mar 18 23:03:40 CST 2016
;; MSG SIZE rcvd: 70
[root@h104 consul]# dig @127.0.0.1 -p 8600 a1.node.dc1.consul
; <<>> DiG 9.9.4-RedHat-9.9.4-29.el7_2.1 <<>> @127.0.0.1 -p 8600 a1.node.dc1.consul
; (1 server found)
;; global options: cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 43289
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; WARNING: recursion requested but not available
;; QUESTION SECTION:
;a1.node.dc1.consul. IN A
;; ANSWER SECTION:
a1.node.dc1.consul. 0 IN A 192.168.100.104
;; Query time: 1 msec
;; SERVER: 127.0.0.1#8600(127.0.0.1)
;; WHEN: Fri Mar 18 23:03:47 CST 2016
;; MSG SIZE rcvd: 70
[root@h104 consul]#