ElasticSearch on Openshift

OpenShift supports the “Do it Yourself” application type. Using this application type, you can run any program that can be accessed through HTTP.

Download the ElasticSearch application from the ElasticSearch website and extract the downloaded package.

For ElasticSearch to run on OpenShift, some configuration options need to be changed. Use your favourite text editor to open the file “elasticsearch.yml” in the “config” folder, and change the following configuration settings:

network.host: ${OPENSHIFT_DIY_IP}
transport.tcp.port: 3306
http.port: ${OPENSHIFT_DIY_PORT}
discovery.zen.ping.multicast.enabled: false
discovery.zen.ping.unicast.hosts: []

Each application on the “DIY” application type is executed by the .openshift/action_hooks/start script, and stopped by the .openshift/action_hooks/stop script. Lets instruct OpenShift to run ElasticSearch, by editing the hook scripts in the folder:

First, open the start script, and replace the content with:

nohup ./elasticsearch > ${OPENSHIFT_DIY_LOG_DIR}/elasticsearch_bin.log 2>&1 &
pgrep -f elasticsearch > ${OPENSHIFT_TMP_DIR}$OPENSHIFT_APP_NAME.pid

Next, replace the stop script with the following code:

echo "stopping: "${OPENSHIFT_APP_NAME}
echo `ps -ef | grep $OPENSHIFT_APP_NAME | grep -v grep | awk '{ print $2 }'`

Now commit your changes and push them to Openshift:

git commit -a -m "install the binhello binary and start stop scripts"
git push

I did not find all of this myself, but used multiple sources of information:

Leave a Reply

Your email address will not be published. Required fields are marked *