github.com/NVIDIA/aistore@v1.3.23-0.20240517131212-7df6609be51d/docs/cli.md (about)

     1  ---
     2  layout: post
     3  title: CLI
     4  permalink: /docs/cli
     5  redirect_from:
     6   - /cli.md/
     7   - /docs/cli.md/
     8  ---
     9  
    10  ## Table of contents
    11  
    12  - [Getting Started](#getting-started)
    13  - [CLI Reference](#cli-reference)
    14  - [CLI Config](#cli-config)
    15  - [Environment variables](#environment-variables)
    16  - [First steps](#first-steps)
    17  - [Global options](#global-options)
    18  - [Backend Provider](#backend-provider)
    19  - [Verbose errors](#verbose-errors)
    20  - [CLI Help Paging](#cli-help-paging)
    21  
    22  AIS command-line interface (CLI) is a tool to easily manage and monitor every aspect of the AIS clusters' lifecycle.
    23  
    24  In addition, CLI provides dataset management commands, reading and writing primitives, and more.
    25  
    26  Goven an existing aistore instance, maybe the very first command you execute would be `ais show cluster` - a variant of numerous `ais show` subcommands.  For example:
    27  
    28  ```console
    29  $ ais show cluster
    30  PROXY            MEM USED(%)     MEM AVAIL       LOAD AVERAGE    UPTIME          K8s POD         STATUS
    31  p[DlPmJiRU]      0.01%           366.36GiB       [0.1 0.3 0.3]   526h28m20s      ais-proxy-5     online
    32  p[JedAkLgG][P]   0.02%           366.52GiB       [0.7 0.3 0.3]   526h27m30s      ais-proxy-7     online
    33  ...
    34  ...
    35  ...
    36  
    37  TARGET         MEM USED(%)     MEM AVAIL     CAP USED(%)   CAP AVAIL     LOAD AVERAGE    REBALANCE     UPTIME        K8s POD         STATUS
    38  t[KoplySra]    0.03%           366.37GiB     52%           8.324TiB      [0.1 0.3 0.3]   -             526h26m10s    ais-target-1    online
    39  t[MgHaIvNG]    0.03%           366.62GiB     52%           8.177TiB      [0.9 0.8 0.6]   -             526h27m10s    ais-target-4    online
    40  t[WoLfoQEW]    0.03%           366.56GiB     50%           8.499TiB      [0.4 0.2 0.2]   -             526h28m30s    ais-target-7    online
    41  t[fXFPnenn]    0.03%           366.52GiB     51%           8.347TiB      [0.7 0.3 0.3]   -             526h28m10s    ais-target-6    online
    42  t[fwKWswQP]    0.03%           366.56GiB     51%           8.434TiB      [0.5 0.3 0.3]   -             526h27m40s    ais-target-5    online
    43  t[tFUjHCCO]    0.03%           366.37GiB     50%           8.509TiB      [1.5 0.9 0.6]   -             526h28m40s    ais-target-8    online
    44  t[tfNKAtFk]    0.03%           366.40GiB     52%           8.350TiB      [1.6 0.8 0.6]   -             526h26m30s    ais-target-2    online
    45  ...
    46  ...
    47  
    48  Summary:
    49     Proxies:             10 (all electable)
    50     Targets:             10 (total disks: 30)
    51     Cluster Map:         version 760, UUID HCGGmT4K0, primary p[JedAkLgG]
    52     Deployment:          K8s
    53     Status:              20 online
    54     Rebalance:           n/a
    55     Authentication:      disabled
    56     Version:             3.22.rc2.f889d45
    57     Build:               2024-01-29T00:29:36+0000
    58  ```
    59  
    60  Next, montoring wise, you'd maybe run `ais show performance`, etc.
    61  
    62  ## Getting Started
    63  
    64  To build CLI from the source, run the following two steps:
    65  
    66  ```console
    67  $ make cli			# 1. build CLI binary and install it into your `$GOPATH/bin` directory
    68  $ make cli-autocompletions	# 2. install CLI autocompletions (Bash or Zsh)
    69  ```
    70  
    71  To build with debug, run:
    72  
    73  ```console
    74  $ MODE=debug make cli
    75  ```
    76  
    77  Alternatively, install directly from GitHub:
    78  
    79  * [Install CLI from release binaries](https://github.com/NVIDIA/aistore/blob/main/scripts/install_from_binaries.sh)
    80  
    81  For example, the following command extracts CLI binary to the specified destination and, secondly, installs `bash` autocompletions:
    82  
    83  ```console
    84  $ ./scripts/install_from_binaries.sh --dstdir /tmp/www --completions
    85  ```
    86  
    87  For more usage options, run: `./scripts/install_from_binaries.sh --help`
    88  
    89  You can also install `bash` and/or `zsh` autocompletions separately at any (later) time:
    90  
    91  * [Install CLI autocompletions](https://github.com/NVIDIA/aistore/blob/main/cmd/cli/install_autocompletions.sh)
    92  
    93  To uninstall autocompletions, follow the `install_autocompletions.sh` generated prompts, or simply run `bash autocomplete/uninstall.sh`.
    94  
    95  **Please note**: using CLI with autocompletions enabled is strongly recommended.
    96  
    97  Once installed, you should be able to start by running ais `<TAB-TAB>`, selecting one of the available (completion) options, and repeating until the command is ready to be entered.
    98  
    99  **TL;DR**: see section [CLI reference](#cli-reference) below to quickly locate useful commands. There's also a (structured as a reference) list of CLI resources with numerous examples and usage guides that we constantly keep updating.
   100  
   101  **TIP**: when starting with AIS, [`ais search`](/docs/cli/search.md) command may be especially handy. It will list all possible variations of a command you are maybe looking for - by exact match, synonym, or regex.
   102  
   103  See also:
   104  
   105  * [cmd/cli/README.md](https://github.com/NVIDIA/aistore/blob/main/cmd/cli/README.md)
   106  
   107  > The rest of the README assumes that user's `PATH` environment variable contains `$GOPATH/bin` directory.
   108  > Run `export PATH=$PATH:$GOPATH/bin` if this is not the case.
   109  > You can find more about $GOPATH environment [here](https://golang.org/doc/code.html#GOPATH).
   110  
   111  ## CLI Reference
   112  
   113  The recommended and, actually, fastest way to get started with CLI is to type `ais` and press `<TAB-TAB>`:
   114  
   115  ```console
   116  $ ais <TAB-TAB>
   117  
   118  bucket        etl         help           log              create        dsort        stop         blob-download
   119  object        job         advanced       performance      download      evict        cp           rmo
   120  cluster       auth        storage        remote-cluster   prefetch      get          rmb          wait
   121  config        show        archive        alias            put           ls           start        search
   122  ```
   123  
   124  These are the top-level commands as of early 2024. Each command has its own extended help (`--help`) and sub-commands
   125  (which, in turn, have their respective helps and subcommands).
   126  
   127  The list of top-level commands must give maybe the first idea of the supported functionality and functional grouping.
   128  
   129  Following is a brief summary (that's non-exhaustive and slightly outdated):
   130  
   131  | Command | Use Case |
   132  |---------|----------|
   133  | [`ais help`](/docs/cli/help.md) | All top-level commands and brief descriptions; version and build; general usage guidelines. |
   134  | [`ais advanced`](/docs/cli/advanced.md) | Special commands for developers and advanced usage. |
   135  | [`ais alias`](/docs/cli/alias.md) | User-defined command aliases. |
   136  | [`ais archive`](/docs/cli/archive.md) | Read, write, and list archives (i.e., objects formatted as TAR, TGZ, ZIP, etc.) |
   137  | [`ais auth`](/docs/cli/auth.md) | Add/remove/show users, manage user roles, manage access to remote clusters. |
   138  | [`ais bucket`](/docs/cli/bucket.md) | Create/destroy buckets, list bucket's content, show existing buckets and their properties. |
   139  | [`ais cluster`](/docs/cli/cluster.md) | Monitor and manage AIS cluster: add/remove nodes, change primary gateway, etc. |
   140  | [`ais config`](/docs/cli/config.md) | Set local/global AIS cluster configurations. |
   141  | [`ais etl`](/docs/cli/etl.md) | Execute custom transformations on objects. |
   142  | [`ais job`](/docs/cli/job.md) | Query and manage jobs (aka eXtended actions or `xactions`). |
   143  | [`ais object`](/docs/cli/object.md) | PUT and GET (write and read), APPEND, archive, concat, list (buckets, objects), move, evict, promote, ... |
   144  | [`ais search`](/docs/cli/search.md) | Search `ais` commands. |
   145  | [`ais show`](/docs/cli/show.md) | Monitor anything and everything: performance (all aspects), buckets, jobs, remote clusters, and more. |
   146  | [`ais log`](/docs/cli/log.md) | Download ais nodes' logs or view the logs in real time. |
   147  | [`ais storage`](/docs/cli/storage.md) | Show capacity usage on a per bucket basis (num objects and sizes), attach/detach mountpaths (disks). |
   148  {: .nobreak}
   149  
   150  Other CLI documentation:
   151  - [`ais help`](/docs/cli/help.md)
   152  - [Reference guide](https://github.com/NVIDIA/aistore/blob/main/docs/cli.md#cli-reference)
   153  - [Monitoring](/docs/cli/show.md)
   154    - [`ais show cluster`](/docs/cli/show.md)
   155    - [`ais show performance`](/docs/cli/show.md)
   156    - [`ais show job`](/docs/cli/show.md)
   157  - [Cluster and node management](/docs/cli/cluster.md)
   158  - [Mountpath (disk) management](/docs/cli/storage.md)
   159  - [Attach, detach, and monitor remote clusters](/docs/cli/cluster.md)
   160  - [Start, stop, and monitor downloads](/docs/cli/download.md)
   161  - [Distributed shuffle](/docs/cli/dsort.md)
   162  - [User account and access management](/docs/cli/auth.md)
   163  - [Jobs](/docs/cli/job.md)
   164  
   165  > Note: In CLI docs, the terms "xaction" and "job" are used interchangeably.
   166  
   167  ## CLI Config
   168  
   169  Notice:
   170  
   171  * CLI configuration directory: `$HOME/.config/ais/cli`
   172  * CLI configuration filename: `cli.json`
   173  
   174  > For the most updated system filenames and configuration directories, please see [`fname/fname.go`](https://github.com/NVIDIA/aistore/blob/main/cmn/fname/fname.go) source.
   175  
   176  
   177  When used the very first time, *or* if the `$HOME/.config/ais/cli/cli.json` does not exist, the latter will be created with default parameters:
   178  
   179  ```json
   180  $ ais config cli --json
   181  
   182  {
   183      "cluster": {
   184          "url": "http://127.0.0.1:8080",
   185          "default_ais_host": "http://127.0.0.1:8080",
   186          "default_docker_host": "http://172.50.0.2:8080",
   187          "client_crt": "",
   188          "client_crt_key": "",
   189          "client_ca_tls": "",
   190          "skip_verify_crt": false
   191      },
   192      "timeout": {
   193          "tcp_timeout": "60s",
   194          "http_timeout": "0s"
   195      },
   196      "auth": {
   197          "url": "http://127.0.0.1:52001"
   198      },
   199      "aliases": {
   200          "dsort": "job start dsort",
   201          "prefetch": "object prefetch",
   202          "rmo": "object rm",
   203          "get": "object get",
   204          "ls": "bucket ls",
   205          "wait": "job wait",
   206          "create": "bucket create",
   207          "download": "job start download",
   208          "start": "job start",
   209          "stop": "job stop",
   210          "blob-download": "job start blob-download",
   211          "cp": "bucket cp",
   212          "evict": "bucket evict",
   213          "put": "object put",
   214          "rmb": "bucket rm"
   215      },
   216      "default_provider": "ais",
   217      "no_color": false,
   218      "verbose": false,
   219      "no_more": false
   220  }
   221  ```
   222  
   223  CLI config can be updated using `ais config cli set` command or even simply by changing the config file.
   224  
   225  The next time you run it CLI will use the updated values.
   226  
   227  To get back to system defaults, run `ais config cli reset`.
   228  
   229  ## Environment variables
   230  
   231  First and foremost, there's `AIS_ENDPOINT`. If defined, it'll take precedence over "cluster.url" (section [CLI Config](#cli-config) above).
   232  
   233  Example:
   234  
   235  ```console
   236  $ export AIS_ENDPOINT=https://10.07.56.68:51080
   237  ```
   238  
   239  In addition, environment can be used to **override** client-side TLS (aka, HTTPS) configuration - the knobs "client_crt", etc. also listed in the table below:
   240  
   241  | var name | description | the corresponding [CLI Config](#cli-config) |
   242  | -- | -- | -- |
   243  | `AIS_CRT`             | X509 certificate | "cluster.client_crt" |
   244  | `AIS_CRT_KEY`         | X509 certificate's private key | "cluster.client_crt_key"|
   245  | `AIS_CLIENT_CA`       | Certificate authority that authorized (signed) the certificate | "cluster.client_ca_tls" |
   246  | `AIS_SKIP_VERIFY_CRT` | true: skip X509 cert verification (usually enabled to circumvent limitations of self-signed certs) | "cluster.skip_verify_crt" |
   247  
   248  * See also: [TLS: testing with self-signed certificates](/docs/getting_started.md#tls-testing-with-self-signed-certificates)
   249  
   250  ## First steps
   251  
   252  To get the list of supported commands, run:
   253  
   254  ```console
   255  $ ais help
   256  ```
   257  
   258  > Alternatively, you could start making use of auto-completions by typing `ais ` and pressing TAB key two times in a row.
   259  
   260  To check if the CLI can correctly contact the cluster and to get cluster status, run following command:
   261  
   262  ```console
   263  $ ais show cluster
   264  ```
   265  
   266  ## Global options
   267  
   268  Besides a set of options specific for each command, AIS CLI provides global options:
   269  
   270  - `--no-color` - by default AIS CLI displays messages with colors (e.g, errors are printed in red color).
   271    Colors are automatically disabled if CLI output is redirected or environment variable `TERM=dumb` is set.
   272    To disable colors in other cases, pass `--no-color` to the application.
   273  
   274  Please note that the place of a global options in the command line is fixed.
   275  Global options must follow the application name directly.
   276  At the same time, the location of a command-specific option is arbitrary: you can put them anywhere.
   277  Examples:
   278  
   279  ```console
   280  $ # Correct usage of global and command-specific options.
   281  $ ais --no-color ls ais://bck --props all
   282  $ ais --no-color ls --props all ais://bck
   283  $
   284  $ # Incorrect usage of a global option.
   285  $ ais ls ais://bck --props all --no-color
   286  ```
   287  
   288  ## Backend Provider
   289  
   290  The syntax `provider://BUCKET_NAME` (referred to as `BUCKET` in help messages) works across all commands.
   291  For more details, please refer to each specific command's documentation.
   292  `provider://` can be omitted if the `default_provider` config value is set (in such case the config value will be used implicitly).
   293  
   294  Supported backend providers currently include:
   295  * `ais://` - AIStore provider
   296  * `aws://` or `s3://` - Amazon Web Services
   297  * `azure://` or `az://` - Azure Blob Storage
   298  * `gcp://` or `gs://` - Google Cloud Storage
   299  * `ht://` - HTTP(S) datasets
   300  
   301  See also:
   302  
   303  > [Backend Providers](/docs/providers.md)
   304  > [Buckets: definition, operations, properties](/docs/bucket.md)
   305  
   306  ## Verbose errors
   307  
   308  CLI uses [AIS API](https://github.com/NVIDIA/aistore/tree/main/api) to execute operations on a cluster.
   309  
   310  Of course, a remote API call - any API call, for that matter - may return errors. For developers, it may be sometimes useful to see a complete and unredacted error information.
   311  
   312  Here's an example where we are trying to rename a non-existing bucket:
   313  
   314  ```console
   315  $ ais bucket mv ais://ddd ais://mmm
   316  Error: bucket "ais://ddd" does not exist
   317  ```
   318  
   319  But here's how it'll look once we put CLI in verbose mode:
   320  
   321  ```console
   322  $ ais config cli set verbose true
   323  "verbose" set to: "true" (was: "false")
   324  
   325  $ ais bucket mv ais://ddd ais://mmm
   326  Error: {"tcode":"ErrBckNotFound","message":"bucket \"ais://ddd\" does not exist","method":"HEAD","url_path":"/v1/buckets/ddd","remote_addr":"127.0.0.1:57026","caller":"","node":"p[JFkp8080]","status":404}: HEAD /v1/buckets/ddd (stack: [utils.go:445 <- bucket.go:104 <- bucket_hdlr.go:343])
   327  ```
   328  
   329  ## CLI Help Paging
   330  
   331  To view help content page-by-page, CLI uses the `more` command. Disable this by setting `no_more` to `true` in your configuration.
   332  
   333  ```console
   334  $ ais config cli set no_more=true
   335  "no_more" set to: "true" (was: "false")
   336  ```