命令行界面
大多数常见的客户端配置设置现在可通过命令行使用。
虽然配置文件和命令行参数可以同时使用,但需要注意的是,命令行选项会覆盖相同设置的基于文件的配置。
最基本的命令行参数如下
curator [--config CONFIG.YML] [--dry-run] ACTION_FILE.YML
方括号表示可选元素。
如果未提供 --config 和 CONFIG.YML,Curator 将在 ~/.curator/curator.yml 中查找配置文件。~ 是执行 Curator 的用户的主目录。在 Unix 系统中,这可能是 /home/username/.curator/curator.yml,而在 Windows 系统中,可能是 C:\Users\username\.curator\curator.yml
如果包含 --dry-run,Curator 将在不实际进行任何更改的情况下,尽可能接近地模拟 ACTION_FILE.YML 中的操作。结果将保存在日志文件中,如果未指定日志文件,则输出到 STDOUT/命令行。
ACTION_FILE.YML 是一个 YAML 动作文件。
对于其他客户端配置选项,随时可以通过命令行获取帮助
curator --help
帮助输出如下所示
$ curator --help
Usage: curator [OPTIONS] ACTION_FILE
Curator for Elasticsearch indices
The default $HOME/.curator/curator.yml configuration file (--config) can be used but is not needed.
Command-line settings will always override YAML configuration settings.
Some less-frequently used client configuration options are now hidden. To see the full list, run:
curator_cli -h
Options:
--config PATH Path to configuration file.
--hosts TEXT Elasticsearch URL to connect to.
--cloud_id TEXT Elastic Cloud instance id
--api_token TEXT The base64 encoded API Key token
--id TEXT API Key "id" value
--api_key TEXT API Key "api_key" value
--username TEXT Elasticsearch username
--password TEXT Elasticsearch password
--request_timeout FLOAT Request timeout in seconds
--verify_certs / --no-verify_certs
Verify SSL/TLS certificate(s) [default: verify_certs]
--ca_certs TEXT Path to CA certificate file or directory
--client_cert TEXT Path to client certificate file
--client_key TEXT Path to client key file
--dry-run Do not perform any changes.
--loglevel [DEBUG|INFO|WARNING|ERROR|CRITICAL]
Log level
--logfile TEXT Log file
--logformat [default|ecs] Log output format
-v, --version Show the version and exit.
-h, --help Show this message and exit.
Learn more at https://esdocs.cn/guide/en/elasticsearch/client/curator/8.0/command-line.html
你可以在配置文件中使用环境变量。
使用 Docker 通过命令行运行 Curator 只需要几个额外的步骤。
如果您打算使用它们,基于 Docker 的 Curator 需要您为配置和/或日志文件映射数据卷。如果您未将配置目录映射到 /.curator,尝试读取 YAML 配置文件将无法正常工作。
它看起来像这样
docker run [-t] --rm --name myimagename \
-v /PATH/TO/MY/CONFIGS:/.curator \
untergeek/curator:mytag \
--config /.curator/config.yml /.curator/actionfile.yml
在测试时,添加 -t 参数将分配一个伪终端,使您能够看到原本会被隐藏的终端输出。
config.yml 和 actionfile.yml 这两个文件在运行之前应该已经存在于路径 /PATH/TO/MY/CONFIGS 中。
命令中的 --rm 意味着容器(而非镜像)将在执行完毕后被删除。你肯定希望这样,因为每次运行都保留容器毫无意义,事后清理会非常麻烦。