elasticsearch索引管理
文章发布较早,内容可能过时,阅读注意甄别。
- 1,查看索引。
[root@elk ~]$curl 'localhost:9200/_cat/indices?v'
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
yellow open wf4-2018.12.22 jjRV5VIgTfiv6q8iJ7o69g 5 1 987148 0 328.5mb 328.5mb
yellow open yf1-2018.12.25 fQ_VYwr9QVC3lR_5grMbZw 5 1 27870 0 3.9mb 3.9mb
yellow open yf1-2018.12.22 02oUFAhQT4qSsQruIFad-A 5 1 87549 0 11mb 11mb
yellow open wf2-2018.12.24 yGOPJfu0RI60F3qEl7tUow 5 1 683664 0 108mb 108mb
green open .monitoring-kibana-6-2018.12.24 uIFCkWtSRVeHyFsjEhsrNw 1 0 17276 0 3.3mb 3.3mb
yellow open wf5-2018.12.21 4EPmw4gsQdC1pTtDRN_bHw 5 1 1178566 0 365.8mb 365.8mb
yellow open wf5-2018.12.24 tdmcamTOR3WLV3QD87oRAA 5 1 922208 0 300.1mb 300.1mb
yellow open yf2-2018.12.22 lF9jZAlWTs-RPuUXtYIS0A 5 1 3453 0 955.7kb 955.7kb
yellow open wf2-2018.12.20 rHcSj9HTQ4GmdtKC0Jti2Q 5 1 729169 0 120.4mb 120.4mb
yellow open wf6-2018.12.23 eG_u7bSRSBK9KjV_bykShg 5 1 780374 0 238.6mb 238.6mb
yellow open wf2-2018.12.21 EqRAVZt0TEa65lz_vXe-Yg 5 1 833613 0 137.6mb 137.6mb
green open .monitoring-es-6-2018.12.20 9cj137KuTSiJ_f03ozHjRw 1 0 252715 1342 140.1mb 140.1mb
yellow open wf6-2018.12.20 Vi2W8CR-T4-avVcHlvtblw 5 1 771965 0 236.9mb 236.9mb
yellow open wf6-2018.12.22 Ygm1fRWmR-6FWDHzo6b01w 5 1 806617 0 253.6mb 253.6mb
yellow open wf5-2018.12.23 MjE7n9j8RnWg1iaXeZ78Rw 5 1 965034 0 323.8mb 323.8mb
yellow open wf3-2018.12.24 Por8Fb5oTOe2oLIrjQHasQ 5 1 687247 0 108.8mb 108.8mb
yellow open wf4-2018.12.25 MYdvnUy9TvOYJ6bjnnKNcg 5 1 345203 0 114.8mb 114.8mb
yellow open wf2-2018.12.22 pZRyDlQjRcas5a8ADJz4tw 5 1 797741 0 130.4mb 130.4mb
yellow open wf5-2018.12.20 kc3Lz-KiTi2FXxqNDtDByw 5 1 976625 0 325.2mb 325.2mb
yellow open yf1-2018.12.20 mPpNKYo4TFG8b-AIuKR2mA 5 1 82944 0 10.8mb 10.8mb
yellow open wf2-2018.12.23 Ve3quMvSRi6AOMKCBrPQsA 5 1 754477 0 120.1mb 120.1mb
yellow open wf6-2018.12.25 v43r_cUeTUajiRU7q3n83Q 5 1 271405 0 81.9mb 81.9mb
green open .newakibana_1 yKhbNPo8Txa8JOL9fhfSbw 1 0 0 0 261b 261b
yellow open yf4-2018.12.20 o7AuGVbWS06r1Vaoc5DN7Q 5 1 83029 0 10.9mb 10.9mb
yellow open wf3-2018.12.22 kDlpAjgRTsKqBVbc0MSH5w 5 1 802308 0 131.7mb 131.7mb
yellow open yf3-2018.12.24 tUo_N44rS0CgNUsEeLEBvQ 5 1 896500 0 146.3mb 146.3mb
yellow open logstash-nginx-access-2018-12 ZCPK_OcESUeglzl75PqYGA 5 1 19211932 0 8.9gb 8.9gb
yellow open wf6-2018.12.21 RNqBKXCYS3CZMGof522GlA 5 1 879132 0 266.8mb 266.8mb
yellow open yf2-2018.12.24 HlinQ8W2Qc26Na4EvOadyQ 5 1 456517 0 75.5mb 75.5mb
yellow open wf1-2018.12.23 _YD9-pscTcCxdRTDcVk5aA 5 1 752487 0 119.8mb 119.8mb
green open .monitoring-es-6-2018.12.25 a0dYH288QlKonNsfG03hhA 1 0 225804 10080 155.3mb 155.3mb
green open .monitoring-es-6-2018.12.18 MwHqiBRySR2J4zAb6bcLaQ 1 0 460669 18860 222.5mb 222.5mb
yellow open wf4-2018.12.24 z5E3CS4DSy-pPmQusK0sqQ 5 1 914839 0 298.6mb 298.6mb
yellow open yf3-2018.12.22 X3z2128QTCyCTThtuELFBg 5 1 3456 0 914.9kb 914.9kb
yellow open wf4-2018.12.21 a-Yd46WESTaPDtVvdI0ogg 5 1 1182077 0 366.7mb 366.7mb
yellow open wf1-2018.12.24 _Z_t0HuZShG1iq-1QC5nMw 5 1 689415 0 109.2mb 109.2mb
yellow open wf3-2018.12.20 RxJJozV2TSGLlePYIPFwAA 5 1 722696 0 119.9mb 119.9mb
green open .monitoring-kibana-6-2018.12.19 59sHqlzeQE-gr35Zic0LLw 1 0 8291 0 2.6mb 2.6mb
yellow open wf1-2018.12.22 Nq5AsVocSwe6za5_XpG1Bg 5 1 795699 0 130.4mb 130.4mb
yellow open wf5-2018.12.25 NMxEc7AnSkWzXHhE542J2g 5 1 343157 0 112.6mb 112.6mb
green open .monitoring-es-6-2018.12.21 LWEfDSZYSJOrsZ8SmTF8kw 1 0 338715 4032 194.5mb 194.5mb
yellow open yf2-2018.12.21 AUNgViEIT_ey0F4iSucxAQ 5 1 4594 0 1.7mb 1.7mb
yellow open yf2-2018.12.23 pofWG8tWSyiX4w0YgRBvig 5 1 3456 0 874.5kb 874.5kb
yellow open wf3-2018.12.23 1FraDw-3TE-j0pj52yZ8tw 5 1 749250 0 119.4mb 119.4mb
green open .monitoring-kibana-6-2018.12.21 wb-6_lAPRR-RBGktnFqWOg 1 0 17276 0 3.4mb 3.4mb
yellow open wf1-2018.12.20 z_ISOyHlS1eRXxGp1Byrwg 5 1 973777 0 159mb 159mb
yellow open yf3-2018.12.21 3j2MM-mlQCOXmSAOWUQ4Iw 5 1 4721 0 1.5mb 1.5mb
green open .monitoring-es-6-2018.12.22 Zjz4t_fySWWC1stOrPU-OA 1 0 442509 5542 252.8mb 252.8mb
yellow open yf4-2018.12.25 7u7ADSk8Sc2xVBQEvcgBdQ 5 1 27953 0 4mb 4mb
yellow open yf3-2018.12.25 jrhWhJTVSeq4CK2bK1XkxA 5 1 3042 0 1.8mb 1.8mb
green open .monitoring-es-6-2018.12.19 V543MHwZSeW6JLMxVgb6pw 1 0 99229 8538 43.3mb 43.3mb
yellow open yf4-2018.12.24 Jjn7KfY6QQyAjxQNbw31BA 5 1 129340 0 18.2mb 18.2mb
yellow open yf4-2018.12.22 WGr4vuvWSKeO6pRD3rwl2Q 5 1 87552 0 11.1mb 11.1mb
yellow open yf1-2018.12.21 y9IQ6gPGToe4zNiC8H2Gmw 5 1 87978 0 11.3mb 11.3mb
green open .tasks Wh2WiKW-SRuR_fR6t14Rcw 1 0 1 0 6.2kb 6.2kb
green open .monitoring-es-6-2018.12.23 U2hmu-GVRlyKx5b4IND1Rg 1 0 546436 6691 299.1mb 299.1mb
yellow open wf3-2018.12.21 9vu65HJgTAiS8P6sFxLrNQ 5 1 831776 0 137.7mb 137.7mb
yellow open yf2-2018.12.20 SWkBA1vrQLyeFhTnDyTWEg 5 1 7081 0 2.4mb 2.4mb
yellow open yf4-2018.12.23 qHyK0yDrSSmpMqFsbuKulg 5 1 87549 0 11.1mb 11.1mb
yellow open yf3-2018.12.20 GWujzIc4Sx6ekKL0cUHu8w 5 1 6763 0 2.7mb 2.7mb
yellow open wf4-2018.12.20 jT8xleSZQ0yT4xtwYqhBfQ 5 1 960724 0 318.2mb 318.2mb
yellow open yf1-2018.12.24 lwb7v1u-S4-o7lKvOgsj7A 5 1 131699 0 18.4mb 18.4mb
yellow open wf2-2018.12.25 sgEb3lf9Tz-kTs8n6z3LJg 5 1 230312 0 39.1mb 39.1mb
green open .monitoring-kibana-6-2018.12.25 jQQiSq7rQfSjMD4i7PRC3A 1 0 5238 0 1.1mb 1.1mb
green open .newkibana_2 e87PQRE0TQOA1IevT7Vr7A 1 0 18 8 59kb 59kb
green open .monitoring-kibana-6-2018.12.23 K5JRbvvIQUSfLZVURdfAoA 1 0 17274 0 3.3mb 3.3mb
yellow open yf3-2018.12.23 6k-QdQGeRb2uqe_ChyeGTQ 5 1 3456 0 918.8kb 918.8kb
yellow open yf4-2018.12.21 pdlPPoBTTy2MdU-QT4aUKA 5 1 87921 0 11.2mb 11.2mb
yellow open wf4-2018.12.23 SoobGvkrTUe-WeRpzQSCtQ 5 1 955903 0 319.8mb 319.8mb
green open .monitoring-kibana-6-2018.12.18 KS5oKtpgTUiia5NkteCGvw 1 0 10941 0 3.2mb 3.2mb
green open .monitoring-kibana-6-2018.12.20 xiMGIJY_Qs-i2H_C3zFdrw 1 0 14001 0 3mb 3mb
yellow open wf1-2018.12.25 M7LLDaI1QoexnEQIBfdP7A 5 1 227287 0 38.5mb 38.5mb
yellow open wf6-2018.12.24 ysFDJ2HUSJCsXRWD1zZz6A 5 1 731664 0 220.9mb 220.9mb
yellow open yf1-2018.12.23 3eOixFw3SuOqPdDBjALB2w 5 1 87549 0 11.1mb 11.1mb
yellow open yf2-2018.12.25 p8rzGkFjSx-G35si_OIkEQ 5 1 2976 0 1.8mb 1.8mb
yellow open wf1-2018.12.21 Ad7dfIbyTrGbGtSG0hdOzw 5 1 831372 0 137.5mb 137.5mb
green open .newkibana_1 ao_IxYXDTDyTljxR1b3Fvw 1 0 13 0 30.8kb 30.8kb
yellow open wf3-2018.12.25 RrDqLajjR_iWYaXcAhue1w 5 1 227969 0 38.6mb 38.6mb
yellow open wf5-2018.12.22 wdiLC5iGSC2wNGbKWVTpQA 5 1 981146 0 332.9mb 332.9mb
green open .monitoring-es-6-2018.12.24 _vavT7VoRD-D7BuZQ7C2kg 1 0 646545 7930 358.4mb 358.4mb
green open .monitoring-kibana-6-2018.12.22 yPtt_vzKS_C4hbXfNxQsgw 1 0 17276 0 3.2mb 3.2mb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
- 2,删除指定索引。
curl -XDELETE -u elastic:changeme http://localhost:9200/acc-apply-2018.08.09
1
- 3,删除指定多个索引。
多个索引之间用,
隔开。
curl -XDELETE -u elastic:changeme http://localhost:9200/acc-apply-2018.08.09,acc-apply-2018.08.10
1
- 4,模糊匹配删除。
curl -XDELETE -u elastic:changeme http://localhost:9200/acc-apply-*
1
- 5,使用通配符,删除所有的索引
curl -XDELETE http://localhost:9200/_all
或 curl -XDELETE http://localhost:9200/*
1
2
2
_all
,*
通配所有的索引
通常不建议使用通配符,误删了后果就很严重了,所有的 index 都被删除了 禁止通配符为了安全起见,可以在 elasticsearch.yml 配置文件中设置禁用_all 和*通配符
action.destructive_requires_name = true
1
这样就不能使用_all 和*了
- 6,定时删除索引。
可以通过脚本的形式。删除 3 天前的索引。
#!/bin/bash
time=$(date -d '-3days' +'%Y.%m.%d')
curl -XDELETE -u elastic:changeme http://localhost:9200/*-${time}
1
2
3
2
3
也可以通过写入定时任务。删除 3 天前的索引。
30 2 * * * /usr/bin/curl -XDELETE -u elastic:changeme http://localhost:9200/*-$(date -d '-3days' +'%Y.%m.%d') >/dev/null 2>&1
1
参考:https://www.cnblogs.com/Dev0ps/p/9493576.html
上次更新: 2024/11/28, 21:21:13