Upgrade ElasticSearch on Linux

ava-s-dmitriy-drenkalyuk

Suppose you have a system with ElasticSearch server installed and need to upgrade it to a newer version. Below is a step-by-step guide explaining how you can do it, but note that it only works for ElasticSearch pre-1.x versions. It’s also assumed that you have already stopped your ElasticSearch cluster before upgrading.

1) Get the latest ElasticSearch release and move it to the <em>/opt</em> directory:

$ cd ~
$ wget http://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.20.2.tar.gz -O elasticsearch-0.20.2.tar.gz
$ tar -xf elasticsearch-0.20.2.tar.gz
$ rm elasticsearch-0.20.2.tar.gz
$ sudo mv elasticsearch-0.20.2 /optCode language: HTML, XML (xml)

2) Get a service wrapper execution for ElasticSearch. This enables ElasticSearch to be installed and run as Unix daemon. You need to place the service directory to the /opt/elasticsearch-0.20.2/bin:

$ curl -L https://github.com/elasticsearch/elasticsearch-servicewrapper/tarball/master | tar -xz
$ mv *servicewrapper*/service /opt/elasticsearch-0.20.2/bin/
$ rm -Rf *servicewrapper*Code language: JavaScript (javascript)

3) Remove older version of ElasticSearch and install the newest one:

$ /opt/elasticsearch-0.18.7/bin/service/elasticsearch remove
$ sudo /opt/elasticsearch-0.20.2/bin/service/elasticsearch install
$ sudo /etc/init.d/elasticsearch start

4) Check version:

$ curl 'http://localhost:9200'Code language: JavaScript (javascript)

You must see something like this:

{
  "ok" : true,
  "status" : 200,
  "name" : "Max",
  "version" : {
    "number" : "0.20.2",
    "snapshot_build" : false
  },
  "tagline" : "You Know, for Search"
}Code language: JSON / JSON with Comments (json)

5) Upgrade elasticsearch-head plugin:

$ /opt/elasticsearch-0.18.7/bin/plugin -remove mobz/elasticsearch-head
$ /opt/elasticsearch-0.20.2/bin/plugin -install mobz/elasticsearch-head

Enjoy!

UPD. For full info on ElasticSearch upgrade process (including rolling upgrade on newer versions), follow this reference from official ElasticSearch portal: https://www.elastic.co/guide/en/elasticsearch/reference/1.4/setup-upgrade.html.

ava-s-dmitriy-drenkalyuk
DevOps / Senior Software Engineer