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.
- 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
- 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
- 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
- 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"
- Copy the solr.war file which exists in apache-solr-3.5.0/example/webapps directory to deployment directory under solr maven project.
- 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.
- On oepenshift you can put data in $OPENSHIFT_DATA_DIR. So create a folder solr.home under $OPENSHIFT_DATA_DIR directory.
- 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
- 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
- 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/
This doesn’t work at all.
LOL, even your URL doesn’t work.
You can run the solr in tomcat
https://openshift.redhat.com/community/blogs/free-apache-tomcat-hosting-in-the-cloud-for-java-applications-its-called-openshift
Thanks!! It worked!!
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.
I can’t install Solr 4.4.0 underway of this