Ii. Install SOLR (Tomcat)

Source: Internet
Author: User
Tags 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:

Decompress the solr-4.9.0 to any folder and I decompress it to the D: \ Installed applications \ solr-4.9.0 \ solr-4.9.0 directory.

Step 2:

Copy the solr-4.9.0 \ Dist \ solr-4.9.0.war to the Tomcat webapp/directory, preferably rename it SOLR. War.

Step 3:

Start tomcat, will report an error, this step is just to extract the solr-4.9.0.war, so manual decompression is also feasible under the webapp directory.

Step 4:

Method 1:

Open webapps \ SOLR \ WEB-INF \ WEB. xml

Find:

  

<!--<env-entry>   <env-entry-name>solr/home</env-entry-name>   <env-entry-value>/put/your/solr/home/here</env-entry-value>   <env-entry-type>java.lang.String</env-entry-type></env-entry>-->

 

Here, you need to configure SOLR/home. You only need to modify <env-entry-value>/Put/Your/SOLR/home/here </env-entry-value>.

 

This directory can be customized. We recommend that you use the directory extracted in step 1. Note that the SOLR official website's tutorial contains the following:

How SOLR works with Tomcat

The two basic steps for running SOLR in any web application container are as follows:

  1. Make the SOLR classes available to the container. in container 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 Tomcat's webapps directory. if you installed Tomcat with SOLR, take a look in Tomcat/webapps: You'll see the SOLR. war file is already there.
  2. 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

 

The <env-entry-value> directory must contain CONF/solrconfig. XML and CONF/schema. the two XML files mean that the conf sub-directory is required in the directory pointed to by <env-entry-value>. I did not succeed for a long time because of the explanation on the official website, in fact, I understood it wrong. I think it is in SOLR. SOLR. the home directory must have a subdirectory Conf, which contains solrconfig. XML and schema. XML. But in fact, the conf directory is placed under the collection1 directory, and collection is an instance of SOLR. Multiple collections can be configured in SOLR, and there can be independent configuration files.

My web. xml configuration here is:

  

<env-entry><env-entry-name>solr/home</env-entry-name><env-entry-value>D:/Installed Applications/solr-4.9.0/solr-4.9.0/example</env-entry-value><env-entry-type>java.lang.String</env-entry-type></env-entry>

 

Note that the configuration uses the Backslash "/" instead of the default "\" in windows "\".

Here I direct to the example folder.

 

Method 2(Personal recommendations):

Create a SOLR. xml file in the $ tomcat_home/CONF/Catalina/localhost directory with the following content:

 

<Context Path = "/SOLR" docbase = "... /Tomcat/webapps/SOLR. war "DEBUG =" 0 "crosscontext =" true "> <environment name =" SOLR/home "type =" Java. lang. string "value =" D:/installed applications/solr-4.9.0/solr-4.9.0/example "override =" true "/> note that override needs to be set to false, otherwise, each time Tomcat is started, the war file will be re-decompressed to overwrite the previous configuration, or after manual decompression, the context path will direct to the folder
</Context>

 

Step 5:

Copy the overall collection1 directory under the solr-4.9.0 \ example \ SOLR directory to the solr-4.9.0 \ example directory. You can customize the path by yourself. The <env-entry-value> </env-entry-type> defined in Web. xml contains the collection1 directory.

Step 6:

Copy the jar package under the D: \ Installed applications \ solr-4.9.0 \ solr-4.9.0 \ example \ Lib \ ext directory to the Apache-Tomcat-8.0.9 \ lib directory, you can also copy to webapps \ SOLR \ WEB-INF \ Lib, readers can choose on their own (global and local problems only ). (If the startup still reports an error, you can find the corresponding jar package in solr-4.9.0 \ Dist as prompted ).

Step 7:

Open Server. xml under the Tomcat conf directory, find the following code to add uriencoding = "UTF-8", add Chinese support.

<Connector port="8080" protocol="HTTP/1.1"           connectionTimeout="20000"           redirectPort="8443"           URIEncoding="UTF-8" />

 

Step 8:

Start Tomcat and enter http: // localhost: 8080/SOLR/admin/in the browser. If you see the startup screen, the installation is successful.

 

 

Summary

As shown in the preceding installation steps, step 4 is the core step. Here, we need to understand the operating principle of SOLR: SOLR is a service similar to the HTTP interface, it needs to be deployed in the Web Container (Tomcat here). After running, the application interacts with SOLR through HTTP requests, including adding indexes and querying. Therefore, we need to deploy SOLR in the Web Container and specify the SOLR configuration directory in Tomcat configuration.

The Installation Method in Linux is no different from that in windows.

 

Ii. Install SOLR (Tomcat)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.