您好,登錄后才能下訂單哦!
Curator 是一個elasticsearch集群管理工具,在日常集群管理方面的一個利器,掌握此神器,es集群日常管理將輕松+愉快。
如下:
創建索引
刪除索引
關閉索引
刪除快照
從快照還原
添加或移除索引
打開已經關閉的索引
更改分片路由配置
強制合并索引
更改索引每個分片的副本數量
為索引創建快照
reindices 、remote reindices
rollover indices(當某個別名指向的實際索引過大的時候,自動將別名指向下一個實際索引)
等等。。。。。
rpm --import https://packages.elastic.co/GPG-KEY-elasticsearch
RHEL/CentOS 7:
cat >/etc/yum.repos.d/es-curator.repo <<-EOF
[curator-5]
name=CentOS/RHEL 7 repository for Elasticsearch Curator 5.x packages
baseurl=https://packages.elastic.co/curator/5/centos/7
gpgcheck=1
gpgkey=https://packages.elastic.co/GPG-KEY-elasticsearch
enabled=1
EOF
yum install elasticsearch-curator -y
curator提供了兩種接口。一個是curator_cli 命令行模式 ,一個是curator API 模式。
curator_cli --help
Usage: curator_cli [OPTIONS] COMMAND [ARGS]...
Commands:
allocation Shard Routing Allocation
close Close indices
delete_indices Delete indices
delete_snapshots Delete snapshots
forcemerge forceMerge index/shard segments
open Open indices
replicas Change replica count
show_indices Show indices
show_snapshots Show snapshots
snapshot Snapshot indices
curator_cli --host 10.33.4.160 --port 9200 show_indices --verbos
ptlog-prod-userservice-2018.11.20 open 58.4MB 185964 5 1 2018-11-20T00:00:09Z
ptlog-prod-userservice-2018.11.21 open 58.3MB 185658 5 1 2018-11-21T00:00:12Z
ptlog-prod-userservice-2018.11.22 open 57.5MB 182808 5 1 2018-11-22T00:00:18Z
ptlog-prod-userservice-2018.11.23 open 56.7MB 180296 5 1 2018-11-23T00:00:18Z
curator_cli --host 10.33.4.160 --port 9200 show_snapshots --verbose
可以根據指定條件匹配,然后指定相應的動作。
curator_cli --host 172.20.11.32 --port 9200 close --filter_list '[{"filtertype":"age","source":"creation_date","direction":"older","unit":"days","unit_count":30},{"filtertype":"pattern","kind":"prefix","value":"ptlog-"}]'
查看索引信息
GET _cat/indices
green open 15_hot_v1 P1FnKd6FRsG7NmnoWZ5hZA 20 1 1780400 59939 1.9gb 981.1mb
close ptlog-pte-prod-userservice-2018.11.12 LaAHL-KKToqQ30f0dX6pqw
green open ptlog-pte-prod-userservice-2018.11.27 bXIzgcrVR1eki8NpehUWcA 5 1 91756 0 57.6mb 28.8mb
close ptlog-ddv-syslog-2018.10.26 x4lnrJbbQ_uD4UXR8iXGWw
green open ptlog-ddv-trace-2018.12.03 BrGrgpsYQFOQM0TVHgR-QA 5 1 110 0 896.2kb 438.6kb
close ptlog-pte-prod-ptservice-2018.11.09 A4Fil2BkRUC70jjcW9iczQ
close ptlog-pte-prod-userservice-2018.10.24 0eNY0RzYSNuxH5Fm5bpM9A
發現符合條件的索引狀態都調整為 close !
curator_cli --host 172.20.11.32 --port 9200 delete_indices --filter_list '[{"filtertype":"age","source":"creation_date","direction":"older","unit":"days","unit_count":30},{"filtertype":"pattern","kind":"prefix","value":"ptlog-"}]'
2018-12-12 14:33:57,064 INFO ---deleting index ptlog-ddv-syslog-2018.10.23
...........
2018-12-12 14:33:57,066 INFO ---deleting index ptlog-ddv-syslog-2018.11.02
2018-12-12 14:33:57,066 INFO ---deleting index ptlog-ddv-syslog-2018.10.31
2018-12-12 14:33:57,066 INFO ---deleting index ptlog-pte-prod-userservice-2018.10.25
發現所有 close 狀態的索引都被刪除了,生產環境推薦這樣操作,先關閉一段時間觀察,然后再刪除數據,畢竟恢復數據比較麻煩。
GET _cat/indices
green open 15_hot_v1 P1FnKd6FRsG7NmnoWZ5hZA 20 1 1780726 59943 1.9gb 987.4mb
green open 6c_hot_v1 TIiPrWmaTRCPUShBfVdVIw 20 1 34826911 369431 37gb 18.4gb
green open ptlog-event-pte-prod-ecology-2018.12.10 FSgH1MFkRbKkR7Y27ugNXA 2 1 0 0 1kb 522b
https://blog.51cto.com/michaelkang/2333607
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。