How to Install Solr on Ubuntu 12.04

Solr  is the popular, blazing fast open source enterprise search platform from the Apache Lucene project. Solr is written in Java and runs as a standalone full-text search server within a servlet container such as Tomcat. Solr uses the Lucene Java search library at its core for full-text indexing and search, and has REST-like HTTP/XML and JSON APIs that make it easy to use from virtually any programming language.

Solr  Features

Solr is a standalone enterprise search server with a REST-like API. You put documents in it (called "indexing") via XML, JSON, CSV or binary over HTTP. You query it via HTTP GET and receive XML, JSON, CSV or binary results.

  •     Advanced Full-Text Search Capabilities
  •     Optimized for High Volume Web Traffic
  •     Standards Based Open Interfaces - XML, JSON and HTTP
  •     Comprehensive HTML Administration Interfaces
  •     Server statistics exposed over JMX for monitoring
  •     Linearly scalable, auto index replication, auto failover and recovery
  •     Near Real-time indexing
  •     Flexible and Adaptable with XML configuration
  •     Extensible Plugin Architecture
Solr Installation :-

Apacha Solr requires Tomcat, so the first step, install the Tomcat server:
apt-get install tomcat6



want to get Solr and extract it to a temporary directory:
mkdir -p ~/tmp/solr/
cd ~/tmp/solr/
wget http://apache.ziply.com/lucene/solr/3.6.0/apache-solr-3.6.0.tgz
tar xzvf apache-solr-3.6.0.tgz

All the solr cores and indexes will go in /var/solr:
mkdir -p /var/solr

Copy the Solr webapp and the example multicore configuration files:
cp apache-solr-3.6.0/dist/apache-solr-3.6.0.war /var/solr/solr.war
cp -R apache-solr-3.6.0/example/multicore/* /var/solr/
chown -R tomcat6 /var/solr/

Need to point Catalina at Solr:

echo -e '<Context docBase="/var/solr/solr.war" debug="0"

privileged="true" allowLinking="true" crossContext="true">\n<Environment

name="solr/home" type="java.lang.String" value="/var/solr"

override="true" />\n</Context>' | sudo tee -a  /etc/tomcat6/Catalina/localhost/solr.xml



echo 'TOMCAT6_SECURITY=no' | sudo tee -a /etc/default/tomcat6

Change near the top of the file other environment vars are set up:
JAVA_OPTS="$JAVA_OPTS -Dsolr.home=/var/solr"

Restart Tomcat6 and :
/etc/init.d/tomcat6 restart 

Open to http://localhost:8080/solr/ – you should see it up and running. 

 


 
 
 
 
 
Thanks,
Vishal Vyas 

5 comments:

  1. Hi, thanks for this tutorial. I am using the new version of of Solr which is 4.2.1 and I followed the steps above. At first run using http://loclahost:8080/solr/ I got an error message about core, it says that something is wrong with the solrconfig.xml (can't remember the message cause I can't reproduce it anymore). And then I tried to repeat the step "..point Catalina at Solr" cause I thought I didn't followed that correctly, and now when I run my localhost:8080/solr I got the message "HTTP 404".

    ReplyDelete
  2. Hi, great tutorial, you mention this:
    Change near the top of the file other environment vars are set up:
    JAVA_OPTS="$JAVA_OPTS -Dsolr.home=/var/solr"
    But don't say what file? Is it solr.xml?

    ReplyDelete
  3. Hi Vishal,

    its a good tutorial got to learn solr from the above tutorial.
    Can you please provide instructions to install lucene on ubuntu 12.04.

    Regards,
    Vijay

    ReplyDelete
  4. Nice share Linux guru :)

    Thanks,
    Martin Leonis

    ReplyDelete