Searching with ElasticSearch on OpenShift

Hi, I am new here, so let me introduce myself. My name is Marek and I just joined Red Hat as an OpenShift Evangelist. I am mostly a Ruby guy, but this time, I will show you a more Javaish thing.

Searching capabilities are one the basic features of almost any application, my product of choice for this functionality is ElasticSearch. It provides scalable full-text search engine with a REST interface. In this blog-post we will set up an ElasticSearch instance in OpenShift so that your other applications can use it.


Let’s start with a DIY application and name it for example “elastic”. If you are not familar with the DIY appllication type, check out Mark Atwood’s post here. We do not have to clone it locally, but we connect to it using SSH connection. Being your git URL


to connect to the server using SSH you can issue this command


once you are connected, you should see a welcome “warning” message and a familiar UNIX shell.


OpenShift provides a specific directory that is supposed to be used for the persistent data. Because it would be cool to have the search index persistent, lets use that directory. To get there we can issue

cd elastic/data/

but OpenShift makes it a bit simpler for us, and it provides the specific path using an environment variable


once you are in the directory, download and unpack ElasticSearch, clean up a bit, and enter the ElasticSearch directory

tar xf elasticsearch-0.19.2.tar.gz
rm elasticsearch-0.19.2.tar.gz
mv elasticsearch-0.19.2/ elasticsearch
cd elasticsearch


To run ElasticSearch on OpenShift it’s required to change some configuration options. There is a file in the “config” folder called “elasticsearch.yml”, open it with an editor.

vi config/elasticsearch.yml

now, you have to change these keys and values ${OPENSHIFT_DIY_IP}
transport.tcp.port: 3306
http.port: ${OPENSHIFT_DIY_PORT} false []


Once ElasticSearch is installed and configured, let’s start it. You can test it by running the server in foreground and inspect the logs printed to the standard output.

./bin/elasticsearch -f 

You can validate the functionality by opening the page in your browser. You should see some basic information about your ElasticSearch server. Now, that the server is running … stop it by CTRL+C and start it once again in the background


and you can safely disconnect from OpenShift.

Well done!! You have just set up your first ElasticSearch instance in OpenShift.

Comments are closed.