Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Elasticsearch startup script on GCE
# install java
apt-get update
apt-get -y install openjdk-7-jre-headless
# install elasticsearch
VERSION="1.4.2"
wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-$VERSION.tar.gz -O /tmp/elasticsearch-$VERSION.tar.gz
tar zxvf /tmp/elasticsearch-$VERSION.tar.gz -C /usr/local/
ln -s /usr/local/elasticsearch-$VERSION /usr/local/elasticsearch
cd /usr/local/elasticsearch
bin/plugin install mobz/elasticsearch-head
bin/plugin install elasticsearch/elasticsearch-cloud-gce/2.4.1
# setting elasticsearch
PROJECT_ID=$(curl http://metadata/computeMetadata/v1/project/project-id -H "Metadata-Flavor: Google")
ZONE=$(curl http://metadata/computeMetadata/v1/instance/zone -H "Metadata-Flavor: Google" | cut -d"/" -f 4)
echo "
cluster.name: gce-elasticsearch # SET YOUR CLUSTER NAME
cloud:
gce:
project_id: $PROJECT_ID
zone: $ZONE
discovery:
type: gce
" >> config/elasticsearch.yml
# start elasticsearch
bin/elasticsearch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment