Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run Solr 4 in Tomcat locally?

I've been trying to set up Solr 4.3 on my home PC (in Tomcat 7) but it doesn't run. I have set up Tomcat and deployed the solr.war file which both unpacks and shows up in the Tomcat Web Apps Manager screen in Tomcat but its not running and clicking the start button doesn't do anything (as it should already be running in the first place).

Here is my solr.xml context file in Tomcat which also gives the path to the solr.war file and where my solr Cores are (which is the default Collection1):

<Context path="/solr" docBase="C:/LocalApps/Tomcat/apache-tomcat-7.0.40/webapps/solr.war" debug="0" crossContext="true">
<Environment name="solr/home" type="java.lang.String" value="C:/LocalApps/Solr/solr-4.3.0/example/solr/" override="true"/>
</Context>

this is the error log in tomcat:

INFO: Starting Servlet Engine: Apache Tomcat/7.0.40
Jun 09, 2013 11:04:07 PM org.apache.catalina.startup.HostConfig deployDescriptor
INFO: Deploying configuration descriptor C:\LocalApps\Tomcat\apache-tomcat-7.0.40\conf\Catalina\localhost\solr.xml
Jun 09, 2013 11:04:07 PM org.apache.catalina.startup.HostConfig deployDescriptor
WARNING: A docBase C:\LocalApps\Tomcat\apache-tomcat-7.0.40\webapps\solr.war inside the host appBase has been specified, and will be ignored
Jun 09, 2013 11:04:07 PM org.apache.catalina.startup.SetContextPropertiesRule begin
WARNING: [SetContextPropertiesRule]{Context} Setting property 'debug' to '0' did not find a matching property.
Jun 09, 2013 11:04:09 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Error filterStart
Jun 09, 2013 11:04:09 PM org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/solr] startup failed due to previous errors
like image 383
jsnoob Avatar asked Jun 10 '13 03:06

jsnoob


People also ask

How do I run Solr locally?

If you didn't start Solr after installing it, you can start it by running bin/solr from the Solr directory. If you are running Windows, you can start Solr by running bin\solr. cmd instead. This will start Solr in the background, listening on port 8983.

Does Apache Solr use Tomcat?

For production environment, we would want Solr to run as a part of a more convenient setup involving a more reliable web server. Solr can be configured to run on any J2EE container such as IBM Websphere or JBoss or any other server. Apache Tomcat is the most commonly used server.


2 Answers

You need to install the jars for logging as explained here.

Just copy all the mentioned files into your tomcat/lib dir. And restart Tomcat.

  1. Copy the jars from solr/example/lib/ext into your container's main lib directory. These jars will set up SLF4J and log4j. Exactly where this lib directory is highly variable. For a Debian or Ubuntu server using the Tomcat package available from the OS vendor, this is likely to be /usr/share/tomcat6/lib or /usr/share/tomcat7/lib.
  2. Copy the logging config from solr/example/resources/log4j.properties into a location on the classpath. Usually you can use the same location as the jar files above. Edit the configuration file for your preferred log destination.
  3. Optionally, if you did not place log4j.properties on the classpath, set java option -Dlog4j.configuration=file:///path/to/log4j.properties
like image 195
Okke Klein Avatar answered Sep 20 '22 13:09

Okke Klein


  1. Download latest solr-4.x.zip file.
  2. Extract zip file somewhere like C:\solr setup.
  3. Apache Tomcat (version greater than 5) and Java 6 or greater should be installed. Copy solr-4.x.war file from “C:\solr setup\solr-4.3.0\dist” to “Apache Tomcat” webapps folder most probably in C:\Program Files\Apache...\Tomcat...\webapps\ and rename copied war file to some meaningful name like solrTest.Start Tomcat. If already running then restart Tomcat. New folder with same name as of war file (solrTest) will be created.
  4. Stop Tomcat. Copy bin and collection1 folders from C:\solr setup\solr-4.x\example\solr to C:\Program Files\Apache ...\Tomcat...\webapps\solrTest.
  5. Copy all jars from C:\solr setup\solr-4.x\example\lib\ext to C:\Program Files\Apache...\Tomcat...\lib. SOLR 4.x will use these jars for logging.
  6. Create xml file in C:\Program Files\Apache...\Tomcat...\conf\Catalina\localhost\ with same name as of war file (solrTest.xml) with contents as given below. Tomcat looks for this xml file to get a start of the application.
  7. Update C:\Program Files\Apache...\Tomcat...\webapps\solrTest\collection1\conf\schema.xml and add required fields and update too.
  8. Remove copy fields if not required. Usage of copy fields is available in same file.
  9. Update C:\Program Files\Apache...\Tomcat...\webapps\solrTest\collection1\conf\solrconfig.xml. Update physical index path in tag like ${solr.data.dir:C:/Indexes/solrTest Index/}. If it will be commented then C:\Program Files\Apache...\Tomcat...\webapps\solrTest\collection1\data\ directory will be used by default. DataDir tag is available in file. No need to add your own.
  10. Update replication entries to set either master or slave in replication request handler.
  11. Try accessing “...localhost:portNumber/solrTest”. If no error comes then you have successfully configured SOLR 4.x.
like image 44
user2715709 Avatar answered Sep 22 '22 13:09

user2715709