My multicore Solr on Ubuntu 10.04 has proven to be one of my most popular posts yet. Â Seeing the success of that post I decided it was time to show how to get the latest version of Solr up and running on Ubuntu 10.04. Â As of this writing the latest version of Solr is 3.4.0.
Before we get started you should read and follow my previous post because I borrow all of the config settings from Ubuntu’s Solr 1.4 packages. Â The default config settings from the Ubuntu maintainers is still a decent starting point with Solr 3.4. Â Once finished you can safely remove the old Solr 1.4 package if you want to.
With a working Solr 1.4 installation in place, we can get started on getting Solr 3.4 running. Â You can change some of the following paths if you want, just remember to change them in all of the appropriate places. Â Everything you’re about to see should be done as the root user.
Create some required paths
mkdir /usr/local/share/solr3 mkdir /usr/local/etc/solr3 mkdir -p /usr/local/lib/solr3/data
Next, re-own the data dir to the proper user
chown -R tomcat6.tomcat6 /usr/local/lib/solr3/data
Download the latest version of Solr
You can get the latest version of Solr fromÂ http://lucene.apache.org/solr/Â and extract the files into root’s home directory.
wget http://mirrors.axint.net/apache//lucene/solr/<version>/apache-solr-<version>.tgz tar zxvf apache-solr-<version>tgz
Extract the war Solr war file
Extract the Solr war file into a location. Â You may need to install the unzip utility with apt-get install unzip.
Install additional libs
There are a few other libs included with the Solr distribution. Â You can install anything else you need, I specifically need to have the dataimporthandler add ons.
cp /root/apache-solr-3.4.0/dist/apache-solr-dataimporthandler-* WEB-INF/lib/
If you want to have multicore enabled you’ll need to perform the following actions. Â The rest of this post assumes you have copied this file and will require you to make some changes to support multicore. Â I’ve marked steps that can be skipped if you also wish to skip the multicore functionality.
Copy in the multicore config file:
cp /root/apache-solr-3.4.0/example/multicore/solr.xml .
You should now edit the solr.xml file at this point, doing the following:
- Set persistent to true
- Remove entries for core0 and core1
Next, change the ownership and permissions so that tomcat is able to modify this file when needed
chown tomcat6.tomcat6 /usr/local/share/solr3 chown tomcat6.tomcat6 /usr/local/share/solr3/solr.xml
Copy existing config files
This is where we’re going to borrow some files from Ubuntu’s Solr package maintainer.
cd /usr/local/etc/solr3 cp -av /etc/solr/* .
Because we simply copied the config files we need to modify them to fit our new environment. Â Change the following in the solr-tomcat.xml file:
- Change docBase to /usr/local/share/solr3
- Change Environment value to /usr/local/share/solr3
Also edit tomcat.policy file changing:
- Modify all entries referencing solr to point to appropriate /usr/local location
Change the following in conf/solrconfig.xml:
- Change <dataDir> to /usr/local/lib/solr3/data
If you are using multicore and you followed the Solr 1.4 multicore post you’ll have a conftemplate directory and you’ll need make changes to conftemplate/solrconfig.xml
- Change <dataDir> to /usr/local/lib/solr3/data/CORENAME
Here we’ll create some symlinks to support the way Ubuntu packages Solr. Â This is necessary because we copied Ubuntu’s config files and those files reference a few locations. Â Creating the symlinks also allows us to continue using the scripts created in the previous post with minimal modifications.
- cd /usr/local/share/solr3
- ln -s /usr/local/etc/solr3/conf
- ln -s /usr/local/etc/solr3/ /etc/solr3
- ln -s /usr/local/lib/solr3 /var/lib/solr3
Enable/Start the new Solr instance
We can now enable our new Solr 3.4 instance in tomcat by doing the following:
cd /etc/tomcat6/Catalina/localhost ln -s /usr/local/etc/solr3/solr-tomcat.xml solr3.xml
Note that the name of the symlink is important as it will define where we find this instance (/solr vs /solr3). Â At this point you can create a new core. Â I’ve provided the updated scripts here.