Hi,
I'm not able to resolve my new service amq.service.consul after installing consul and dnsmasq. When I enter "
dig amq.service.consul" it seems my dns config is not correct because I dont get the same ANSWER SECTION that I get when entering "
dig @127.0.0.1 -p 8600 amq.service.consul SRV"
Here I explain the steps I've taken and then show the different outputs from the dig commands.
Essentially I want to be able to call curl http://amq.service.consul/hawtio/jolokia/read/java.lang:type=Memory/HeapMemoryUsage to be able to retrieve java memory metrics. I'm assuming this is possible.
What I've done
1. installed consul (basic install. No conf changes)
2. followed the consul tutorial to create a simple service. Added /etc/consul.d/amq.json
{"service": {"name": "amq", "tags": ["java"], "port": 61000,
"check": {"script": "curl localhost:61000 >/dev/null 2>&1", "interval": "10s"}}}
3. installed dnsmasq
4. executed:
echo "server= echo "server=/consul/127.0.0.1#8600" > /etc/dnsmasq.d/10-consul5. added the following to /etc/resolv.conf nameserver 127.0.0.1
6. started dnsmasq
7. started consul using: consul agent -server -bootstrap-expect 1 -data-dir /tmp/consul -config-dir /etc/consul.d -ui-dir /var/opt/consul-ui/
The output below compares the dig commands. You'll notice that I dont get the ANSWER SECTION when just specifying dig amq.service.consul SRV. nslookup on amq.service.consul also returns host not found.
Dig results when pointing at Consul DNS
[root@ip-10-10-100-10 consul.d]# dig @127.0.0.1 -p 8600 amq.service.consul SRV
; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.23.rc1.32.amzn1 <<>> @127.0.0.1 -p 8600 amq.service.consul SRV ; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 39308
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; WARNING: recursion requested but not available
;; QUESTION SECTION:
;amq.service.consul. IN SRV
;; ANSWER SECTION:
amq.service.consul. 0 IN SRV 1 1 61000 ip-10-10-100-10.node.dc1.consul.
;; ADDITIONAL SECTION:
ip-10-10-100-10.node.dc1.consul. 0 IN A 10.10.100.10
;; Query time: 1 msec
;; SERVER: 127.0.0.1#8600(127.0.0.1)
;; WHEN: Fri Dec 5 00:43:28 2014
;; MSG SIZE rcvd: 152
Dig results when not specifying the Consul DNS (Notice there is no ANSWER SECTION)
[root@ip-10-10-100-10 consul.d]# dig amq.service.consul
; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.23.rc1.32.amzn1 <<>> amq.service.consul
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 53548
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0
;; QUESTION SECTION:
;amq.service.consul. IN A
;; AUTHORITY SECTION:
;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Fri Dec 5 00:47:57 2014
;; MSG SIZE rcvd: 111
Thanks heaps!
Dave