Created
December 9, 2014 03:00
-
-
Save grantr/a53a9b6b91005ad9807f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
pkill -f 'elasticsearch.*cluster.name=8823' | |
rm -rf data/8823 | |
bin/elasticsearch -Des.node.master=true -Des.cluster.name=8823 -Des.node.name=master 2>&1 >/dev/null & | |
sleep 1 | |
bin/elasticsearch -Des.node.master=false -Des.cluster.name=8823 -Des.node.name=data1 2>&1 >/dev/null & | |
sleep 1 | |
bin/elasticsearch -Des.node.master=false -Des.cluster.name=8823 -Des.node.name=data2 2>&1 >/dev/null & | |
until curl -s localhost:9200/; do echo "--- waiting for master node start..."; sleep 1; done | |
until curl -s localhost:9201/; do echo "--- waiting for data1 node start..."; sleep 1; done | |
until curl -s localhost:9202/; do echo "--- waiting for data2 node start..."; sleep 1; done | |
curl localhost:9200/_cluster/health\?wait_for_status=green | |
echo; echo; echo " --- healthy cluster, no indices ---" | |
sleep 5 | |
curl -XPUT localhost:9200/test/test/1 -d '{"foo":"bar"}' | |
curl localhost:9200/_cluster/health\?wait_for_status=green | |
echo; echo; echo " --- healthy cluster, one index ---" | |
find data/8823 -name _state | |
echo; echo; echo " --- index state directories ---" | |
sleep 5 | |
echo "--- killing master..." | |
pkill -f 'elasticsearch.*master=true.*cluster.name=8823' | |
while pgrep -fq 'elasticsearch.*master=true.*cluster.name=8823'; do echo "waiting for node stop..."; sleep 1; done | |
rm -rvf data/8823/nodes/0 | |
echo; echo "--- deleted master data directory" | |
find data/8823 -name _state | |
echo "--- data1 and data2 index state remains" | |
echo "--- waiting for master node start..." | |
bin/elasticsearch -Des.node.master=true -Des.cluster.name=8823 -Des.node.name=master 2>&1 >/dev/null & | |
curl localhost:9201/_cluster/health\?wait_for_status=green | |
echo; echo; echo "--- healthy cluster, no indices ---" | |
sleep 3 | |
find data/8823 -name _state | |
echo "--- data1 and data2 index state deleted ---" | |
pkill -f 'elasticsearch.*cluster.name=8823' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment