溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

Elasticsearch集群管理工具curator詳解-curator_cli

發(fā)布時(shí)間:2020-08-06 11:52:04 來(lái)源:網(wǎng)絡(luò) 閱讀:2049 作者:無(wú)鋒劍 欄目:大數(shù)據(jù)

介紹

Curator 是一個(gè)elasticsearch集群管理工具,在日常集群管理方面的一個(gè)利器,掌握此神器,es集群日常管理將輕松+愉快。

功能介紹

如下:

創(chuàng)建索引
刪除索引
關(guān)閉索引
刪除快照
從快照還原
添加或移除索引
打開(kāi)已經(jīng)關(guān)閉的索引
更改分片路由配置
強(qiáng)制合并索引
更改索引每個(gè)分片的副本數(shù)量
為索引創(chuàng)建快照
reindices 、remote reindices
rollover indices(當(dāng)某個(gè)別名指向的實(shí)際索引過(guò)大的時(shí)候,自動(dòng)將別名指向下一個(gè)實(shí)際索引)
等等。。。。。

安裝配置(centos7)

install the public signing key:
rpm --import https://packages.elastic.co/GPG-KEY-elasticsearch   

添加repo 文件

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提供了兩種接口。一個(gè)是curator_cli 命令行模式 ,一個(gè)是curator API 模式。  

curator_cli 命令行模式介紹

查看幫助
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

實(shí)例

查看 index

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
查看 snapshots

curator_cli --host 10.33.4.160 --port 9200 show_snapshots --verbose

過(guò)濾特性 (filter)

可以根據(jù)指定條件匹配,然后指定相應(yīng)的動(dòng)作。

實(shí)例演示
將30天以前創(chuàng)建的以ptlog開(kāi)頭的index狀態(tài)為 close
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-"}]'
驗(yàn)證結(jié)果:

查看索引信息

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                                          
發(fā)現(xiàn)符合條件的索引狀態(tài)都調(diào)整為 close !   
將30天以前創(chuàng)建的以ptlog開(kāi)頭的index狀態(tài)為刪除
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-"}]'
輸入結(jié)果如下:
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
再次查看索引信息

發(fā)現(xiàn)所有 close 狀態(tài)的索引都被刪除了,生產(chǎn)環(huán)境推薦這樣操作,先關(guān)閉一段時(shí)間觀察,然后再刪除數(shù)據(jù),畢竟恢復(fù)數(shù)據(jù)比較麻煩。

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

elasticsearch 集群管理工具curator 接口模式使用介紹

https://blog.51cto.com/michaelkang/2333607

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI