Skip to content

Instantly share code, notes, and snippets.

@sudhirpandey
Last active July 31, 2018 12:27
Show Gist options
  • Save sudhirpandey/7a878502c71a850a03b62a40057f38f6 to your computer and use it in GitHub Desktop.
Save sudhirpandey/7a878502c71a850a03b62a40057f38f6 to your computer and use it in GitHub Desktop.
scripts to do maintainence of elastic cluster in openshift
!/bin/bash
array=(083kuvhb 56ghubyf mdaaepif)
RANDOM=$$$(date +%s)
for index in $(curl --key /etc/elasticsearch/secret/admin-key --cert /etc/elasticsearch/secret/admin-cert --cacert /etc/elasticsearch/secret/admin-ca -XGET https://localhost:9200/_cat/shards | grep UNASSIGNED | awk '{print $1}'| sort | uniq); do
for shard in $(curl --key /etc/elasticsearch/secret/admin-key --cert /etc/elasticsearch/secret/admin-cert --cacert /etc/elasticsearch/secret/admin-ca -XGET https://localhost:9200/_cat/shards | grep $index |grep UNASSIGNED | awk '{print $2}'); do
i=${array[$RANDOM % ${#array[@]} ]}
echo "assigning shard $index $shard to logging-es-$i"
curl --key /etc/elasticsearch/secret/admin-key --cert /etc/elasticsearch/secret/admin-cert --cacert /etc/elasticsearch/secret/admin-ca -XPOST 'https://localhost:9200/_cluster/reroute' -d '{
"commands" : [ {
"allocate" : {
"index" : "'"$index"'",
"shard" : '$shard',
"node" : "'"logging-es-$i"'",
"allow_primary" : true
}
}
]
}'
sleep 5
done
done
curl --key /etc/elasticsearch/secret/admin-key --cert /etc/elasticsearch/secret/admin-cert --cacert /etc/elasticsearch/secret/admin-ca -XGET "https://localhost:9200/_cat/indices"
curl --key /etc/elasticsearch/secret/admin-key --cert /etc/elasticsearch/secret/admin-cert --cacert /etc/elasticsearch/secret/admin-ca -XGET "https://localhost:9200/project.name.b6133790-8961-11e6-91c2-005056bd0733.2017.08.17/_search?pretty=1"
More info
https://stackoverflow.com/questions/8954785/elastic-search-how-to-see-the-indexed-data
Kibana fails to load (javascript error) due to lack of mappings solution
add this in kibana config map 1.5.1
io.fabric8.elasticsearch.kibana.mapping.app: /usr/share/elasticsearch/index_patterns/com.redhat.viaq-openshift.index-pattern.json
io.fabric8.elasticsearch.kibana.mapping.ops: /usr/share/elasticsearch/index_patterns/com.redhat.viaq-openshift.index-pattern.json
io.fabric8.elasticsearch.kibana.mapping.empty: /usr/share/elasticsearch/index_patterns/com.redhat.viaq-openshift.index-pattern.json
Reload each elastic servers, and delete the existing kibana iodicess for each users to get it solved
oc exec logging-es-2jpwtagt-3-sjfl0 -- curl -s -X DELETE -k --cert /etc/elasticsearch/secret/admin-cert --key /etc/elasticsearch/secret/admin-key https://logging-es:9200/.kibana.\*
and
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment