How to install Solr+Tomcat

  
in Windows7

Solr installation configuration under Tomcat

Since Solr is based on Java development, Solr can be deployed in both Windows and Linux, but because Solr provides some for testing and management. It is more convenient to maintain the shell script, so it is recommended to install it on Linux during production deployment, and it can be used in windows during testing.

Solr is a Lucene-based Java search engine server. Solr provides level search, hits eye-catching displays, and supports multiple output formats (including XML/XSLT and JSON formats). It is easy to install and configure, and comes with an HTTP-based management interface. The index created by Solr is fully compatible with the Lucene search engine library. By properly configuring Solr, in some cases it may be necessary to code, and Solr can read and use indexes built into other Lucene applications. In addition, many Lucene tools (such as Nutch, Luke) can also use the index created by Solr.

Installation Environment

Windows 7 64bit

Apache-tomcat-8.0.9-windows-x64

Solr-4.9.0

JDK 1.8.0_05 64bit

Installation Steps

The installation of Tomcat and JDk is skipped here.

Note: Solr4.9 requires jdk1.7+

Step 1:

Unzip solr-4.9.0 to any folder, I extract to D:Installed Applicationssolr- 4.9.0solr-4.9.0 directory.

Step 2:

Copy solr-4.9.0dist solr-4.9.0.war to the Tomcat webapp/directory, preferably renamed to solr.war.

Step 3:

Starting Tomcat will give you an error. This step is only for decompressing solr-4.9.0.war, so it is also possible to manually unzip it in the webapp directory.

Step four:

Method one:

Open webappssolrWEB-INFweb.xml

Find:

Here is the need to configure solr/Home, only need to modify /put/your/solr/home/here

This directory can be customized, it is recommended to use the step one decompressed directory, here you need to pay attention: in the Soltorial official website Tutorial has the following paragraph Words:

How Solr Works with Tomcat

The two basic steps for running Solr in any Web application container are as follows:

Make the Solr classes available to the container. In many cases, the Solr Web application archive (WAR) file can be placed into a special directory of the application container. In the case of Tomcat, you need to place the Solr WAR file in Tomcats webapps directory. If you installed Tomcat with Solr , take a look in tomcat/webapps:youll see the solr.war file is already there.

Point Solr to the Solr home directory that contains conf/solrconfig.xml and conf/schema.xml. There are a few ways to get this done. One of the best is to define the solr.solr.home Java system property. With Tomcat, the best way to do this is via a shell environment variable, JAVA_OPTS. Tomcat puts the value of This variable on the command line upon startup

It can be seen from this that the directory pointed to needs to contain the two files conf/solrconfig.xml and conf/schema.xml, which means that the directory pointed to I need to have a conf subdirectory. I am because of this explanation of the official website. I haven't succeeded for a long time. In fact, I understand it wrong. I think there must be a subdirectory conf in the solr.solr.home directory. The conf contains solrconfig. .xml and schema.xml. But in fact, the conf directory is placed under the collection1 directory, the collection is an instance of solr Instance, solr can be configured with multiple collections, you can have a separate configuration file.

The configuration of web.xml here is:

solr/homeD:/Installed Applications/solr-4.9.0/solr-4.9.0/examplejava.lang.String

Special attention should be paid to the use of backslashes "/" instead of the default "" under Windows.

Here I am pointing directly to the example folder.

Method 2 (personal recommendation):

Create a new solr.xml file in the $TOMCAT_HOME/conf/Catalina/localhost directory, the content is:

Note here, The override needs to be set to false, otherwise each time you start tomcat, you will re-decompress the war file to overwrite the previous configuration, or manually decompress, point the context path directly to the folder

Step 5:

The collection1 directory under the solr-4.9.0examplesolr directory is copied to the solr-4.9.0example directory as a whole. The reader can customize the path, defined in web.xml, and the directory pointed to contains the collection1 directory.

Step 6:

Copy the jar package in the D:Installed Applicationssolr-4.9.0solr-4.9.0examplelibext directory to the apache-tomcat-8.0.9lib directory, or copy it to webappssolrWEB - INFlib, the reader can choose (global and local problems only). (If you start or report an error, you can find the corresponding jar package in solr-4.9.0dist according to the prompt).

Step 7:

Open the server.xml in the Tomcat conf directory, find the following code to add URIEncoding="UTF-8", add Chinese support.

connectionTimeout="20000"

redirectPort="8443"

URIEncoding="UTF-8" />

Step 8:

Start Tomcat, open the browser and type: http://localhost:8080/solr/admin/. If you see the startup screen, the installation is successful.

Summary

As can be seen from the above installation steps, step 4 is the core step, which needs to understand the operating principle of Solr: Solr is a service similar to Http interface It needs to be deployed in the web container (here Tomcat). After running, the application interacts with Solr in the form of Http request, including adding indexes, queries, and so on. So we need to deploy Solr in the web container and specify the directory where Solr is configured in the Tomcat configuration.

The installation method under Linux is not much different from Windows.

Copyright © Windows knowledge All Rights Reserved