Consul命令(CLI)


Consul可以被命令行工具(CLI)非常容易的控制。此时Consul只是一个单一的命令行应用程序:consul。这个应用程序接收一些子命令,如“agent”或者“members”。完整的子命令列表请看左侧导航。

Consul CLI是一个易用的命令行应用程序。在错误情况下,将返回一个非零的退出状态码。它还响应你最可能期望的 -h–help 。而且一些命令还接受“-”作为一个参数,来让Consul读取标准输入。

任何时候,要浏览所有可用的命令,只要运行consul且不带任何参数:

$ consul
usage: consul [--version] [--help] <command> [<args>]

Available commands are:
	agent          Runs a Consul agent
	event          Fire a new event
	exec           Executes a command on Consul nodes
	force-leave    Forces a member of the cluster to enter the "left" state
	info           Provides debugging information for operators
	join           Tell Consul agent to join cluster
	keygen         Generates a new encryption key
	keyring        Manages gossip layer encryption keys
	leave          Gracefully leaves the Consul cluster and shuts down
	lock           Execute a command holding a lock
	members        Lists the members of a Consul cluster
	monitor        Stream logs from a Consul agent
	operator       Provides cluster-level tools for Consul operators
	reload         Triggers the agent to reload configuration files
	rtt            Estimates network round trip time between nodes
	version        Prints the Consul version
	watch          Watch for changes in Consul

要获取任何指定命令的帮助,将 -h 参数传递给相关的子命令。例如,要看 join 子命令的帮助:

$ consul join -h
Usage: consul join [options] address ...

  Tells a running Consul agent (with "consul agent") to join the cluster
  by specifying at least one existing member.

Options:

  -rpc-addr=127.0.0.1:8400  Address to the RPC server of the agent you want to contact
							to send this command. If this isn't specified, the command checks the
							CONSUL_RPC_ADDR env variable.
  -wan                      Joins a server to another server in the WAN pool