Installation and configuration of solr in linux, linuxsolr Configuration

Source: Internet
Author: User
Tags solr

Installation and configuration of solr in linux, linuxsolr Configuration
Preparations

Solr-4.8.1.tgz,apache-tomcat-7.0.54.tar.gz

 

Tar zxvf apache-tomcat-7.0.54.tar.gz

Tar zxvf solr-4.8.1.tgz

Start installing and configuring solr

Mkdir-p/home/cluster/solrhome

 

Cp/home/cluster/solr-4.8.1/dist/solr-4.8.1.war/home/cluster/solrhome/solr. war

 

Cp-r/home/cluster/solr-4.8.1/example/solr/home/cluster/solrhome

Cp-rf/home/cluster/solr-4.8.1/contrib/home/cluster/solrhome/solr

Cp-rf/home/cluster/solr-4.8.1/dist/home/cluster/solrhome/solr

Configure tomcat

Vi conf/Catalina/localhost/solr. xml

<? Xml version = "1.0" encoding = "UTF-8"?>

<Context docBase = "/home/cluster/solrhome/solr. war" reloadable = "true">

<Environment name = "solr/home" type = "java. lang. String" value = "/home/cluster/solrhome/solr/" override = "true"/>

</Context>

Copy all jar files under/home/cluster/solr-4.8.1/example/lib/ext to the lib folder of tomcat.

Copy the log4j configuration file under/home/cluster/solr-4.8.1/example/resources to the lib folder of tomcat.

 

Find solrconfig. xml in the conf folder under each collection.

Set <searchComponent name = "clustering" enable = "$ {solr. clustering. enabled: true}" class = "solr. clustering. ClusteringComponent">

Change to <searchComponent name = "clustering" enable = "$ {solr. clustering. enabled: false}" class = "solr. clustering. ClusteringComponent">

 

Set

<Lib dir = ".../contrib/extraction/lib" regex = ". * \. jar"/>

<Lib dir = ".../../dist/" regex = "solr-cell-\ d. * \. jar"/>

<Lib dir = ".../../contrib/clustering/lib/" regex = ". * \. jar"/>

<Lib dir = ".../../dist/" regex = "solr-clustering-\ d. * \. jar"/>

<Lib dir = ".../contrib/langid/lib/" regex = ". * \. jar"/>

<Lib dir = ".../../dist/" regex = "solr-langid-\ d. * \. jar"/>

<Lib dir = ".../contrib/velocity/lib" regex = ". * \. jar"/>

<Lib dir = ".../../dist/" regex = "solr-velocity-\ d. * \. jar"/>

Change to absolute path

<Lib dir = "/home/cluster/solrhome/solr/contrib/extraction/lib" regex = ". * \. jar"/>

<Lib dir = "/home/cluster/solrhome/solr/dist/" regex = "solr-cell-\ d. * \. jar"/>

<Lib dir = "/home/cluster/solrhome/solr/contrib/clustering/lib/" regex = ". * \. jar"/>

<Lib dir = "/home/cluster/solrhome/solr/dist/" regex = "solr-clustering-\ d. * \. jar"/>

<Lib dir = "/home/cluster/solrhome/solr/contrib/langid/lib/" regex = ". * \. jar"/>

<Lib dir = "/home/cluster/solrhome/solr/dist/" regex = "solr-langid-\ d. * \. jar"/>

<Lib dir = "/home/cluster/solrhome/solr/contrib/velocity/lib" regex = ". * \. jar"/>

<Lib dir = "/home/cluster/solrhome/solr/dist/" regex = "solr-velocity-\ d. * \. jar"/>

Configure IK Word Segmentation

Download IK Analyzer 2012FF_hf1.zip (this version supports more than 4.0)

Unzip IKAnalyzer2012FF_u1.jar to tomcat/webapps/solr/WEB-INF/lib, and create the classes directory under tomcat/webapps/solr/WEB-INF/And then IK ****. decompress the zip file and extract IKAnalyzer. cfg. xml and stopword. copy two dic files to the classes directory.

This configuration may not be used. Check whether the file has been configured.

Modify collection1/conf/schema. xml under solrhome to add the following types:

<FieldType name = "text_ik" class = "solr. TextField">

<Analyzer class = "org. wltea. analyzer. lucene. IKAnalyzer"/>

<Filter class = "solr. StopFilterFactory" ignoreCase = "true" words = "stopwords.txt" enablePositionIncrements = "true"/>

</FieldType>

OK, start your tomcat and access http: // localhost: 8080/solr. Check the management interface to go to the test page.

 

 

 

And mysql Database Configuration

Step 1 import the dependency package:

Solr package (under the solr-4.8.1/dist directory), if you cannot find the package, you can use find-name solr-datai * to query

Solr-dataimporthandler-4.8.1.jar

Solr-dataimporthandler-extras-4.8.1.jar

Database package

Mysql-connector-java-3.0.10-stable-bin.jar put under/home/cluster/solrhome/solr/dist

Introduce jar in solrconfig. xml under/home/cluster/solrhome/solr/collection1/conf.

<Lib dir = "/home/cluster/solrhome/solr/dist/" regex = "solr-dataimporthandler-\ d. * \. jar"/>

<Lib dir = "/home/cluster/solrhome/solr/dist/" regex = "mysql-connector-java-3.0.10-stable-bin.jar"/>

 

 

Step 2

Configure solrconfig. xml

Add the following configuration to solrconfig. xml:

<RequestHandler name = "/dataimport" class = "org. apache. solr. handler. dataimport. DataImportHandler">

<Lst name = "defaults">

<Str name = "config"> data-config.xml </str>

</Lst>

</RequestHandler>

Step 3

Create a data-config.xml file. When editing this file using vi, note the space between properties, be sure not to use double quotation marks for Chinese characters, and note that field is an attribute defined in schema. xml.

<DataConfig>

<DataSource type = "JdbcDataSource" driver = "com. mysql. jdbc. Driver"

Url = "jdbc: mysql: // localhost: 3306 /****? UseUnicode = true & characterEncoding = UTF-8 "user =" root "password =" mysql "/>

<Document name = "search_object">

<Entity name = "cource" query = "SELECT id, name, description, price_per_day FROM t_course">

<Field column = "id" name = "id"/>

<Field column = "name" name = "name"/>

<Field column = "description" name = "description"/>

<Field column = "price_per_day" name = "price_per_day"/>

<Entity name = "courceImage"

Query = "SELECT file_path FROM t_course_image, t_course WHERE course_id = '$ {cource. id}'">

<Field column = "file_path" name = "file_path"/>

</Entity>

</Entity>

</Document>

</DataConfig>

 

 

Add the mysql driver package WEB-INF to D: \ tomcat-6.0.18 \ webapps \ solr \ mysql-connector-java-5.0.4-bin.jar \ lib

 

6, apache-solr-3.6.2, solr-dataimporthandler-4.8.1.jar In the downloaded solr-dataimporthandler-extras-4.8.1.jar/dist/folder

Copy to the D: \ tomcat-6.0.18 \ webapps \ solr \ WEB-INF \ lib folder

 

 

After configuring the preceding content, you can start tomcat to import data, and click the image below.

 

 

After the operation is successful, you can query the result.

 

 

 


Install solr in ubuntu and configure Environment Variables

Assume that your tomcat is/usr/local/tomcat again.

Cp/opt/solr-4.4.0/dist/solr-4.4.0.war/usr/local/tomcat/webapps/solr. war

# Copy slf4j jar files and log. properties to tomcat
Cp/opt/solr-4.4.0/example/lib/ext/*. jar/usr/local/tomcat/lib
# This step will let solr write logs to/usr/local/tomcat/logs/solr. log
Cp/opt/solr-4.4.0/example/resources/log4j. properties/usr/local/tomcat/lib

# Update your solr. solr. home path to the following command:
# Set solr home for tomcat
Echo 'java _ OPTS = "$ JAVA_OPTS-Dsolr. solr. home =/path/to/your/solr. home/"'>/usr/local/tomcat/bin/setenv. sh

Must Tomcat be installed before solr installation? What are the installation methods of solr in Linux?

You can use jettey to run it without development.

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.