Created
July 1, 2014 21:29
-
-
Save zembutsu/2f09575091c44a2fb2b3 to your computer and use it in GitHub Desktop.
Consul Cheat Sheet 日本語版 ref: http://qiita.com/zembutsu/items/3efb7ebc1d8dba521d3c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ wget -O 0.3.0_linux_amd64.zip https://dl.bintray.com/mitchellh/consul/0.3.0_linux_amd64.zip | |
$ unzip ./0.3.0_linux_amd64.zip | |
# cp ./consul /usr/bin/consul |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ consul -v | |
Consul v0.3.0 | |
Consul Protocol: 2 (Understands back to: 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<タグ>.<サービス名>.<ノード名>.node.<データセンタ名>.consul |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ wget -O 0.3.0_web_ui.zip https://dl.bintray.com/mitchellh/consul/0.3.0_web_ui.zip | |
$ unzip 0.3.0_web_ui.zip | |
# mkdir /opt/consul | |
# mv ./dist /opt/consul/webui |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ curl -s http://192.168.39.5:8500/v1/catalog/nodes | jq '.' | |
[ | |
{ | |
"Address": "192.168.39.5", | |
"Node": "consul1.pocketstudio.net“ | |
}, | |
{ | |
"Address": "192.168.39.6", | |
"Node": "consul2.pocketstudio.net“ | |
} | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ dig @192.168.39.5 -p 8600 consul1.node.consul any | |
; <<>> DiG 9.8.2rc1-RedHat-9.8.2-0.23.rc1.el6_5.1 <<>> @192.168.39.5 -p 8600 consul1.node.consul any | |
(snip) | |
;; WARNING: recursion requested but not available | |
;; QUESTION SECTION: | |
;consul1.node.consul. IN ANY | |
;; ANSWER SECTION: | |
consul1.node.consul. 0 IN A 192.168.39.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ curl http://192.168.39.5:8500/v1/health/state/critical | jq '.' | |
[ | |
{ | |
"ServiceName": "web", | |
"ServiceID": "web", | |
"Notes": "", | |
"Status": "critical", | |
"Name": "Service 'web' check", | |
"CheckID": "service:web", | |
"Node": "consul1" | |
} | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ consul agent -server -bootstrap -client=192.168.39.5 -dc=local \ | |
-node=consul1 -data-dir=/tmp/consul -bind=192.168.39.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ consul agent -dc=local -node=consul2 -data-dir=/tmp/consul2 \ | |
-bind=192.168.39.6 -join=192.168.39.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# consul members | |
Node Address Status Type Build Protocol | |
consul3 192.168.39.13:8301 alive client 0.3.0 2 | |
consul1 192.168.39.11:8301 alive server 0.3.0 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<タグ>.<サービス名>.<ノード名>.node.<データセンタ名>.consul |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"service": { | |
"name": "web", | |
"tags": [ "httpd" ], | |
"port": 80, | |
"check": { | |
"script": "curl localhost:80 >/dev/null 2>&1", | |
"interval": "10s" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment