设为首页 收藏本站
查看: 1521|回复: 0

[经验分享] Elasticsearch 集群管理工具curator 接口模式使用介绍

[复制链接]
发表于 2019-1-29 10:56:27 | 显示全部楼层 |阅读模式
  安装配置参考文档:
http://blog.运维网.com/michaelkang/2333586

curator 接口模式使用介绍

curator的命令行语法如下:
  curator [--config CONFIG.YML] [--dry-run] ACTION_FILE.YML

--config : 之后跟上配置文件
--dry-run :调试参数,测试脚本运行是否正常;
ACTION_FILE.YML :action文件中可以包含一连串的action,curator接口集中式的config和action管理,可以方便我们重用变量,更利于维护和阅读。
环境初始化也可以至通过 curator [--config CONFIG.YML] 直接指定
#### linux 默认查找路径:

  ~/.curator/curator.yml
  环境初始化也可以至通过 curator [--config CONFIG.YML] 直接指定


#### 初始化系统环境
  配置 [--config CONFIG.YML]

mkdir -p  ~/.curator/
vim ~/.curator/curator.yml
---
# Remember, leave a key empty if there is no value.  None will be a string,
# not a Python "NoneType"
client:
hosts:
- 172.20.11.32     《== 集群节点IP地址,可以写多个
port: 9200           《== datanode 接口
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: ['elasticsearch', 'urllib3']
重要选项介绍

loglevel 支持 :
CRITICAL will only display critical messages.
ERROR will only display error and critical messages.
WARNING will display error, warning, and critical messages.
INFO will display informational, error, warning, and critical messages.
DEBUG will display debug messages, in addition to all of the above.
logfile 支持:
default, json, logstash 或者留空;
blacklist 支持:
那些关键字开头索引日志不输出,默认即可。
ACTION_FILE.YML  介绍

action
每个action由三部分组成:
- action,具体执行什么操作
- option, 配置哪些可选项
- filter, 过滤条件,哪些index需要执行action
支持的动作如下:

Alias
Allocation
Close
Cluster Routing
Create Index
Delete Indices
Delete Snapshots
forceMerge
Index Settings
Open
Reindex
Replicas
Restore
Rollover
Shrink
Snapshot
  option: 选项 ,filter:过滤条件,哪些index需要执行action,详细参考官网;
  https://www.elastic.co/guide/en/elasticsearch/client/curator/current/actions.html

实例

实例1 :定期删除旧index

more delete_indices-eslog-ptlog.yml
actions:
1:
action: delete_indices
description: >-
删除超过20天的索引(基于索引名称),monitoring-*
前缀索引。如果过滤器没有导致错误,请忽略错误
可操作的索引列表(ignore_empty_list)并彻底退出.
options:
ignore_empty_list: True
disable_action: False
filters:
- filtertype: pattern
kind: regex
value: '^(\.monitoring-(es|kibana|logstash)-).*$'
- filtertype: age
source: name
direction: older
timestring: '%Y.%m.%d'
unit: days
unit_count: 20
2:
action: delete_indices
description: >-
删除超过10天的索引(基于索引名称ptlog)
options:
ignore_empty_list: True
disable_action: False
filters:
- filtertype: pattern
kind: prefix
value: ptlog
- filtertype: age
source: name
direction: older
timestring: '%Y.%m.%d'
unit: days
unit_count: 10
实例2:reindex每天生成的index文件到月index文件
  将所有每天生成的ptlog-dd-trace-prod-app-gateway-2018.11.文件汇总到  ptlog-dd-trace-prod-app-gateway-2018.11 月日志文件,然后删除 ptlog-dd-trace-prod-app-gateway-2018.11. 的日志文件。
  用于合并琐碎index文件,减少集群分片数;

awsesbak-reindex.yml
---
actions:
1:
description: >-
Reindex 11月份每天生成的index数据到 ptlog-$name-2018.11
action: reindex
options:
disable_action: False
wait_interval: 9
max_wait: -1
request_body:
source:
index: REINDEX_SELECTION
dest:
index: ptlog-dd-trace-prod-app-gateway-2018.11
filters:
- filtertype: pattern
kind: prefix
value: ptlog-dd-trace-prod-app-gateway-2018.11.
2:
action: delete_indices
description: >-
删除已经完成合并的索引
options:
ignore_empty_list: True
disable_action: False
filters:
- filtertype: pattern
kind: prefix
value: ptlog-dd-trace-prod-app-gateway-2018.11.



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-669093-1-1.html 上篇帖子: elasticsearch配置文件详解 下篇帖子: ELK(elasticsearch+logstash+kibana)日志分析系统
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表