Installing Apache Solr 4.7 multicore on Ubuntu 12.04 and Tomcat7

ApacheSolr

Tags:

Case type:

Service area: 

Overview

I will show you how to install the ApacheSolr search engine under Tomcat7 servlet container on Ubuntu 12.04.4 LTS (Precise Pangolin) to be used later with Drupal 7. In this writeup I'm gonna discuss only the installation and setup of the ApacheSolr server. Specific Drupal configuration and/or Drupal side configuration to be discussed in future writeup.

Tomcat7

We’re installing Oracle Java 7 before installing Tomcat7:

$ sudo apt-get purge oracle-java6-installer
$ sudo apt-get install software-properties-common python-software-properties
$ sudo add-apt-repository ppa:webupd8team/java
$ sudo apt-get update
$ sudo apt-get install oracle-java7-installer

Then get Tomcat7:

$ sudo apt-get install tomcat7 tomcat7-admin

Solr 4.7

$ cd ~
$ curl http://www.eu.apache.org/dist/lucene/solr/4.7.0/solr-4.7.0.tgz > solr-4.7.0.tgz
$ tar xzvf solr-4.7.0.tgz
$ sudo mv solr-4.7.0 /usr/share/solr
$ cd /usr/share/solr/example
$ sudo cp webapps/solr.war multicore/solr.war
$ cd /usr/share
$ sudo cp -r solr/example/lib/ext/* tomcat7/lib/
$ sudo cp -r solr/example/resources/log4j.properties tomcat7/lib/

Configure

Edit log4j.properties and set the solr.log setting:

$ sudo nano /usr/share/tomcat7/lib/log4j.properties

Set there solr.log=/usr/share/solr.

Now, let’s a get Solr into Tomcat Catalina config. Create a new solr.xml file:

$ sudo nano /etc/tomcat7/Catalina/localhost/solr.xml

and add

<Context docBase="/usr/share/solr/example/multicore/solr.war" debug="0" crossContext="true">
  <Environment name="solr/home" type="java.lang.String" value="/usr/share/solr/example/multicore" override="true" />
</Context>

Add Tomcat GUI administrative users:

$ sudo nano /etc/tomcat7/tomcat-users.xml

Add the tomcat user within the block:

<tomcat-users>
  <role rolename="manager-gui"/>
  <user username="admin" password="mysecretpassword" roles="manager-gui"/>
</tomcat-users>

Ensure correct permissions:

$ sudo chown -R tomcat7 /usr/share/solr/example/multicore

Restart Tomcat:

$ sudo service tomcat7 restart

Testing

You are able now to access the Solr administrative interface at http://localhost:8080/solr.

Apache Solr services, corresponding to each configured core are delivered at:

  • http://localhost:8080/solr/core0
  • http://localhost:8080/solr/core1

Security

Place the next line inside <Context> in /etc/tomcat7/Catalina/localhost/solr.xml:

<Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="127.0.0.1|86.120.24.124" />

You're done. Now it's time to configure Solr and you application that use it. About that in another writeup.