Skip to content

Instantly share code, notes, and snippets.

@zembutsu
Created July 1, 2014 21:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zembutsu/2f09575091c44a2fb2b3 to your computer and use it in GitHub Desktop.
Save zembutsu/2f09575091c44a2fb2b3 to your computer and use it in GitHub Desktop.
Consul Cheat Sheet 日本語版 ref: http://qiita.com/zembutsu/items/3efb7ebc1d8dba521d3c
$ 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
$ consul -v
Consul v0.3.0
Consul Protocol: 2 (Understands back to: 1)
<タグ>.<サービス名>.<ノード名>.node.<データセンタ名>.consul
$ 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
$ 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“
  }
]
$ 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
$ 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"
}
]
$ consul agent -server -bootstrap -client=192.168.39.5 -dc=local \
-node=consul1 -data-dir=/tmp/consul -bind=192.168.39.5
$ consul agent -dc=local -node=consul2 -data-dir=/tmp/consul2 \
-bind=192.168.39.6 -join=192.168.39.5
# 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
<タグ>.<サービス名>.<ノード名>.node.<データセンタ名>.consul
{
"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