Solr on Ubercart.org
During our hackathon @ ubercamp we decided to install solr search on ubercart.org. Here is how we got solr running as a service, with tomcat, drupal, and the Apachesolr module.
Install solr / tomcat
I decided to use tomcat in this case, mainly because I wanted to create an init script to start/stop the solr serivce, and to automatically bring it online when the server is rebooted.
I followed the SolrTomcat Instructions, except I didn't start tomcat. We need to change a couple things first.
mkdir solr-tomcat
cd solr-tomcat/
wget http://mirrors.ibiblio.org/pub/mirrors/apache/tomcat/tomcat-5/v5.5.25/bin/apache-tomcat-5.5.25.zip
NIGHTLY=solr-`/bin/date +%F`
wget http://people.apache.org/builds/lucene/solr/nightly/$NIGHTLY.zip
unzip apache-tomcat-5.5.25.zip
unzip $NIGHTLY.zip
cp apache-solr-nightly/dist/apache-solr-nightly.war apache-tomcat-5.5.25/webapps/solr.war
cp -r apache-solr-nightly/example/solr .
chmod a+x apache-tomcat-5.5.25/bin/*
Configuring Tomcat
If you start tomcat right now, everything will work as long as you launch the service from this directory. This won't play friendly with an init script, so we are going to make a few changes.
First we're going to follow the solrtomcat instructions for Configuring Solr Home with JNDI.cd apache-tomcat-5.5.25/conf/Catalina/localhost/
nano solr.xml
Add the following but replace the docBase and solr/home value with your actual paths:
<Context docBase="/var/solr-tomcat/apache-tomcat-5.5.25/webapps/solr.war" debug="0" crossContext="true" >
<Environment name="solr/home" type="java.lang.String" value="/var/solr-tomcat/solr" override="true" />
</Context>
By default all of the solr information will be stored in the directory where the service is launched. We are going to change the solrconfig.xml to save things where we want them:
cd ../../../../solr/conf
nano solrconfig.xml
Look for dataDir and change it to the absolute path to the solr directory:
<!-- Used to specify an alternate directory to hold all index data
other than the default ./data under the Solr home.
If replication is in use, this should match the replication configuration. -->
<dataDir>/var/solr-tomcat/solr/</dataDir>
Since we are in the solr conf directory, we are going to replace the schema.xml file with the one packaged with the apachesolr module:
cp /path/to/apachsolr/schema.xml ./
Adding the init script
Next we are going to add an init script to start/stop the server.
cd /etc/init.d
nano solr
copy / paste the following init script, make sure the paths are correct
#! /bin/sh
# Basic support for IRIX style chkconfig
###
# chkconfig: 235 98 55
# description: Manages the services you are controlling with the chkconfig command
###
case "$1" in
start)
echo -n "Starting solr"
#To run it as root:
/var/solr-tomcat/apache-tomcat-5.5.25/bin/startup.sh
echo "."
;;
stop)
echo -n "Stopping solr"
/var/solr-tomcat/apache-tomcat-5.5.25/bin/shutdown.sh
echo "."
;;
*)
echo "Usage: /sbin/service solr {start|stop}"
exit 1
esac
exit 0
Now we are going to make the script executable, and enable it with chkconfig:
chmod 755 solr
chkconfig --add solr
Start it up
/etc/init.d/solr start
You should be able to browse to your url on port 8080 and see a tomcat splash screen. /solr/admin will show you the solr admin interface. If you get the following error there is one more thing to do.
Starting solrNeither the JAVA_HOME nor the JRE_HOME environment variable is defined
Modify the catalina script:
At least one of these environment variable is needed to run this program
nano /var/solr-tomcat/apache-tomcat-5.5.25/bin/catalina.sh
and add the proper location to the JAVA_HOME variable
JAVA_HOME=/usr/lib/jvm/java-1.5.0-sun-1.5.0.15
Apachesolr Config
The only thing left to do is point the apachsolr module to the right location. Those settings can be found under admin/settings/apachesolr. Change the port to 8080 and you should be all set.
- mikejoconnor's blog
- Login or register to post comments
