日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) >

附9 elasticsearch-curator + Linux定时任务

發(fā)布時(shí)間:2025/3/15 41 豆豆
生活随笔 收集整理的這篇文章主要介紹了 附9 elasticsearch-curator + Linux定时任务 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

官網(wǎng)教程入口:https://www.elastic.co/guide/en/elasticsearch/client/curator/current/index.html

一、下載安裝

  • 下載:sudo?pip install elasticsearch-curator
  • 更新:sudo?pip install?-U?elasticsearch-curator

版本:curator4.1.0

?

二、配置文件

1、config.yml

1 # Remember, leave a key empty if there is no value. None will be a string, 2 # not a Python "NoneType" 3 client: 4 hosts: ["127.0.0.1:9200"] 5 url_prefix: 6 use_ssl: False 7 certificate: 8 client_cert: 9 client_key: 10 aws_key: 11 aws_secret_key: 12 aws_region: 13 ssl_no_validate: False 14 http_auth: 15 timeout: 30 16 master_only: False 17 18 logging: 19 loglevel: INFO 20 logfile: 21 logformat: default 22 blacklist: ['elasticsearch', 'urllib3'] View Code

說明:https://www.elastic.co/guide/en/elasticsearch/client/curator/current/configfile.html

2、action.yml

1 --- 2 # Remember, leave a key empty if there is no value. None will be a string, 3 # not a Python "NoneType" 4 # 5 # Also remember that all examples have 'disable_action' set to True. If you 6 # want to use this action as a template, be sure to set this to False after 7 # copying it. 8 actions: 9 1: 10 action: delete_indices 11 description: "Delete indices older than 45 days (based on index name), for logstash- prefixed indices. 12 Ignore the error if the filter does not result in an actionable list of indices (ignore_empty_list) and exit cleanly" 13 options: 14 timeout_override: 15 continue_if_exception: False 16 disable_action: False 17 filters: 18 - filtertype: pattern 19 kind: prefix 20 value: logstash- 21 exclude: 22 - filtertype: age 23 source: name 24 direction: older 25 timestring: '%Y.%m.%d' 26 unit: days 27 unit_count: 5 28 exclude: View Code

注意:action上邊那個(gè)1是action id,必須得有

說明:

  • 例子:https://www.elastic.co/guide/en/elasticsearch/client/curator/current/examples.html#ex_delete_indices
  • https://www.elastic.co/guide/en/elasticsearch/client/curator/current/actionfile.html

?

三、測(cè)試

curator --config ~/Desktop/server/elk/es-curator-4.1.0/config.yml ~/Desktop/server/elk/es-curator-4.1.0/action.yml

?

四、做成Linux定時(shí)任務(wù)

1、編寫sh腳本:curator-delete-index.sh

#!/bin/sh /usr/local/bin/curator --config /Users/enniu1/Desktop/server/elk/es-curator-4.1.0/config.yml /Users/enniu1/Desktop/server/elk/es-curator-4.1.0/action.yml echo "delete index success"

注意:最好使用命令的全路徑名,否則可能找不到。

2、賦予權(quán)限

  • chmod 777?/Users/enniu1/Desktop/server/elk/es-curator-4.1.0/curator-delete-index.sh

3、創(chuàng)建定時(shí)任務(wù):crontab?

  • crontab -e:打開了vi,輸入:

    • 30 16 * * * /Users/enniu1/Desktop/server/elk/es-curator-4.1.0/curator-delete-index.sh,之后保存退出vi

  • crontab -l:查看所有的root用戶的定時(shí)任務(wù)

?

附:crontab的文件格式

分 時(shí) 日 月 星期 要運(yùn)行的命令

  • 第1列分鐘1~59
  • 第2列小時(shí)1~23(0表示子夜)
  • 第3列日1~31
  • 第4列月1~12
  • 第5列星期0~7(0和7表示星期天)
  • 第6列要運(yùn)行的命令

轉(zhuǎn)載于:https://www.cnblogs.com/java-zhao/p/5900590.html

總結(jié)

以上是生活随笔為你收集整理的附9 elasticsearch-curator + Linux定时任务的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。