zoukankan      html  css  js  c++  java
  • es索引管理工具-curator

    elasticsearch-curator  是官方收购的开源社区周边产品,用来管理es的索引和快照。 在6.6以后官方推出了ILM(索引生命周期管理策略),更加易于操作和方便使用,可以在kibana界面直接操作。

    官方文档:https://www.elastic.co/guide/en/elasticsearch/client/curator/current/index.html

    功能包括:从别名添加、删除索引,更改分片路由分配,打开/关闭索引,创建/删除索引,快照管理、合并segment,更改索引分片副本数等。

    目前使用的elasticsearch-curator版本是5.4, Python2.6安装会出现问题.建议在安装在python2.7+的环境中.

    安装:

          # pip install elasticsearch-curator

    使用:

    命令语法:

    命令行参数:  curator [--config CONFIG.YML] [--dry-run] ACTION_FILE.YML

    $ curator --help
    Usage: curator [OPTIONS] ACTION_FILE
    
      Curator for Elasticsearch indices.
      See http://elastic.co/guide/en/elasticsearch/client/curator/current
    Options:
      --config PATH  Path to configuration file. Default: ~/.curator/curator.yml
      --dry-run      Do not perform any changes.  #  --dry-run参数在调试action_file时比较重要
      --version      Show the version and exit.
      --help         Show this message and exit.

    curator运行需两个配置文件:

    config.yml:用于连接ES集群配置

    action.yml:用于配置要执行的操作,文件名称可以随意命名 

    config.yml配置:

    # cat curator.yml
    # Remember, leave a key empty ifthere is no value.  None will be a string,
    # not a Python "NoneType"
    client:
      hosts:
        - 172.16.10.23
        - 172.16.10.24
        - 172.16.10.25
      port: 9200
      url_prefix:
      use_ssl: False
      certificate:
      client_cert:
      client_key:
      ssl_no_validate: False
      http_auth:
      timeout: 3600
      master_only: False
    logging:
      loglevel: INFO
    #  logfile: /home/test/curator.log
      logfile:
      logformat: default
      blacklist: ['elasticsearch', 'urllib3']

    配置说明:

    • hosts: 同一个集群内节点IP,如果端口不同,可写成ip:port形式;只能一次使用一个集群。在主机设置中包含来自多个集群的节点将导致错误。
    • port: 默认值是9200。这个值只适用于没有端口的主机。
    • timeout:  默认值是30S,根据实际使用情况调整.
    • logfile: 默认值是空的,会将执行结果输出到STDOUT或控制台。如果指定文件,会把执行日志输出到文件中,而不是控制台.
    • blacklist:  默认值为'elasticsearch', 'urllib3'。Python模块不被输出。除非需要调试某些问题, 否则请使用默认值.

    ACTION_FILE配置

    配置说明:关闭前缀为syslog- 并且 时间格式为 '%Y.%m.%d'的7天前的所有的文档.

    # cat action_close.yml
    ---
    # Remember, leave a key empty ifthere is no value.  None will be a string,
    # not a Python "NoneType"
    #
    # Also remember that all examples have 'disable_action'set to True.  If you
    # want to use thisaction as a template, be sure to set thisto False after
    # copying it.
    actions:
      1:
        action: close
        description: >-
          Close indices older than 30days (based on index name), forlogstash-
          prefixed indices.
        options:
          delete_aliases: False
          disable_action: False
        filters:      # filters下的配置都是隐含的逻辑“AND”操作链接.
        - filtertype: pattern
          kind: prefix
          value: syslog-
        - filtertype: age
          source: name
          direction: older
          timestring: '%Y.%m.%d'
          unit: days
          unit_count: 7

     curator_cli命令行命令行查看所有索引:

     # curator_cli --config   config.yml  action_close.yml  --verbose

    执行命令:

    # curator --config  config.yml   action_close.yml

  • 相关阅读:
    学单词的一点方法
    CSS布局标准
    前端开发知识之前端移动端适配总结
    用PS制作APP的界面图片
    Hadoop读写过程
    hadoop伪分布式搭建
    centos6.5安装vmware tools&共享文件夹显示
    02-虚拟机克隆配置
    SpringBootの使用Swagger2
    idea快捷键
  • 原文地址:https://www.cnblogs.com/xiaobaozi-95/p/10450380.html
Copyright © 2011-2022 走看看