Installation Guide to Set Up Solr 4 With Apache Tomcat On Windows
This is a short guide on how to set up Apache Solr on Windows 7 running on Apache Tomcat. Be aware that Solr-4.3.0 and Apache-tomcat-7.0.40. Older versions of Solr use different folder structure and therefore this guide will not adequately cover its requirements.
If you wish to have a fully functioning file or web crawler using Nutch that Indexes to Solr then follow the next steps of the guide at:
http://amac4.blogspot.co.uk/2013/07/setting-up-tika-extracting-request.html
http://amac4.blogspot.co.uk/2013/07/configuring-nutch-to-crawl-urls.html
http://amac4.blogspot.co.uk/2013/07/setting-up-nutch-to-crawl-filesystem.html
http://amac4.blogspot.co.uk/2013/07/web-service-to-query-solr-rest.html
This is a short guide on how to set up Apache Solr on Windows 7 running on Apache Tomcat. Be aware that Solr-4.3.0 and Apache-tomcat-7.0.40. Older versions of Solr use different folder structure and therefore this guide will not adequately cover its requirements.
If you wish to have a fully functioning file or web crawler using Nutch that Indexes to Solr then follow the next steps of the guide at:
http://amac4.blogspot.co.uk/2013/07/setting-up-tika-extracting-request.html
http://amac4.blogspot.co.uk/2013/07/configuring-nutch-to-crawl-urls.html
http://amac4.blogspot.co.uk/2013/07/setting-up-nutch-to-crawl-filesystem.html
http://amac4.blogspot.co.uk/2013/07/web-service-to-query-solr-rest.html
http://amac4.blogspot.co.uk/2013/07/setting-up-tika-extracting-request.html
http://amac4.blogspot.co.uk/2013/07/configuring-nutch-to-crawl-urls.html
http://amac4.blogspot.co.uk/2013/07/setting-up-nutch-to-crawl-filesystem.html
http://amac4.blogspot.co.uk/2013/07/web-service-to-query-solr-rest.html
Preparation
First of all we need an Apache Tomcat servlet container. It can be found at the Apache Tomcat website:Apache Website Any version beyond 7.0.0 is considered stable with sufficient support and documentation available. Please Download Tomcat & Solr in preparation to starting this guide. You will also require the Java Runtime Environment to be downloaded and set up. Its location will be referred to as $JAVA.
-
Solr 4.3.0
- Tomcat 7 or Tomcat 8
- Cygwin
- JRE 7
First of all we need an Apache Tomcat servlet container. It can be found at the Apache Tomcat website:Apache Website Any version beyond 7.0.0 is considered stable with sufficient support and documentation available. Please Download Tomcat & Solr in preparation to starting this guide. You will also require the Java Runtime Environment to be downloaded and set up. Its location will be referred to as $JAVA.
- Solr 4.3.0
- Tomcat 7 or Tomcat 8
- Cygwin
- JRE 7
Set-up
-
Firstly, choose the location you wish to install Tomcat and copy the files from your downloads to your chosen directory. This will be referred to as
$TOMCAT_HOME. Do the same for your Solr download, copy the files to your chosen location and this will be referred to as which will be referred to as $SOLR.
-
Edit the
server.xml file in $TOMCAT_HOME/conf to look like the following code snippet:
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
URIEncoding="UTF-8" />
-
Now copy the
[$SOLR]/example/solr directory somewhere else and rename it solr_home. This will be your main Solr installation to run your Solr server and will be referred to as $SOLR_HOME.
-
The next thing is setting up the Solr deployment. To do that we need the
apache-solr-4.0.0.war (found in $SOLR/example/webapps) file that contains the necessary files and libraries to run Solr to be copied to the $TOMCAT_HOME/webapps directory and renamed solr.war.
-
Create a proper context file by creating a
solr.xml file in the $TOMCAT_HOME/conf/Catalina/localhost directory. If the Catalina/localhost/ directory does not exist then you will need to make it yourself. The contents of the file should look like the following code:
<Context docBase="/solr.war"debug="0" crossContext="true">
<Environment name="solr/home" type="java.lang.String" value="$SOLR_HOME" override="true"/>
</Context>
-
Modify
solr_home/collection1/conf/solrconfig.xml to set the absolute directory:
<lib dir="$SOLR/contrib/extraction/lib" regex=".*\.jar" />
-
Also set the data directory like:
<dataDir>${solr.data.dir:$SOLR_HOME/data}</dataDir>
-
Now we can start the servlet container. Navigate to the
$TOMCAT_HOME/bin and double click: startup.bat. Using command prompt:
cd $TOMCAT_HOME/bin
startup.bat run
- Copy the jar files from
$SOLR\example\lib\ext into the $TOMCAT_HOME/lib folder and also copy the $SOLR/example/solr/example/resources/log4j.properties into the same location.
- Runtimes may need to be set in the
startup.bat file. Add set JAVA_HOME=$JAVA or equivalent location to the second line of the file catalina.bat if it fails to run.
-
Your Solr server is now running and to ensure that Solr is running properly, you can open a browser and navigate to:http://localhost:8080/solr/. The Solr administration screen should appear and there are a variety of options to choose from.
- Firstly, choose the location you wish to install Tomcat and copy the files from your downloads to your chosen directory. This will be referred to as
$TOMCAT_HOME. Do the same for your Solr download, copy the files to your chosen location and this will be referred to as which will be referred to as$SOLR.
- Edit the
server.xmlfile in$TOMCAT_HOME/confto look like the following code snippet:
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
URIEncoding="UTF-8" />
- Now copy the
[$SOLR]/example/solrdirectory somewhere else and rename itsolr_home. This will be your main Solr installation to run your Solr server and will be referred to as $SOLR_HOME.
- The next thing is setting up the Solr deployment. To do that we need the
apache-solr-4.0.0.war(found in$SOLR/example/webapps) file that contains the necessary files and libraries to run Solr to be copied to the $TOMCAT_HOME/webapps directory and renamedsolr.war.
- Create a proper context file by creating a
solr.xmlfile in the$TOMCAT_HOME/conf/Catalina/localhostdirectory. If theCatalina/localhost/directory does not exist then you will need to make it yourself. The contents of the file should look like the following code:
<Context docBase="/solr.war"debug="0" crossContext="true">
<Environment name="solr/home" type="java.lang.String" value="$SOLR_HOME" override="true"/>
</Context>
- Modify
solr_home/collection1/conf/solrconfig.xmlto set the absolute directory:
<lib dir="$SOLR/contrib/extraction/lib" regex=".*\.jar" />
- Also set the data directory like:
<dataDir>${solr.data.dir:$SOLR_HOME/data}</dataDir>
- Now we can start the servlet container. Navigate to the
$TOMCAT_HOME/binand double click:startup.bat. Using command prompt:
cd $TOMCAT_HOME/bin
startup.bat run
- Copy the jar files from
$SOLR\example\lib\extinto the$TOMCAT_HOME/libfolder and also copy the$SOLR/example/solr/example/resources/log4j.propertiesinto the same location. - Runtimes may need to be set in the
startup.batfile. Addset JAVA_HOME=$JAVAor equivalent location to the second line of the filecatalina.batif it fails to run.
- Your Solr server is now running and to ensure that Solr is running properly, you can open a browser and navigate to:http://localhost:8080/solr/. The Solr administration screen should appear and there are a variety of options to choose from.
Next Steps
The next step is to ensure that Tika's extracting request handler is configured correctly so that it can deal with pdf, doc, xls etc files:
http://amac4.blogspot.co.uk/2013/07/setting-up-tika-extracting-request.html
You will also want to set-up de-duplication and potentially Solr's Highlighting functionality:http://amac4.blogspot.co.uk/2013/08/setting-up-highlighting-for-solr-4.htmlhttp://amac4.blogspot.co.uk/2013/08/solr-deduplication.html
Tomcat Options
When running Tomcat you have various options which are availible to you here:
-
stop: This stops Apache Tomcat
-
restart: This restarts Apache Tomcat
-
debug: This start Apache Tomcat in debug mode
-
run: This runs Apache Tomcat in the current window, so you can see the output on the console from which you run Tomcat.
- stop: This stops Apache Tomcat
- restart: This restarts Apache Tomcat
- debug: This start Apache Tomcat in debug mode
- run: This runs Apache Tomcat in the current window, so you can see the output on the console from which you run Tomcat.