Elasticsearch集群如果经过一系列优化之后,数据确实超过了集群能承载的能力,除了拆分集群以外,最后就只剩下一个办法了:清除废旧索引!
为了更加方便的做清除数据,合并segment、备份恢复等管理任务,Elasticsearch在提供相关API的同事,另外准备了一个命令行工具,叫curator。curator是Python程序,可以直接通过Pypi库安装:
pip install elasticsearch-curator
安装安装完成之后会有两个命令可用
读取配置文件的curator
读取命令行参数的curator_cli
配置文件可以灵活的filter和action做到复杂逻辑处理,不过一般来说使用curator_cli做够了。
curator_cli可用参数如下:
[root@hdp-002 ~]# curator_cli Usage: curator_cli [OPTIONS] COMMAND [ARGS]... Options: --config PATH Path to configuration file. Default: ~/.curator/curator.yml --host TEXT Elasticsearch host. --url_prefix TEXT Elasticsearch http url prefix. --port TEXT Elasticsearch port. --use_ssl Connect to Elasticsearch through SSL. --certificate TEXT Path to certificate to use for SSL validation. --client-cert TEXT Path to file containing SSL certificate for client auth. --client-key TEXT Path to file containing SSL key for client auth. --ssl-no-validate Do not validate SSL certificate --http_auth TEXT Use Basic Authentication ex: user:pass --timeout INTEGER Connection timeout in seconds. --master-only Only operate on elected master node. --dry-run Do not perform any changes. --loglevel TEXT Log level --logfile TEXT log file --logformat TEXT Log output format [default|logstash|json]. --version Show the version and exit. --help Show this message and exit. Commands: allocation Shard Routing Allocation close Close indices delete_indices Delete indices delete_snapshots Delete snapshots forcemerge forceMerge index/shard segments open Open indices replicas Change replica count show_indices Show indices show_snapshots Show snapshots snapshot Snapshot indices [root@hdp-002 ~]#
针对具体的command,还可以继续使用--help查看该子命令的帮助,比如查看close子命令的帮助。
[root@hdp-002 ~]# curator_cli close --help Usage: curator_cli close [OPTIONS] Close indices Options: --delete_aliases Delete all aliases from indices to be closed --ignore_empty_list Do not raise exception if there are no actionable indices --filter_list TEXT JSON string representing an array of filters. [required] --help Show this message and exit.
本文出自 “小科” 博客,请务必保留此出处http://kexiaoke.blog.51cto.com/5530023/1971723
原文地址:http://kexiaoke.blog.51cto.com/5530023/1971723