Agent
consul agent -dev
Run a single in-memory dev server
No persistence; UI available with -ui.
consul agent -server -bootstrap-expect=<n>
-data-dir=<dir>
Start a server in a new cluster
consul agent -data-dir=<dir>
-retry-join=<addr>
Start a client that joins a server
consul agent -config-dir=<dir>
Load .json and .hcl config files
consul agent -node=<name>
-datacenter=<dc>
Set node name and datacenter
consul agent -bind=<ip> -client=<ip>
Choose cluster and client addresses
-client defaults to loopback only.
consul agent -ui
Enable the web UI
consul validate <file-or-dir>
Check config before starting
consul version
Print the version
consul tls ca create
Create a CA for TLS
consul tls cert create -server
Create a server certificate
Cluster
consul members
List members and their status
consul members -detailed
Include tags and versions
consul members -wan
Show the WAN pool (server members)
consul join <addr>
Join this agent to a cluster
consul leave
Leave gracefully and shut down
On a server this also removes it from the Raft peer set.
consul force-leave <node>
Mark a failed node as left
consul reload
Re-read config without a restart
consul monitor
Stream logs from the agent
consul monitor -log-level=debug
Raise the streamed log level
consul maint -enable -reason="<why>"
Put the node in maintenance mode
consul keygen
Generate a gossip encryption key
Catalog and services
consul catalog services
List services
consul catalog nodes
List nodes
consul catalog nodes -service=<name>
Nodes that provide a service
consul catalog services -node=<node>
Services on a node
consul services register <file>
Register services from HCL or JSON
consul services register -name=<name>
-port=<port>
Register one service from flags
consul services register -tag=<tag>
-meta=<k>=<v>
Add tags and metadata
consul services deregister -id=<id>
Remove a service instance
consul services deregister <file>
Remove services defined in a file
Key-value store
consul kv put <key> <value>
Set or update a key
consul kv get <key>
Read a key
consul kv get -recurse <prefix>/
Read all keys under a prefix
consul kv get -keys <prefix>/
List key names only
consul kv get -detailed <key>
Show index, flags and session
consul kv delete <key>
Delete a key
consul kv delete -recurse <prefix>/
Delete a whole subtree
Keep the trailing slash: foo also matches food.
consul kv put <key> @<file>
Take the value from a file
consul kv put -cas -modify-index=<n> <key>
<value>
Write only if unchanged
Fails if ModifyIndex no longer matches; not allowed with
-recurse on delete.
consul kv export <prefix>/
Dump a subtree as JSON
consul kv import @<file>
Load a JSON export
consul lock <prefix> <command>
Run a command while holding a lock
Snapshots and Raft
consul snapshot save <file>
Save a point-in-time snapshot
consul snapshot restore <file>
Restore a snapshot to the servers
consul snapshot inspect <file>
Show snapshot metadata
consul operator raft list-peers
Show Raft servers and leader
consul operator raft list-peers -stale=true
List peers when there is no leader
consul operator raft remove-peer -id=<id>
Remove a dead server
consul operator raft transfer-leader
Hand leadership to another server