Wednesday, March 14, 2012

Setting up a Apache multi-site SOLR on Tomcat & Windows (localhost)

In the Drupal world, it is very common to find SOLR deployments on Ubuntu or Debian. I have also seen comments that SOLR needs only one of the above Operating Systems for deployment.


In this blog we will see how to deploy SOLR on our Windows local host and have Drupal communicate with it.

Step 1 : Set up the Java Runtime Environment to install Tomcat on.
  • Tomcat is a java application server. And so it needs a Java Runtime Environment to be deployed on. That environment is provided by the Java Runtime Envieonment, commonly called as the JRE.
  • A Java Runtime Environment is directly installed on the operating system, just as any other application is installed on the operating system. Since, our focus is to deploy Tomcat on localhost, we will not be discussing other deployment options of the JRE such as on the remote server.
  • We can download the JRE for our OS on this site http://docs.oracle.com/javase/7/docs/webnotes/install/index.html with all the instructions and Installation Guides. 
    • We will not need the JDK, which is required only if we plan to do any Java Development. 
    • The JDK also contains the JRE. So if you wish to do any Java development also, then download the JDK only. Now you will not need the JRE separately.
  • We will now set up the environment variables of your system. Environment variables of your operating system tells the OS where to find the JRE and its files. This is set on the JAVA_HOME variable of your OS.
  • To set this up, go to 'My Computer', Right Click > Properties > Advanced System Settings > Advanced TAB . Environment Variables. Here you will see USER VARIABLES and the SYSTEM VARIABLES.
  • Under System Variables, you will need to create a NEW VARIABLE called "JAVA_HOME" and type the path of your JRE as its value.

Step 2 : Tomcat Installation on Windows.
  • That is it like our Apache web server, except that it only serves Java Server Applications. And Tomcat is a Java Application also.
  • Apache Tomcat is an open source software implementation of the Java Servlet and JavaServer Pages technologies. Basically it is an Application Server for hosting Java Applications. 
  • Apache Tomcast is required for installing SOLR on it. 
  • Since Tomcat is a java application server, it can be deployed on any operating system, Windows and Mac.All it needs to run on OS is the OS specific runtime libaries provided by the JRE that we covered in step-1 above.
  • Download  Tomcat for window from the apache.org website. [http://tomcat.apache.org/download-70.cgi]
  • It ill be easier if you download the installer version. It will provide links on your desktop to stop / start the tomcat server
  • If you installed a .tar.gz or a .zip file, you will need to navigate to /tomcat/bin/ folder to find the scripts to start/stop the tomcat server. You can also install it as a windows service and manage it's administration from there. And now if you go to local-host:8080 on your browser, you will see the tomcat home page served from your local host.
Step 2 : SOLR Installation on Tomcat.
  •  Tomcat is a servlet container for Java Servlets... SOLR is a servlet. So installing SOLR is only about knowing how to deploy a servlet on Tomcat. A simple search on youtube will provide umpteen video guides.
Step 3 : Telling SOLR about your Drupal Installation
  • SOLR also needs to know what application or data it is indexing. This is pretty simple. All instructions are there in the README file that comes with the APACHESOLR MODULE. The file, , that needs to be copied from the folder (of the apache solr module) and pasted to the folder in the SOLR installation. This file provides all the information the SOLR needs to know to know which application and which data to index and where to find it. Based on this information, the SOLR servlet accesses and indexes all the relevant data. 
  • we could set up the rules for SOLR to specify which tables and what fields (what content types and what content fields in Drupal lingo) to index. One could even setup content biases in the Apache SOLR configuration. This means that letting SOLR know which fields to give more weightage to in search results. This way the results of a multiple field search would put more emphasis on fields that have a greater bias.
Step 4 : Telling Drupal where to transfer the SEARCH request to
  • Just as the SOLR install needs to know which Drupal database, data and application it needs to index, even Drupal needs to know where to forward the Search request. This means, the Drupal installation needs to have the URL of the SOLR deployment. This is part of the configuration of the apacheSOLR module.
References =
  1. http://css.dzone.com/print/51463 
  2. http://wiki.apache.org/solr/
  3. http://2011.drupalcampatlanta.com/program/session-video/index.html 

No comments:

Post a Comment