Skip to content

Instantly share code, notes, and snippets.

@martindilling
Last active April 17, 2018 08:41
Show Gist options
  • Save martindilling/a7a5c6e73214bc253bb6b81a512f68b0 to your computer and use it in GitHub Desktop.
Save martindilling/a7a5c6e73214bc253bb6b81a512f68b0 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Replace with the correct url to the raw file
# curl -L https://url_to_raw/install_elasticsearch.sh | bash
echo "###"
echo "### Install Java 8..."
echo "###"
sudo apt-get update
sudo apt-get install -y python-software-properties debconf-utils
sudo add-apt-repository -y ppa:webupd8team/java
sudo apt-get update
echo "oracle-java8-installer shared/accepted-oracle-license-v1-1 select true" | sudo debconf-set-selections
sudo apt-get install -y oracle-java8-installer
echo "JAVA_HOME=\"/usr/lib/jvm/java-8-oracle\"" >> /etc/environment
source /etc/environment
echo "# JAVA_HOME is set to: " $JAVA_HOME
echo "# Done installing Java..."
echo "###"
echo "### Install Elasticsearch..."
echo "###"
pushd /tmp
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.2.3.deb
popd
# Install the deb
sudo dpkg -i /tmp/elasticsearch-6.2.3.deb
# Start with the system
sudo systemctl enable elasticsearch.service
# Update some config
sudo sed -i 's/#cluster.name: my-application/cluster.name: fullrate-search-dev/' /etc/elasticsearch/elasticsearch.yml
sudo sed -i 's/#node.name: node-1/node.name: dev-node-1/' /etc/elasticsearch/elasticsearch.yml
sudo sed -i 's/#http.port: 9200/http.port: 9200/' /etc/elasticsearch/elasticsearch.yml
# ONLY FOR TESTING
sudo sed -i 's/#network.host: 192.168.0.1/network.host: 0.0.0.0/' /etc/elasticsearch/elasticsearch.yml
# Set the memory usage elasticsearch should use
sudo sed -i 's/Xms1g/Xms1g/' /etc/elasticsearch/jvm.options
sudo sed -i 's/Xmx1g/Xmx1g/' /etc/elasticsearch/jvm.options
# Start now
sudo systemctl start elasticsearch
# Check connection to elasticsearch
sudo curl -X GET 'http://localhost:9200'
echo "# Done installing Elasticsearch..."
echo "###"
echo "### Install Kibana..."
echo "###"
pushd /tmp
wget https://artifacts.elastic.co/downloads/kibana/kibana-6.2.3-amd64.deb
popd
# Install the deb
sudo dpkg -i /tmp/kibana-6.2.3-amd64.deb
# Start with the system
sudo /bin/systemctl daemon-reload
sudo /bin/systemctl enable kibana.service
# Update some config
sudo sed -i 's/#server.port: 5601/server.port: 5601/' /etc/kibana/kibana.yml
# ONLY FOR TESTING
sudo sed -i 's/#server.host: "localhost"/server.host: "0.0.0.0"/' /etc/kibana/kibana.yml
sudo sed -i 's/#server.name: "your-hostname"/server.name: "Fullrate Search (dev)"/' /etc/kibana/kibana.yml
sudo sed -i 's/#elasticsearch.url: "http:\/\/localhost:9200"/elasticsearch.url: "http:\/\/localhost:9200"/' /etc/kibana/kibana.yml
# Start now
sudo systemctl start kibana.service
echo "# Done installing Kibana..."
IP=`wget http://icanhazip.com -qO-`
echo ""
echo "##########"
echo "# Elasticsearch: http://${IP}:9200"
echo "# Kibana: http://${IP}:5601"
echo "##########"
echo ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment