简体   繁体   中英

How to get mesos master URL through APIs dynamically?

is there a way to get the mesos master end point using a POST/GET call dynamically? Are there any APIs to call zookeeper which in turn returns the mesos master URL?

You should be able to query for the master in zookeeper by querying your zookeeper DNS endpoint (eg zookeeper.example.com) with:

zookeeper.example.com:2181/mesos .

You may also query any of your masters in mesos, and the request will automatically get forwarded to the leading master.

Lastly, there's a project called Mesos-DNS that has a DNS endpoint for any of your mesos masters (with master.mesos ).

However, the most important point is that you shouldn't be storing that information . There's no reason to assume that the current leading master (or any master for that matter) won't change.

Use zookeeper command-line.

https://github.com/apache/zookeeper/blob/trunk/bin/zkCli.sh

./bin/zkCli.sh

help
# see how to connect to other zookeeper
# default is: localhost:2181

ls /
# [mesos, zookeeper]

ls /mesos
# [json.info_0000000001]

get /mesos/json.info_0000000001
# It will return the Mesos Master's hostname & IP

The result is like this:

{"address":{"hostname":"ced7f7fb79fc","ip":"172.17.0.3","port":5050},"hostname":"ced7f7fb79fc","id":"c8055c4c-3ae0-40e6-a710-5184bcb957a9","ip":50336172,"pid":"master@172.17.0.3:5050","port":5050,"version":"0.26.0"}

With mesos-dns you can simplye use leader.mesos to get the current master.

dig leader.mesos

; <<>> DiG 9.9.5-3ubuntu0.6-Ubuntu <<>> leader.mesos
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 8386
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;leader.mesos.                  IN      A

;; ANSWER SECTION:
leader.mesos.           60      IN      A       10.100.12.40

;; Query time: 1 msec
;; SERVER: 10.100.14.206#53(10.100.14.206)
;; WHEN: Wed Sep 14 15:31:55 UTC 2016
;; MSG SIZE  rcvd: 46

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM