日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > linux >内容正文

linux

附9 elasticsearch-curator + Linux定时任务

發布時間:2025/3/15 linux 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 附9 elasticsearch-curator + Linux定时任务 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

官網教程入口: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上邊那個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

?

三、測試

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

?

四、做成Linux定時任務

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、賦予權限

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

3、創建定時任務:crontab?

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

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

  • crontab -l:查看所有的root用戶的定時任務

?

附:crontab的文件格式

分 時 日 月 星期 要運行的命令

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

轉載于:https://www.cnblogs.com/java-zhao/p/5900590.html

總結

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

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。