Skip to content

Instantly share code, notes, and snippets.

@tomoemon
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomoemon/4f1042f8fccf02efd52a to your computer and use it in GitHub Desktop.
Save tomoemon/4f1042f8fccf02efd52a to your computer and use it in GitHub Desktop.
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