ES - script pour les opérations sur les indexes
Alasta 28 Avril 2016 bigdata shell cli BigData elasticsearch
Description : Voici un script pour les opérations des indexes Elasticsearch.
Description :
Voici un script pour des opérations courantes basiques sur les indexes ES, telle que le delete, open, close et list.
Script : es-operations.sh
Help
1 ./es-operations.sh -h
2
3 Description : Script to Elasticsearch operations.
4
5 Usage : es-operations.sh [-h] [-l] [-S] [-D] -H <host> -P <port> -p <proxypass path> -c <command operation> -i <index>
6
7 -h : Help
8 -D : Debug script
9 -S : Web Server is HTTPS
10 -H : Elasticsearch host - mandatory
11 -P : Elasticsearch port - mandatory
12 -p : Web Server proxypass if is set (set -P to listen port of Web Server) - mandatory
13 -c : Command :
14 - delete
15 - open
16 - close
17 - list
18
19 -i : index
Note : il est possible de faire une requête en HTTP/HTTPS, au travers d'un Apache/NGINX en mode reverse proxy.
Exemples
Liste des indexes
En direct
1 ./es-operations.sh -H 127.0.0.1 -P 9200 -c list
2 #####=> Result to list
3 health index pri rep docs.count docs.deleted store.size pri.store.size
4 green logstash-2015.07.30 5 0 86 0 292.4kb 292.4kb
5 green logstash-2014.09.28 5 0 376 0 407.7kb 407.7kb
6 green kibana-int 5 0 3 0 43.3kb 43.3kb
7 green nodes_stats 1 0 42 0 648.4kb 648.4kb
8 yellow logstash-2014.10.22 5 1 17 0 40.1kb 40.1kb
9 green logstash-2014.10.18 5 0 7 0 36.3kb 36.3kb
10 yellow logstash-2016.04.27 5 1 32 0 151.6kb 151.6kb
11 green logstash-2014.09.08 5 0 114 0 242kb 242kb
12 yellow logstash-2016.04.28 5 1 45 0 245.2kb 245.2kb
Via un reverse proxy
1 ./es-operations.sh -H 192.168.5.40 -P 80 -p /my_elasticsearch -c list
2 #####=> Result to list
3 health index pri rep docs.count docs.deleted store.size pri.store.size
4 green logstash-2015.07.30 5 0 86 0 292.4kb 292.4kb
5 green logstash-2014.09.28 5 0 376 0 407.7kb 407.7kb
6 green kibana-int 5 0 3 0 43.3kb 43.3kb
7 green nodes_stats 1 0 44 0 719.2kb 719.2kb
8 yellow logstash-2014.10.22 5 1 17 0 40.1kb 40.1kb
9 green logstash-2014.10.18 5 0 7 0 36.3kb 36.3kb
10 yellow logstash-2016.04.27 5 1 32 0 151.6kb 151.6kb
11 green logstash-2014.09.08 5 0 114 0 242kb 242kb
12 yellow logstash-2016.04.28 5 1 48 0 274.7kb 274.7kb
Fermer un index
1 ./es-operations.sh -H 127.0.0.1 -P 9200 -c close -i logstash-2014.10.22
2 #####=> Result to close
3 {"acknowledged":true}
Fermer X index
1 ./es-operations.sh -H 127.0.0.1 -P 9200 -c close -i logstash-2014.10.*
2 #####=> Result to close
3 {"acknowledged":true}
Ouverture d'un index
1 ./es-operations.sh -H 127.0.0.1 -P 9200 -c open -i logstash-2014.10.22
2 #####=> Result to open
3 {"acknowledged":true}
Suppression d'un index
1 ./es-operations.sh -H 127.0.0.1 -P 9200 -c delete -i logstash-2014.10.22
2 #####=> Result to delete
3 {"acknowledged":true}