Linux under Installation using SOLR

Source: Internet
Author: User
Tags solr

Linux under Installation using SOLR

1, first download SOLR, mmseg4j participle packet, tomcat and decompression, which Google, baidu can be searched.

2, because to use the Chinese word segmentation, so to set the code, enter the Tomcat installation directory, use VI to modify the Confserver.xml configuration

<port= "8080"  protocol= "http/1.1"              connectiontimeout  = "20000"              redirectport= "8443"  uriencoding= "UTF-8" />

Increase the uriencoding= "UTF-8" setting to encode utf-8.

3. Copy the Apache-solr-*.war from the Dist folder below the downloaded SOLR package to the WebApps of Tomcat and rename it to Solr.war

Cp/opt/apache-solr-3.6.1/dist/apache-solr-3.6.1.war/opt/apache-tomcat-6.0.35/webapps/solr.war

4. Copy the SOLR files from the example folder under the download SOLR package to the/OPT directory

Cp-r/opt/apache-solr-3.6.1/example/solr//opt

5, configure the environment variable solr.home, use VI to modify the/etc/profile, add the following code, configure the permanent variable, restart reboot

Export java_opts= "$JAVA _OPTS-DSOLR.SOLR.HOME=/OPT/SOLR"

6. Start the Tomcat service and then visit http://127.0.0.1:8080/solr/

The following page appears, indicating a successful configuration

7, the configuration of Chinese word segmentation, the mmseg4j directory under a jar to copy to the solr/web-inf/lib/directory for SOLR to use, here must run again before the SOLR folder will be generated

cp/opt/mmseg4j/mmseg4j-all-1.8.3.jar/opt/apache-tomcat-6.0.35/webapps/solr/web-inf/lib/

8. Configure Chinese Thesaurus

cp/opt/mmseg4j/data/words.dic/opt/solr/dic/

9, change the Schema.xml (/opt/solr/conf/schema.xml) file, make the word breaker play a role.

<!--mmseg4j field Types -<FieldTypename= "Textcomplex"class= "SOLR." TextField "Positionincrementgap= "+" >  <Analyzer>     <Tokenizerclass= "Com.chenlb.mmseg4j.solr.MMSegTokenizerFactory"Mode= "complex"Dicpath= "/opt/solr/dic"/>     <Filterclass= "SOLR." Lowercasefilterfactory "/>   </Analyzer> </FieldType> <FieldTypename= "Textmaxword"class= "SOLR." TextField "Positionincrementgap= "+" > <Analyzer>  <Tokenizerclass= "Com.chenlb.mmseg4j.solr.MMSegTokenizerFactory"Mode= "Max-word"Dicpath= "/opt/solr/dic"/>  <Filterclass= "SOLR." Lowercasefilterfactory "/> </Analyzer> </FieldType> <FieldTypename= "Textsimple"class= "SOLR." TextField "Positionincrementgap= "+" > <Analyzer>   <Tokenizerclass= "Com.chenlb.mmseg4j.solr.MMSegTokenizerFactory"Mode= "simple"Dicpath= "/opt/solr/dic"/>   <Filterclass= "SOLR." Lowercasefilterfactory "/> </Analyzer> </FieldType>

10, http://127.0.0.1:8080/solr/admin/analysis.jsp

Click Analyze to see the word breaker effect

11. Configure MySQL Database

The first thing to import is the jar package that connects to MySQL Mysql-connector-java-5.1.7-bin.jar

I put it in Tomcat's Lib directory.

Touch/opt/solr/conf/mysql.xml

Write the following into Mysql.xml

<?XML version= "1.0" encoding= "UTF-8"?><Dataconfig><DataSourcetype= "Jdbcdatasource"Driver= "Com.mysql.jdbc.Driver"URL= "Jdbc:mysql://10.10.150.116/travel_main"User= "New_travel_u"Password= "123045"/>    <Documentname= "User_core">        <Entityname= "User_core"Query= "SELECT * from User_core"PK= "UserId"Deltaquery= "Select UserId from User_core where EditTime > ' ${dataimporter.last_index_time} '">   <Fieldcolumn= "UserId"name= "id" />            <Fieldcolumn= "nickname"name= "nickname" />        </Entity>    </Document></Dataconfig>

Solrconfig.xml <fields> must have child elements corresponding to database fields, I have added a nickname here

<field name= "nickname" Type= "string" indexed= "true" stored= "true"/>

Configure the Solrconfig.xml file and add a new node under the <config> node

<RequestHandlername= "/dataimport"class= "Org.apache.solr.handler.dataimport.DataImportHandler">  <LSTname= "Defaults">    <Strname= "config">/opt/solr/conf/mysql.xml</Str>       </LST></RequestHandler>

Modify the path of the <lib> tag, or you may not find the corresponding JAR package

<Libdir= "/opt/apache-solr-3.6.1/dist/"Regex= "Apache-solr-cell-\d.*\.jar" /><Libdir= "/opt/apache-solr-3.6.1/contrib/extraction/lib"Regex= ". *\.jar" /><Libdir= "/opt/apache-solr-3.6.1/dist/"Regex= "Apache-solr-clustering-\d.*\.jar" /><Libdir= "/opt/apache-solr-3.6.1/contrib/clustering/lib/"Regex= ". *\.jar" /><Libdir= "/opt/apache-solr-3.6.1/dist/"Regex= "Apache-solr-dataimporthandler-\d.*\.jar" /><Libdir= "/opt/apache-solr-3.6.1/contrib/dataimporthandler/lib/"Regex= ". *\.jar" /><Libdir= "/opt/apache-solr-3.6.1/dist/"Regex= "Apache-solr-langid-\d.*\.jar" /><Libdir= "/opt/apache-solr-3.6.1/contrib/langid/lib/"Regex= ". *\.jar" /><Libdir= "/opt/apache-solr-3.6.1/dist/"Regex= "Apache-solr-velocity-\d.*\.jar" /><Libdir= "/opt/apache-solr-3.6.1/contrib/velocity/lib"Regex= ". *\.jar" />

12. Restart Tomcat

/opt/apache-tomcat-6.0.35/bin/shutdown.sh
/opt/apache-tomcat-6.0.35/bin/startup.sh

13. Browser Input URL

Http://127.0.0.1:8080/solr/dataimport?command=full-import

New full-scale index, then enter

HTTP/127.0.0.1:8080/solr/admin/

Query results

Incremental indexing can be scheduled on a timed schedule

HTTP/127.0.0.1:8080/solr/dataimport?command=delta-import

Linux under Installation using SOLR

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.