ElasticSearch 命令行管理工具Curator

时间:2022-09-27 12:46:48

一、背景


elastic官网现在已经大面积升级到了5.x版本,然而针对elasticsearch的命令行管理工具curator现在仍然是4.0版本。

刚开始找到此工具,深深的怕因为版本更迭无法使用,还好在试用之后,顾虑烟消云散。

  • 应用目的

我主要用到了它删除数据的功能。因为直接通过curl命令删除数据需要输入密码,然而在利用<< EOF的方式也无法绕过密码校验。

懒得自己写python脚本,既然已经有了对应工具,何不马上用起来。

二、安装


1、Signing Keyedit

Download and install the public signing key:

rpm --import https://packages.elastic.co/GPG-KEY-elasticsearch

2、Repository Configurationedit

Add the following in your /etc/yum.repos.d/ directory in a file with a .repo suffix, for example curator.repo

Warning
The repositories are different for CentOS/RHEL 6 and 7 due to library and path differences. Be sure to use the correct version for your system!

RHEL/CentOS 6
[curator-4]
name=CentOS/RHEL 6 repository for Elasticsearch Curator 4.x packages
baseurl=http://packages.elastic.co/curator/4/centos/6
gpgcheck=1
gpgkey=http://packages.elastic.co/GPG-KEY-elasticsearch
enabled=1
RHEL/CentOS 7
[curator-4]
name=CentOS/RHEL 7 repository for Elasticsearch Curator 4.x packages
baseurl=http://packages.elastic.co/curator/4/centos/7
gpgcheck=1
gpgkey=http://packages.elastic.co/GPG-KEY-elasticsearch
enabled=1

3、Binary Package Installationedit

Starting with version 4.1.2, Curator comes with a binary version. What this really means is that the source is compiled, and all required libraries are bundled with the curator binary, so there are no conflicts.

There are separate binary packages for RedHat variants. The binary packages resulting from the creation process have been tested on CentOS 6 & 7, with a different binary for each. They may work on similar variants and/or derivatives, but they have not been tested.

yum install elasticsearch-curator

This will install the necessary files into /opt/elasticsearch-curator and make a symlink at /usr/bin/curator that points to the curator binary in the aforementioned directory.

三、配置


运行报错
curator_cli     
Click will abort further execution because Python 3 was configured to use ASCII as encoding for the environment.  Either run this under Python 2 or consult http://click.pocoo.org/python3/ for mitigation steps.
This system lists a couple of UTF-8 supporting locales that
you can pick from.  The following suitable locales where
discovered: aa_DJ.utf8, aa_ER.utf8, aa_ET.utf8, af_ZA.utf8, am_ET.utf8, an_ES.utf8, ar_AE.utf8, ar_BH.utf8, ar_DZ.utf8, ar_EG.utf8, ar_IN.utf8, ar_IQ.utf8, ar_JO.utf8, ar_KW.utf8, ar_LB.utf8, ar_LY.utf8, ar_MA.utf8, ar_OM.utf8, ar_QA.utf8, ar_SA.utf8, ar_SD.utf8, ar_SY.utf8, ar_TN.utf8, ar_YE.utf8, as_IN.utf8, ast_ES.utf8, ayc_PE.utf8, az_AZ.utf8, be_BY.utf8, bem_ZM.utf8, ber_DZ.utf8, ber_MA.utf8, bg_BG.utf8, bho_IN.utf8, bn_BD.utf8, bn_IN.utf8, bo_CN.utf8, bo_IN.utf8, br_FR.utf8, brx_IN.utf8, bs_BA.utf8, byn_ER.utf8, ca_AD.utf8, ca_ES.utf8, ca_FR.utf8, ca_IT.utf8, crh_UA.utf8, cs_CZ.utf8, csb_PL.utf8, cv_RU.utf8, cy_GB.utf8, da_DK.utf8, de_AT.utf8, de_BE.utf8, de_CH.utf8, de_DE.utf8, de_LU.utf8, doi_IN.utf8, dv_MV.utf8, dz_BT.utf8, el_CY.utf8, el_GR.utf8, en_AG.utf8, en_AU.utf8, en_BW.utf8, en_CA.utf8, en_DK.utf8, en_GB.utf8, en_HK.utf8, en_IE.utf8, en_IN.utf8, en_NG.utf8, en_NZ.utf8, en_PH.utf8, en_SG.utf8, en_US.utf8, en_ZA.utf8, en_ZM.utf8, en_ZW.utf8, es_AR.utf8, es_BO.utf8, es_CL.utf8, es_CO.utf8, es_CR.utf8, es_CU.utf8, es_DO.utf8, es_EC.utf8, es_ES.utf8, es_GT.utf8, es_HN.utf8, es_MX.utf8, es_NI.utf8, es_PA.utf8, es_PE.utf8, es_PR.utf8, es_PY.utf8, es_SV.utf8, es_US.utf8, es_UY.utf8, es_VE.utf8, et_EE.utf8, eu_ES.utf8, fa_IR.utf8, ff_SN.utf8, fi_FI.utf8, fil_PH.utf8, fo_FO.utf8, fr_BE.utf8, fr_CA.utf8, fr_CH.utf8, fr_FR.utf8, fr_LU.utf8, fur_IT.utf8, fy_DE.utf8, fy_NL.utf8, ga_IE.utf8, gd_GB.utf8, gez_ER.utf8, gez_ET.utf8, gl_ES.utf8, gu_IN.utf8, gv_GB.utf8, ha_NG.utf8, he_IL.utf8, hi_IN.utf8, hne_IN.utf8, hr_HR.utf8, hsb_DE.utf8, ht_HT.utf8, hu_HU.utf8, hy_AM.utf8, ia_FR.utf8, id_ID.utf8, ig_NG.utf8, ik_CA.utf8, is_IS.utf8, it_CH.utf8, it_IT.utf8, iu_CA.utf8, iw_IL.utf8, ja_JP.utf8, ka_GE.utf8, kk_KZ.utf8, kl_GL.utf8, km_KH.utf8, kn_IN.utf8, ko_KR.utf8, kok_IN.utf8, ks_IN.utf8, ku_TR.utf8, kw_GB.utf8, ky_KG.utf8, lb_LU.utf8, lg_UG.utf8, li_BE.utf8, li_NL.utf8, lij_IT.utf8, lo_LA.utf8, lt_LT.utf8, lv_LV.utf8, mag_IN.utf8, mai_IN.utf8, mg_MG.utf8, mhr_RU.utf8, mi_NZ.utf8, mk_MK.utf8, ml_IN.utf8, mn_MN.utf8, mni_IN.utf8, mr_IN.utf8, ms_MY.utf8, mt_MT.utf8, my_MM.utf8, nb_NO.utf8, nds_DE.utf8, nds_NL.utf8, ne_NP.utf8, nhn_MX.utf8, niu_NU.utf8, niu_NZ.utf8, nl_AW.utf8, nl_BE.utf8, nl_NL.utf8, nn_NO.utf8, nr_ZA.utf8, nso_ZA.utf8, oc_FR.utf8, om_ET.utf8, om_KE.utf8, or_IN.utf8, os_RU.utf8, pa_IN.utf8, pa_PK.utf8, pap_AN.utf8, pl_PL.utf8, ps_AF.utf8, pt_BR.utf8, pt_PT.utf8, ro_RO.utf8, ru_RU.utf8, ru_UA.utf8, rw_RW.utf8, sa_IN.utf8, sat_IN.utf8, sc_IT.utf8, sd_IN.utf8, se_NO.utf8, shs_CA.utf8, si_LK.utf8, sid_ET.utf8, sk_SK.utf8, sl_SI.utf8, so_DJ.utf8, so_ET.utf8, so_KE.utf8, so_SO.utf8, sq_AL.utf8, sq_MK.utf8, sr_ME.utf8, sr_RS.utf8, ss_ZA.utf8, st_ZA.utf8, sv_FI.utf8, sv_SE.utf8, sw_KE.utf8, sw_TZ.utf8, szl_PL.utf8, ta_IN.utf8, ta_LK.utf8, te_IN.utf8, tg_TJ.utf8, th_TH.utf8, ti_ER.utf8, ti_ET.utf8, tig_ER.utf8, tk_TM.utf8, tl_PH.utf8, tn_ZA.utf8, tr_CY.utf8, tr_TR.utf8, ts_ZA.utf8, tt_RU.utf8, ug_CN.utf8, uk_UA.utf8, unm_US.utf8, ur_IN.utf8, ur_PK.utf8, ve_ZA.utf8, vi_VN.utf8, wa_BE.utf8, wae_CH.utf8, wal_ET.utf8, wo_SN.utf8, xh_ZA.utf8, yi_US.utf8, yo_NG.utf8, yue_HK.utf8, zh_CN.utf8, zh_HK.utf8, zh_SG.utf8, zh_TW.utf8, zu_ZA.utf8
 
When used with Python 3 (and the DEB and RPM packages of Curator are compiled
and bundled with Python 3), Curator requires the locale to be unicode. Any of
the above unicode definitions are acceptable.
To set the locale to be unicode, try:
$ export LC_ALL=en_US.utf8
$ curator_cli [ARGS]
Alternately, you should be able to specify the locale on the command-line:
$ LC_ALL=en_US.utf8 curator_cli [ARGS]
Be sure to substitute your unicode variant for en_US.utf8
配置修正
vim /etc/profile
#添加以下内容
export LC_ALL=en_US.utf-8
export LANG=en_US.utf-8
 
source /etc/profile
 

四、应用


主要利用其删除功能,先展示下其命令行功能表:

$ curator_cli --help
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

我用到的删除命令示例:

#!/bin/bash

dy=`date -d"1 weeks ago" +%Y.%m.%d`
echo "start deleting elasticsearch index by $dy"
curator_cli --host "127.0.0.1" --port "9200" --http_auth elastic:gl2016 delete_indices --filter_list "{\"filtertype\":\"pattern\",\"kind\":\"regex\",\"value\":\"logstash-(.+)-$dy\"}" >> /tmp/curator.log

ElasticSearch 命令行管理工具Curator的更多相关文章

  1. virsh命令行管理工具

    virsh命令行管理工具 Libvirt有两种控制方式,命令行和图形界面 图形界面: 通过执行名virt-manager,启动libvirt的图形界面,在图形界面下可以一步一步的创建虚拟机,管理虚拟机 ...

  2. rabbitmqadmin命令行管理工具-4

    rabbitmqadmin命令行管理工具原文地址: https://www.cnblogs.com/wuzhiyuan/p/6856985.htmlhttps://www.cnblogs.com/mr ...

  3. rabbitmqctl 命令行管理工具

    1. 用户管理 用户管理包括增加用户,删除用户,查看用户列表,修改用户密码. (1) 新增一个用户 rabbitmqctl add_user Username Password (2) 删除一个用户 ...

  4. IIS命令行管理工具使用

    AppCmd.exe工具所在目录 C:\windows\sytstem32\inetsrv\目录下 一条命令批量添加应用程序 c:\Windows\System32\inetsrv>for /d ...

  5. 第4章:kubectl命令行管理工具

    kubectl --help 查看帮助信息 kubectl create --help 查看create命令帮助信息 命令 描述 create 通过文件名或标准输入创建资源 expose 将一个资源公 ...

  6. PowerCmd-cmd命令行管理工具

    缘由 看了大漠在慕课网关于angular的讲解,用到了PowerCmd.就百度一下准备下载,很小很实用的工具,发现有人总结了.备忘 http://www.cnblogs.com/xing901022/ ...

  7. es索引管理工具-curator

    elasticsearch-curator  是官方收购的开源社区周边产品,用来管理es的索引和快照. 官方文档:https://www.elastic.co/guide/en/elasticsear ...

  8. 玩转Windows服务系列——命令行管理Windows服务

    说到Windows服务的管理就不得不说通过命令行的方式管理Windows服务,因为无论是系统管理员,还是通过编程的方式调用cmd命令,命令行都是非常方便以及强大的工具. 接下来就看一下如何通过cmd命 ...

  9. iOS系统提供开发环境下命令行编译工具:xcodebuild

    iOS系统提供开发环境下命令行编译工具:xcodebuild[3] xcodebuild 在介绍xcodebuild之前,需要先弄清楚一些在XCode环境下的一些概念[4]: Workspace:简单 ...

随机推荐

  1. Mysql登录异常的一个问题:

    问题描述: 正常在启动mysql的时候是这样的: 1. win打开输入界面: 2. 输入cmd命令,鼠标右键选择“以管理员身份运行”: 3, 之后再在界面输入登录mysql的登录语句: mysq -u ...

  2. STL学习系列六:List容器

    List简介 list是一个双向链表容器,可高效地进行插入删除元素. list不可以随机存取元素,所以不支持at.(pos)函数与[]操作符.it++(ok), it+5(err) #include ...

  3. ios使用openUrl进行应用跳转

    1.拨打电话: [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel://68979"]]; ...

  4. 蓝牙DA14580开发:固件格式、二次引导和烧写

    嵌入式企鹅圈原创团队成员黄鑫提供. 相比NRF52832和CC254X,蓝牙单芯片DA14580在OTA和二次引导上要复杂一些,不仅体现在memory map.引导过程等流程上,而且在固件格式.生成和 ...

  5. Elasticsearch5&period;5通过案例学习简单操作

    1. 建立员工目录 ES数据库对象与关系型数据库对象对比 Relational DB -> Databases -> Tables -> Rows -> ColumnsElas ...

  6. linux下安装mysql解决乱码、时间差、表的大小写问题

    编辑vi /etc/mysql/my.cnf,有的则是:/etc/my.cnf,加入 [client]default-character-set=utf8mb4 [mysql]default-char ...

  7. info&period;plist的选项含义

    1.     Application does not run in background(鍵名:UIApplicationExistsOnSuspend)自從iOS4.0之後,當你在應用程式執行的時 ...

  8. 使用libmagic确定文件MIME类型【示例】【转】

    原文地址:http://blog.csdn.net/vevenlcf/article/details/46122661 使用libmagic确定文件MIME类型[示例] 引用:   <http: ...

  9. webrtc 在MAC下和iOS下的编译

    一:安装brew和git 1. mkdir /usr/local 2. curl -LsSf http://github.com/mxcl/homebrew/tarball/master | sudo ...

  10. Java使用ListIterator逆序ArrayList

    对于列表而言,除了Iterator,还提供了一个功能更加强大的ListIterator.它可以实现逆序遍历列表中的元素.本示例将使用其逆序遍历ArrayList. 思路分析:要逆序遍历某个列表,首先要 ...