Elasticsearch curator,简称curator,是一个允许你轻松管理Elasticsearch集群的工具。Curator是用Python编写的,当你需要管理你的ELK索引和快照时,它就会派上用场。
本指南将告诉你如何为你的ELK集群设置和配置Elasticsearch curator。
要求
在你的系统上安装curator之前,请确保你有:
- 安装了Python并且是最新的。
- 你的系统有互联网接入。
更新你的系统
从更新你的系统开始。在本指南中,我们使用的是Ubuntu 20.04服务器
sudo apt update
sudo apt upgrade
安装Python3-Pip
为了安装Elasticsearch策展人,我们首先需要确保我们已经安装了pip。使用该命令。
sudo apt install python3-pip -y
安装Elasticsearch curator
一旦我们安装并更新了pip,我们就可以使用命令来安装Elasticsearch curator了。
pip3 install elasticsearch-curator
设置Curator配置文件
下一步是为Elasticsearch curator设置配置文件。默认情况下,该配置文件在/home/user/.curator/curator.yml中
首先创建该目录:
mkdir ~/.curator
接下来,创建 curator.yml 配置文件。
touch ~/.curator/curator.yml
最后,添加包含客户端连接和日志参数的配置细节。
默认条目如下:
---
client:
hosts: # define nosts
- 127.0.0.1
- 192.168.0.113
port: 9200 # Elasticsearch port
url_prefix: # set url prefix for example proxy. Leave empty for none
use_ssl: false # use SSL? True or False
certificate: # path to CA certificate => /path/to/ca/file
client_cert: # path to client certificate
client_key: # path to private SSL key
ssl_no_validate: false # set true if elasticsearch is protected by SSL
username: # HTTP Auth username
password: # HTTP Auth password
timeout: 30 # set timeout value
master_only: false # install on every node or master only?
logging:
loglevel: INFO # set log level such as CRITICAL, DEBUG, WARNING, or ERROR
logfile: # path to the log file
logformat: default # define log format => defualt format is as 2016-04-22 11:53:09,972 INFO Action #1: ACTIONNAME
blacklist: ['elasticsearch', 'urllib3'] # disables logs for elasticsearch and urllib3
注意:这些评论仅用于编写文档。请随意删除或修改它们,如有必要。
保存该文件并关闭编辑器。
完成后,你可以将curator作为一个python模块或命令行工具使用。
例如,下面的命令显示了使用curator工具的快照。
curator_cli show-snapshots
总结
本指南告诉你如何设置和配置Elasticsearch curator工具来管理你的集群。