-
-
Save ricardo-rossi/8265589463915837429d to your computer and use it in GitHub Desktop.
#!/bin/bash | |
### USAGE | |
### | |
### ./ElasticSearch.sh 1.7 will install Elasticsearch 1.7 | |
### ./ElasticSearch.sh will fail because no version was specified (exit code 1) | |
### | |
### CLI options Contributed by @janpieper | |
### Check http://www.elasticsearch.org/download/ for latest version of ElasticSearch | |
### ElasticSearch version | |
if [ -z "$1" ]; then | |
echo "" | |
echo " Please specify the Elasticsearch version you want to install!" | |
echo "" | |
echo " $ $0 1.7" | |
echo "" | |
exit 1 | |
fi | |
ELASTICSEARCH_VERSION=$1 | |
if [[ ! "${ELASTICSEARCH_VERSION}" =~ ^[0-9]+\.[0-9]+ ]]; then | |
echo "" | |
echo " The specified Elasticsearch version isn't valid!" | |
echo "" | |
echo " $ $0 1.7" | |
echo "" | |
exit 2 | |
fi | |
### Install Java 8 | |
cd ~ | |
sudo apt-get install python-software-properties -y | |
sleep 1 | |
sudo add-apt-repository ppa:webupd8team/java -y | |
sleep 1 | |
sudo apt-get update | |
sleep 1 | |
sudo apt-get install oracle-java8-installer -y | |
### Download and install the Public Signing Key | |
wget -qO - https://packages.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - | |
### Setup Repository | |
echo "deb http://packages.elastic.co/elasticsearch/${ELASTICSEARCH_VERSION}/debian stable main" | sudo tee -a /etc/apt/sources.list.d/elk.list | |
### Install Elasticsearch | |
sudo apt-get update && sudo apt-get install elasticsearch -y | |
### Start ElasticSearch | |
sudo service elasticsearch start | |
### Lets wait a little while ElasticSearch starts | |
sleep 5 | |
### Make sure service is running | |
curl http://localhost:9200 | |
### Should return something like this: | |
# { | |
# "status" : 200, | |
# "name" : "Storm", | |
# "version" : { | |
# "number" : "1.3.1", | |
# "build_hash" : "2de6dc5268c32fb49b205233c138d93aaf772015", | |
# "build_timestamp" : "2014-07-28T14:45:15Z", | |
# "build_snapshot" : false, | |
# "lucene_version" : "4.9" | |
# }, | |
# "tagline" : "You Know, for Search" | |
# } | |
@Aldekein i had the same problem -- managed to work around it by changing
echo "deb http://packages.elastic.co/elasticsearch/${ELASTICSEARCH_VERSION}/debian stable main" | sudo tee -a /etc/apt/sources.list.d/elk.list
to
echo "deb http://packages.elasticsearch.org/elasticsearch/1.7/debian stable main" | sudo tee -a /etc/apt/sources.list.d/elasticsearch-1.7.list
Thanks a lot!
❤️ 💋
I would like to upgrade my ES 0.20.2 and I get an:
couldn't connect to host if I run the Shell-Script.
thanks for the script. what about adding nginx + proxy settings too and maybe optional authentication settings for POST,PUT?
Thanks a lot for the complete script
You need to remove or edit regexp for numeric version if you want to install Elasticsearch > 2.
Elasticsearch.sh 2.x will work.
Modified regex as per comment above but I am getting 404 with version 2.x
Failed to fetch http://packages.elastic.co/elasticsearch/2.1.1/debian/dists/stable/main/binary-amd64/Packages 404
Failed to fetch http://packages.elastic.co/elasticsearch/2.1.1/debian/dists/stable/main/binary-i386/Packages 404
Based on this site, the correct repo url is this:
http://packages.elastic.co/elasticsearch/2.x/debian
So your line to add the repo config would be:
echo "deb http://packages.elastic.co/elasticsearch/2.x/debian stable main" | sudo tee -a /etc/apt/sources.list.d/elk.list
Thank you, worked like a charm 👏
Thank you, worked like a charm
for 2.x version of elasticsearch
change the line 23 :
if [[ ! "${ELASTICSEARCH_VERSION}" =~ ^[0-9]+.[0-9]+ ]]; then
to if [[ ! "${ELASTICSEARCH_VERSION}" =~ ^[0-9]+.[0-9|x]+ ]]; then
on 16.04 - work, thanks!
Not working for me. Getting this error :
-
Starting Elasticsearch Server sysctl: setting key "vm.max_map_count": Read-only file system
[fail]
curl: (7) Failed to connect to localhost port 9200: Connection refused
can anyone help here. i am using this shell script mentioned above:
#download and install the Public Signing Key
wget -qO - https://packages.elastic.co/GPG-KEY-elasticsearch | apt-key add -
Setup Repository
echo "deb http://packages.elastic.co/elasticsearch/5.x/debian stable main" | tee -a /etc/apt/sources.list.d/elk.list
Install Elasticsearch
apt-get update && apt-get install elasticsearch -y
Start ElasticSearch
service elasticsearch start
Lets wait a little while ElasticSearch starts
sleep 5
I had to add
sudo apt-get update
before
sudo apt-get install python-software-properties -y