十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
Curator 是一个elasticsearch集群管理工具,在日常集群管理方面的一个利器,掌握此神器,es集群日常管理将轻松+愉快。
创新互联公司长期为1000+客户提供的网站建设服务,团队从业经验10年,关注不同地域、不同群体,并针对不同对象提供差异化的产品和服务;打造开放共赢平台,与合作伙伴共同营造健康的互联网生态环境。为志丹企业提供专业的做网站、成都网站设计,志丹网站改版等技术服务。拥有十多年丰富建站经验和众多成功案例,为您定制开发。
如下:
创建索引
删除索引
关闭索引
删除快照
从快照还原
添加或移除索引
打开已经关闭的索引
更改分片路由配置
强制合并索引
更改索引每个分片的副本数量
为索引创建快照
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