open-consul/website/source/docs/commands/index.html.markdown

141 lines
4.4 KiB
Markdown
Raw Normal View History

2014-02-08 00:41:03 +00:00
---
layout: "docs"
page_title: "Commands"
sidebar_current: "docs-commands"
description: |-
Consul is controlled via a very easy to use command-line interface (CLI). Consul is only a single command-line application: `consul`. This application then takes a subcommand such as agent or members. The complete list of subcommands is in the navigation to the left.
2014-02-08 00:41:03 +00:00
---
# Consul Commands (CLI)
2014-02-08 00:41:03 +00:00
Consul is controlled via a very easy to use command-line interface (CLI).
Consul is only a single command-line application: `consul`. This application
2014-02-08 00:41:03 +00:00
then takes a subcommand such as "agent" or "members". The complete list of
subcommands is in the navigation to the left.
The `Consul` CLI is a well-behaved command line application. In erroneous
2014-02-08 00:41:03 +00:00
cases, a non-zero exit status will be returned. It also responds to `-h` and `--help`
as you'd most likely expect. And some commands that expect input accept
"-" as a parameter to tell Consul to read the input from stdin.
2014-02-08 00:41:03 +00:00
To view a list of the available commands at any time, just run `consul` with
2014-02-08 00:41:03 +00:00
no arguments:
```text
$ consul
usage: consul [--version] [--help] <command> [<args>]
2014-02-08 00:41:03 +00:00
Available commands are:
agent Runs a Consul agent
2016-09-26 15:12:14 +00:00
configtest Validate config file
2014-09-01 22:03:37 +00:00
event Fire a new event
exec Executes a command on Consul nodes
2014-02-08 00:41:03 +00:00
force-leave Forces a member of the cluster to enter the "left" state
2014-02-24 01:09:59 +00:00
info Provides debugging information for operators
join Tell Consul agent to join cluster
2014-02-08 00:41:03 +00:00
keygen Generates a new encryption key
2015-01-20 02:43:38 +00:00
keyring Manages gossip layer encryption keys
2016-09-26 15:12:14 +00:00
kv Interact with the key-value store
leave Gracefully leaves the Consul cluster and shuts down
2015-01-20 02:43:38 +00:00
lock Execute a command holding a lock
2016-09-26 15:12:14 +00:00
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
version Prints the Consul version
2014-08-22 00:25:42 +00:00
watch Watch for changes in Consul
2014-02-08 00:41:03 +00:00
```
To get help for any specific command, pass the `-h` flag to the relevant
subcommand. For example, to see help about the `join` subcommand:
2014-02-08 00:41:03 +00:00
```text
$ consul join -h
Usage: consul join [options] address ...
2014-02-08 00:41:03 +00:00
Tells a running Consul agent (with "consul agent") to join the cluster
by specifying at least one existing member.
2014-02-08 00:41:03 +00:00
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
2014-02-08 00:41:03 +00:00
```
## Environment Variables
In addition to CLI flags, Consul reads environment variables for behavior
defaults. CLI flags always take precedence over environment variables, but it
is often helpful to use environment variables to configure the Consul agent,
particularly with configuration management and init systems.
These environment variables and their purpose are described below:
## `CONSUL_HTTP_ADDR`
This is the HTTP API address to the *local* Consul agent
(not the remote server) specified as a URI:
```
CONSUL_HTTP_ADDR=127.0.0.1:8500
```
or as a Unix socket path:
```
CONSUL_HTTP_ADDR=unix://var/run/consul_http.sock
```
### `CONSUL_HTTP_TOKEN`
This is the API access token required when access control lists (ACLs)
are enabled, for example:
```
CONSUL_HTTP_TOKEN=aba7cbe5-879b-999a-07cc-2efd9ac0ffe
```
### `CONSUL_HTTP_AUTH`
This specifies HTTP Basic access credentials as a username:password pair:
```
CONSUL_HTTP_AUTH=operations:JPIMCmhDHzTukgO6
```
### `CONSUL_HTTP_SSL`
This is a boolean value (default is false) that enables the HTTPS URI
scheme and SSL connections to the HTTP API:
```
CONSUL_HTTP_SSL=true
```
### `CONSUL_HTTP_SSL_VERIFY`
This is a boolean value (default true) to specify SSL certificate verification; setting this value to `false` is not recommended for production use. Example
for development purposes:
```
CONSUL_HTTP_SSL_VERIFY=false
```
### `CONSUL_RPC_ADDR`
This is the RPC interface address for the local agent specified as a URI:
```
CONSUL_RPC_ADDR=127.0.0.1:8300
```
or as a Unix socket path:
```
CONSUL_RPC_ADDR=unix://var/run/consul_rpc.sock
```