Deploy Apache Solr 3.5 in Ubuntu 10.04

1. Background

Solr is an enterprise search platform from the Apache Lucene project. Its major features include powerful full-text search, hit highlighting, faceted search, dynamic clustering, database integration, rich document handling, and geospatial search.

— Wiki Apache Solr

The feature that I prefer is the full-text search. So let’s begin.

2. Requirement

  • Java 1.6 or greater
  • Tomcat6 or greater ( the servlet is not mandatory to tomcat, you can use any server as you want such as the jetty server included in the zip file what you have just downloaded, but if you want use tomcat, you have to consider the version )

3. Download Solr 3.5

Download Solr 3.5 from apache website. There are a lot of way to get the newest solr.

After downloaded the zip, unzip it in your folder.

The key files that we will use are in the /dist and example.

4. Deploy Solr 3.5

4.1 Copy the file apache-solr-3.5.0.war in apache-solr-3.5.0\dist into /var/lib/tomcat6/webapps, (war file is Web application archive). Here I rename it to solr.war, but it is not mandatory! This file provides web components.

4.2 Take the folder solr/ in apache-solr-3.5.0/example, copy it to /var/lib/tomcat6. This folder will be considered as the solr home folder.

4.3 Add a config file called solr.xml in /etc/tomcat6/Catalina/localhost

<Context docBase=”/var/lib/tomcat6/webapps/solr.war” debug=”0″ reloadable=”true” >
<Environment name=”solr/home” type=”java.lang.String” value=”/var/lib/tomcat6/solr” override=”true” />
</Context>

The docBase will direct to the war file and value will direct to the folder which we have just copied.

4.4 Important, the most file that you will touch will be the solrconfig.xml, in the folder /var/lib/tomcat6/solr/conf.

At this moment, we need just touch one line : <dataDir>${solr.data.dir:}</dataDir>

By default, it will save the output data to the directory each time you use your solr, but I prefer to save them into a folder, so I do:

       <dataDir>${solr.data.dir:/solr/data}</dataDir>

A little further, for avoiding the error, we can have the modification like this:

<lockType>native</lockType> to <lockType>simple</lockType> <unlockOnStartup>false</unlockOnStartup> to <unlockOnStartup>true</unlockOnStartup>

<queryResponseWriter name=”velocity” enable=”${solr.velocity.enabled:true}”/> to <queryResponseWriter name=”velocity” enable=”${solr.velocity.enabled:false}”/>

I will give more details about this error in the next blog.

4.5 Optional, if you use another language than english, it is better to take a look at the file server.xml in /var/lib/tomcat6/conf.

Make sure you have the line : URIEncoding=”UTF-8″

4.6 The last, don’t forget to restart your tomcat6

And type localhost:8080/solr/admin, you will find it:

Advertisements

2 comments on “Deploy Apache Solr 3.5 in Ubuntu 10.04

  1. To check the version of Java and the status of Tomcat6 with command line :

    For java :
    # java -version
    => OpenJDK Runtime Environment (IcedTea6 1.11.3) (6b24-1.11.3-1ubuntu0.10.04.1)
    OpenJDK Client VM (build 20.0-b12, mixed mode, sharing)

    For Tomcat6 :
    # service tomcat6 status
    => * Tomcat servlet engine is running with pid *****

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