How to Install Solr in Tomcat?

房东的猫 提交于 2019-11-29 00:11:45

Install Solr in Tomcat

Pre Requirements

1 – Machine with Windows OS (Windows 7,8,Xp.. ..etc)

2 – Java 6 or Above

3 - Solr 4.0.0 or Above

4 – Apache-tomcat 6 or Above.

Steps to get Solr up on Tomcat Server

1.Install Tomcat on your machine and make sure it is ready to start.(Check using localhost:8080)

2.Install Solr4.0 distribution package apache-solr-4.0.0.zip and unzip it in your local directory like C:\apache-solr-4.0.0.

3.Make a folder with name solr-home in your local machine like C:\solr_home.

4.Go back to the solr distribution package that you downloaded C:\apache-solr-4.0.0. Have a peek inside the Examples/solr ("C:\solr-4.4.0\example\solr") folder. Copy all those files into the C:\solr_home folder.(server shutting down exception will come)

5.Look into C:\solr-home\solr and you will see two folders with name collection1 and bin, copy these two folders a step up to C:\solr_home.(if lib not copy "severe error filterstart" Exception come)

6.Copy lib from C:\apache-solr-4.0.0\example\lib\ext SLF4J and log4j.jar file to Tomcat Lib folder C:\Program Files\Apache Software Foundation\Tomcat 6.0\lib (https://wiki.apache.org/solr/SolrLogging#Using_the_example_logging_setup_in_containers_other_than_Jetty)

7.Copy apache-solr-4.0.war (rename to solr.war) from "C:\solr-4.4.0\dist" directory to webapps directory inside Tomcat.(C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps)

8.If tomact is already start then solr folder will create go to "C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\solr\WEB-INF\web.xml" edit web.xml uncomment entry and edit like following(Exception SolrCore 'collection1' is not available due to init failure)

<env-entry>
   <env-entry-name>solr/home</env-entry-name>
   <env-entry-value>C:\solr_home\solr</env-entry-value>
   <env-entry-type>java.lang.String</env-entry-type>
</env-entry>

9.Start Tomcat and check localhost:8080/solr dashBoard will come

Flo

It got solved for me by on a different forum, here are the steps I followed:

  1. Extract solr431 package. In my case I did in "E:\solr-4.3.1\example\solr"
  2. Now copied solr dir from extracted package (E:\solr-4.3.1\example\solr) into TOMCAT_HOME dir. In my case TOMCAT_HOME dir is pointed to E:\Apache\Tomcat 6.0.
  3. I can refer now SOLR_HOME as " E:\Apache\Tomcat 6.0\solr" (please remember this)
  4. Copy the solr.war file from extracted package to SOLR HOME dir i.e E:\Apache\Tomcat 6.0\solr. This is required to create the context. As I donot want to pass this as JAVA OPTS
  5. Also copy solr.war file into TOMCAT_HOME\webapps for deployment purpose
  6. If you start tomcat you will get errors as mentioned by Shawn. S0 you need to copy all the 5 jar files from solr extracted package ( E:\solr-4.3.1\example\lib\ext ) to TOMCAT_HOME\lib dir:

    1. jul-to-slf4j-1.6.6,
    2. jcl-over-slf4j-1.6.6,
    3. slf4j-log4j12-1.6.6,
    4. slf4j-api-1.6.6,
    5. log4j-1.2.16
  7. Also copy the log4js.properties file from E:\solr-4.3.1\example\resources dir to TOMCAT_HOME\lib dir.

  8. Now if you start the tomcat you wont having any problem.

The way that logging works with Solr was updated with Solr 4.3.0 (and higher). If you check your Tomcat logs you will most likely see a "Filter Exception" error. Please refer to the Solr Logging - Using the example logging setup in containers other than Jetty for the steps required to get Solr 4.3.0 and higher to run on Tomcat.

According to my notes (I did that procedure some time ago), I had to add an extra line in the Tomcat "caralina.sh" (or catalina.bat if you use windows):

export JAVA_OPTS="$JAVA_OPTS -Dsolr.solr.home=/opt/solr/example/solr"

This is used to specify where the solr "configuration" and "data" directories (where your data will be stored). In my case it is "/opt/solr/example/solr", but you need to use the directory where you have the "configuration" files and "data" directory in your system. For example you should use "C:\solr-4.3.1\examples\solr\" if you extracted the downloaded Solr package in C: in windows. This means, that you will deploy the "Solr.war" in Tomcat (you already did that), but the configuration of Solr and "data" stored will be in that directory you specify in catalina.bat (JAVA_OPS, e.g.: C:\solr-4.3.1\examples\solr).


Good instructions to install Solr in a Tomcat in windows: http://liuweipingblog.cn/java/install-lucene-solar-with-tomcat-on-windows/

This error is occurred due to the separate logging mechanism of solr. After researching I have found that, you need to add slf4j log jar in your tomcat lib. ( as per my local machine it is : C:\xampp\tomcat\lib )

download from below url and copy the jar file in tomcat lib

http://www.slf4j.org/download.html

After doing the above step it is working fine in my local system.

The errors about the lucene version indicate that you are still deploying the 3.5 version. I mean, I'm sure you put the 4.x war but for somewhat reason (forgot to delete the war, tmp files) the 3.5 is still there. When you indicates the solr.home using a system property it will be read by "all" solr you are deploying. So in your case, the 4.3.1 is happy about the given solr home (which contains LUCENE43) but the 3.5 throws the exception (4.3 is unknown to 3.5)

It includes few steps

  1. Download solr-XXX.zip and extract into solr-XXX.

  2. Copy solr-XXX.war (from solr-XXX/dist folder after unzipping the .zip) into Tomcat/webapps. Then unzip the .war file (using WinZip etc.). This will create folder solr-XXX. Copy log4j-XXX.jar,slf4j-api-XXX.jar,slf4j-log4j12-XXX.jar,commons-logging-XXX.jar into Tomcat/webapps/solr-XXX/WEB-INF/lib. And create a folder Tomcat/webapps/solr-XXX/WEB-INF/classes and copy log4j.properties here from solr-XXX\example\resources

  3. Create a directory MySolrHome anywhere and copy content of solr-XXX\example\solr folder here

  4. Add JAVA_OPTS=-Dsolr.solr.home=Path/to/MySolrHome/

Start Tomcat

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!