How to get Solr Up and Running On OpenShift


Full text search is a vital component in most enterprise or non-enterprise applications and Solr is one of the most popular choices. So, today I decided to spend sometime on getting Solr up and running on OpenShift. In this blog I am sharing all the steps required to get Solr running on OpenShift.

  1. Download the latest version of Solr. The current latest version is 3.5. You can get it from here http://www.apache.org/dyn/closer.cgi/lucene/solr/3.5.0
  2.  Install the OpenShift rhc ruby gem. You can follow steps https://www.redhat.com/openshift/community/kb/kb-e1000/installing-openshift-express-client-tools-on-non-rpm-based-systems
  3. Create a new jbossas-7 application using rhc gem. Type the command shown below.
    rhc-create-app -a solr -t jbossas-7 -d -l email
    
  4. Do a git remove the src and pom.xml files from the created solr maven project and commit the changes.
    git rm -rf src/ pom.xml
    git commit -a -m "removing default files"
    
  5. Copy the solr.war file which exists in apache-solr-3.5.0/example/webapps directory to deployment directory under solr maven project.
  6. Next solr needs a solr home directory. This directory contains a conf directory and lib directory. The default conf directory comes with solr installation and you can find at apache-solr-3.5.0/example/solr/conf. The lib directory should contains apache-solr-velocity-3.5.0.jar, commons-beanutils-1.7.0.jar,commons-collections-3.2.1.jar,velocity-1.6.4.jar,velocity-tools-2.0.jar. The solr home directory will also have index.
  7. On oepenshift you can put data in $OPENSHIFT_DATA_DIR. So create a folder solr.home under $OPENSHIFT_DATA_DIR directory.
  8. Push the conf and lib directory to $OPENSHIFT_DATA_DIR/solr.home directory using rsync.I zipped both conf and lib directory in one solr.zip file and extracted on remote machine.
    rsync -avz -e ssh solr.zip xxx@solr-india.rhcloud.com:$OPENSHIFT_DATA_DIR/solr.home
    
  9. Now you need to add solr.war, commit it and push it to openshift.
    git add .
    git commit -a -m "committing solr war"
    git push
    
  10. The above line will stop the jboss and deploy the war. But you will get exception because you didn’t specified solr home. To do that ssh into the openshift application instance and execute the command shown below.
    ctl_all stop
    export JAVA_OPTS="$JAVA_OPTS -Dsolr.solr.home=$OPENSHIFT_DATA_DIR/solr.home"
    ctl_all start
    

    Finally you will see up and running solr http://solr-india.rhcloud.com/solr/admin/

9 thoughts on “How to get Solr Up and Running On OpenShift

  1. Pingback: How to get Solr Up and Running On OpenShift « Another Word For It

  2. frederico

    you dont have to ssh to server and restart it manually like:

    ctl_all stop
    export JAVA_OPTS=”$JAVA_OPTS -Dsolr.solr.home=$OPENSHIFT_DATA_DIR/solr.home”
    ctl_all start

    open .openshift/action_hooks/pre_start_jbossas-7
    and add the following:

    export JAVA_OPTS=”$JAVA_OPTS -server -d64 -Xms64m -Xmx400m -XX:MaxPermSize=120m -Dsolr.solr.home=$OPENSHIFT_DATA_DIR/solr.home”
    export SOLR_HOME=”$OPENSHIFT_DATA_DIR/solr.home”

    since openshift limits the memory to 512MB, it’s wise to set a maximum of 400MB.
    Thanks for the post.

    Reply
  3. Pingback: OpenShift PaaS Weekly Tips and Tricks - November 18, 2012 - Platform as a Service Magazine

  4. Pingback: OpenShift PaaS Weekly Tips and Tricks - November 18, 2012 - Blog Import Demo Site

  5. Pingback: OpenShift Week in Review Ending April 8, 2012New BlogsNew GitHub QuickstartsNew Events - Blog Import Demo Site

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s