Last active
January 21, 2018 02:56
-
-
Save shaheemirza/ad0c5f1d1ca948122844 to your computer and use it in GitHub Desktop.
Shell Script to install ElasticSearch on Ubuntu Server
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
### ElasticSearch version | |
if [ -z "$1" ]; then | |
echo "" | |
echo " Please specify the Elasticsearch version you want to install!" | |
echo "" | |
echo " $ $0 1.7.1" | |
echo "" | |
exit 1 | |
fi | |
ELASTICSEARCH_VERSION=$1 | |
if [[ ! "${ELASTICSEARCH_VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+ ]]; then | |
echo "" | |
echo " The specified Elasticsearch version isn't valid!" | |
echo "" | |
echo " $ $0 1.7.1" | |
echo "" | |
exit 2 | |
fi | |
### Install Oracle Java 8, this means you agree to their binary license!! | |
cd ~ | |
sudo add-apt-repository -y ppa:webupd8team/java | |
sudo apt-get update | |
echo debconf shared/accepted-oracle-license-v1-1 select true | sudo debconf-set-selections | |
echo debconf shared/accepted-oracle-license-v1-1 seen true | sudo debconf-set-selections | |
sudo apt-get install aptitude -y | |
sudo apt-get install curl -y | |
sudo aptitude -y install oracle-java8-installer | |
# manually ran these (java7 was installed so the /etc/init.d/elasticsearch script found it instead of java 8): | |
sudo update-java-alternatives -s java-8-oracle | |
sudo apt-get install oracle-java8-set-default | |
### Download and Install ElasticSearch | |
### Check http://www.elasticsearch.org/download/ for latest version of ElasticSearch and replace wget link below | |
wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-${ELASTICSEARCH_VERSION}.deb | |
sudo dpkg -i elasticsearch-${ELASTICSEARCH_VERSION}.deb | |
### Start ElasticSearch | |
sudo service elasticsearch start | |
sleep 10 | |
echo "Now check: curl http://localhost:9200" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment