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 /opt directory:

1
2
3
4
5
$ 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 /opt

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:

1
2
3
$ curl -L https://github.com/elasticsearch/elasticsearch-servicewrapper/tarball/master | tar -xz
$ mv *servicewrapper*/service /opt/elasticsearch-0.20.2/bin/
$ rm -Rf *servicewrapper*

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

1
2
3
$ /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:

1
$ curl 'http://localhost:9200'

You must see something like this:

1
2
3
4
5
6
7
8
9
10
{
  "ok" : true,
  "status" : 200,
  "name" : "Max",
  "version" : {
    "number" : "0.20.2",
    "snapshot_build" : false
  },
  "tagline" : "You Know, for Search"
}

5) Upgrade elasticsearch-head plugin:

1
2
$ /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.

Looking to hire a software engineer?
Don't hesitate to contact us.