Difference between revisions of "HashiCorp/Consul"
Jump to navigation
Jump to search
Line 6: | Line 6: | ||
</source> | </source> | ||
= Run consul = | = Run consul agent = | ||
You need run at least one <tt>consul server</tt> 3-5 are recommended. | You need run at least one <tt>consul server</tt> 3-5 are recommended. | ||
All other agents do run in a <tt>client</tt> mode, it's very light weight process that : | All other agents do run in a <tt>client</tt> mode, it's very light weight process that : | ||
Line 16: | Line 16: | ||
Run consul in dev mode where single server is also acting as a client: | Run consul in dev mode where single server is also acting as a client: | ||
<source lang=bash> | <source lang=bash> | ||
consul agent -dev -node < | consul agent -dev -node <consul_hostname> | ||
# -node is optional as by default hostname is used, but for OSX with period in it will case problems with dns queries | # -node is optional as by default hostname is used, but for OSX with period in it will case problems with dns queries | ||
</source> | </source> | ||
Consul will start listenig on following ports | |||
<source lang=bash> | <source lang=bash> | ||
Netid State Local Address:Port | Netid State Local Address:Port | ||
udp UNCONN 127.0.0.1:8301 | udp UNCONN 127.0.0.1:8301 | ||
Line 36: | Line 36: | ||
<source lang=bash> | <source lang=bash> | ||
consul members | consul members -details | ||
Node Address Status Type Build Protocol DC Segment | Node Address Status Type Build Protocol DC Segment | ||
u18gui-1 127.0.0.1:8301 alive server 1.4.3 2 dc1 <all> | u18gui-1 127.0.0.1:8301 alive server 1.4.3 2 dc1 <all> | ||
# API call | |||
curl localhost:8500/v1/catalog/nodes | |||
# DNS interface, using dns lookups, consuls listenig on udp/tcp:8600 port | |||
dig @127.0.0.1 -p 8600 <consul_hostname>.node.consul | |||
</source> | </source> | ||
Revision as of 21:23, 11 March 2019
Install
wget https://releases.hashicorp.com/consul/1.4.3/consul_1.4.3_linux_amd64.zip unzip consul_1.4.3_linux_amd64.zip sudo mv consul /usr/bin
Run consul agent
You need run at least one consul server 3-5 are recommended. All other agents do run in a client mode, it's very light weight process that :
- register services
- check healthchecks
- forward queries to servers
- agent needs to run on every node that is a part of a cluster
Run consul in dev mode where single server is also acting as a client:
consul agent -dev -node <consul_hostname> # -node is optional as by default hostname is used, but for OSX with period in it will case problems with dns queries
Consul will start listenig on following ports
Netid State Local Address:Port udp UNCONN 127.0.0.1:8301 udp UNCONN 127.0.0.1:8302 udp UNCONN 127.0.0.1:8600 tcp LISTEN 127.0.0.1:8300 tcp LISTEN 127.0.0.1:8301 tcp LISTEN 127.0.0.1:8302 tcp LISTEN 127.0.0.1:8500 tcp LISTEN 127.0.0.1:8600
consul members -details Node Address Status Type Build Protocol DC Segment u18gui-1 127.0.0.1:8301 alive server 1.4.3 2 dc1 <all> # API call curl localhost:8500/v1/catalog/nodes # DNS interface, using dns lookups, consuls listenig on udp/tcp:8600 port dig @127.0.0.1 -p 8600 <consul_hostname>.node.consul
References
- A practical and simple consul-template example Tutorial with docker restart based on a template change
- Consul template Official Git repository