Installation and configuration of SOLR under Linux

Source: Internet
Author: User
Tags solr

Preparatory work
    1. Download solr and Tomcat

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

    1. Open/home/cluster, unzip

Tar zxvf apache-tomcat-7.0.54.tar.gz

Tar zxvf solr-4.8.1.tgz

Start the installation configurationSOLR
    1. Establish Solrhome

Mkdir-p/home/cluster/solrhome

    1. Copy the Solr War package and rename it to Solr.war in any folder This example puts it under Solrhome

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

    1. Then copy the/home/cluster/solr-4.8.1/example/solr folder to the Solrhome folder (this example directory is single core mode and copy multicore if it is multi-core mode)

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

    1. Then copy the contrib and Dist folders in the extracted solr-4.8.1 folder to/HOME/SOFT/SOLR-4.5.1/EXAMPLE/SOLR/HOME/SOFT/SOLRHOME/SOLR

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

ConfigurationTomcat
    1. Build Solr.xml under Tomcat's conf/catalina/localhost/folder (Docbase points to the Solr folder in Sorlhome to the war Solr/home)

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>

    1. SOLR's log-related jar package

Copy all the jars below the/home/cluster/solr-4.8.1/example/lib/ext to the Tomcat Lib folder

Copy the log4j configuration file below the/home/cluster/solr-4.8.1/example/resources to the Tomcat Lib folder

    1. Configuration modification for standalone version

Find the Solrconfig.xml in the Conf folder below each collection

<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 ">

    1. Modify the introduced jar Package location in the Solrconfig.xml file

Will

<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"/>

ConfigurationIKparticiple

Download IK Analyzer 2012ff_hf1.zip (This version supports 4.0 above)

After decompression, place Ikanalyzer2012ff_u1.jar under Tomcat/webapps/solr/web-inf/lib and create classes directory under tomcat/webapps/solr/web-inf/ Then unzip the ik****.zip and copy the IKAnalyzer.cfg.xml and stopword.dic two files to the classes directory

It's not necessarily a match, it depends on the file.

Modify Solrhome The following collection1/conf/schema.xml join 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 access HTTP://LOCALHOST:8080/SOLR look at the admin interface to go to the test

AndMySQLDatabase Configuration

The first step depends on the package:

SOLR package (in the Solr-4.8.1/dist directory), if the package is not found, you can use Find–name solr-datai* query

Solr-dataimporthandler-4.8.1.jar

Solr-dataimporthandler-extras-4.8.1.jar

Database Packages

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

At the same time, a jar is introduced into the 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 Two

Configure Solrconfig.xml

Add the following configuration to the 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 Three

To create a data-config.xml file, when using vi To edit this file, note that the spaces between attributes, note not to use the double quotes of Chinese characters, and note that field is in The properties defined in the 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 to the D:\tomcat-6.0.18\webapps\solr\WEB-INF\lib Mysql-connector-java-5.0.4-bin.jar

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

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

After configuring the contents above, you can start Tomcat for data import and follow the picture below.

After success, you can query the results.

Installation and configuration of SOLR under Linux

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.