工作生活

2019-07-03 使用 elasticsearch cura

2019-07-04  本文已影响0人  oo_思维天空

什么是elasticsearch curator

curator 是管理elasticsearch 索引生命周期的工具, 有如下功能

installation

~ cd /opt/app
~ virtualenv  --no-site-packages --python=python2.7 elasticsearch-curator
~ source elasticsearch-curator/bin/activate
~ pip install -U elasticsearch-curator==5.7.6 
~ deactivate

config

 client:
  hosts:
    - XXX.XXX.XXX.XX1:9200
    - XXX.XXX.XXX.XX2:9200
    - XXX.XXX.XXX.XX3:9200
  port: 9200
  url_prefix:
  use_ssl: False
  certificate:
  client_cert:
  client_key:
  ssl_no_validate: False
  http_auth:
  timeout: 30
  master_only: False

logging:
  loglevel: INFO
  logfile:
  logformat: default
  blacklist: ['urllib3']
actions:
  1:
    action: forcemerge
    description: >-
      forceMerge XXXXX- prefixed indices and over
      to 2 segments per shard.  Delay 60 seconds between each
      forceMerge operation to allow the cluster to quiesce. Skip indices that
      have already been forcemerged to the minimum number of segments to avoid
      reprocessing.
    options:
      max_num_segments: 1
      delay: 10
      timeout_override: 21600
      continue_if_exception:
      disable_action:
    filters:
    - filtertype: pattern
      kind: prefix
      value: XXXXXXX
      exclude:
    - filtertype: forcemerged
      max_num_segments: 2
      exclude: True
#!/bin/bash
set -e
. "/etc/profile"
. "/home/$USER/.bashrc"
. "/opt/app/elasticsearch-curator/bin/activate"
curDir=$(cd `dirname $0`; pwd)
cd $curDir
curator --config config.yml formerge.yml

上调度定时执行

总结

使用curator比自己写shell去维护索引方便很多 , 而且功能支持的支持的比较全面.

renfrence

https://www.elastic.co/guide/en/elasticsearch/client/curator/current/about-features.html

上一篇 下一篇

猜你喜欢

热点阅读