Monthly Archives: April 2012

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/