Consul CLI 入门
in Tutorial with 0 comment
Consul CLI 入门
in Tutorial with 0 comment

安装 consul cli

这里只在 macOS 上安装,需要先提前安装 homebrew,然后执行下面的命令:

brew instal consul


consul --version 
// 返回
Consul v1.0.0
Protocol 2 spoken by default, understands 2 to 3 (agent will automatically use protocol >2 when speaking to compatible agents)

使用 consul cli


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


Usage: consul [--version] [--help] <command> [<args>]

Available commands are:
    agent          Runs a Consul agent
    catalog        Interact with the catalog
    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
    kv             Interact with the key-value store
    leave          Gracefully leaves the Consul cluster and shuts down
    lock           Execute a command holding a lock
    maint          Controls node or service maintenance mode
    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
    snapshot       Saves, restores and inspects snapshots of Consul server state
    validate       Validate config files/directories
    version        Prints the Consul version
    watch          Watch for changes in Consul

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

consul agent -h
==> Usage: consul agent [options]

  Starts the Consul agent and runs until an interrupt is received. The
  agent represents a single node in a cluster.

 Command Options

     Sets the advertise address to use.

     Sets address to advertise on WAN instead of -advertise address.

     Sets the bind address for cluster communication.

     Sets server to bootstrap mode.

     Sets server to expect bootstrap mode.

     Sets the address to bind for client access. This includes RPC, DNS,
     HTTP and HTTPS (if configured).

     Path to a directory to read configuration files from. This
     will read every file ending in '.json' as configuration in this
     directory in alphabetical order. Can be specified multiple times.

     Path to a JSON file to read configuration from. Can be specified
     multiple times.


     Path to directory containing the web UI resources.