1、下载Solr5.3.1

http://mirror.bit.edu.cn/apache/lucene/solr/5.3.1/

wget http://mirror.bit.edu.cn/apache/lucene/solr/5.3.0/solr-5.3.0.tgz

2、解压压缩包

tar zxf solr-5.3..tgz

unzip solr-5.3..zip

3、配置solr

1、复制solr项目文件

mkdir -p /data/web/solr/solr_app/
cp -r /data/solr-5.3./server/solr-webapp/webapp/* /data/web/solr/solr_app/

2、复制dll文件

cp /data/solr-5.3./server/lib/ext/* /data/web/solr/solr_app/WEB-INF/lib/

3、复制日志文件

mkdir /data/web/solr/solr_app/WEB-INF/classes
cp /data/solr-5.3./server/resources/log4j.properties /data/web/solr/solr_app/WEB-INF/classes/

4、修改solr.log文件的存储位置:默认在/root/logs/solr.log

vim /data/web/solr/solr_app/WEB-INF/classes/log4j.properties

改成自己的日志路径

5、复制solr.xml文件到web.xml里面的<env-entry-value>的路径下

mkdir -p /data/web/solr/solr_app/WEB-INF/solr_home
cp /data/solr-5.3.1/example/example-DIH/solr/solr.xml /data/web/solr/solr_app/WEB-INF/solr_home/

6、配置solr_home

vim /data/web/solr/solr_app/WEB-INF/web.xml   --修改env-entry-value的值:/data/web/solr/solr_app/WEB-INF/solr_home

tomcat配置->Server.xml->Connector->connectionTimeout="20000"不知道为什么,这个值大了启动tomcat,solr页面显示就是失败的。

启动tomcat,此时没有集合,如下图:

4、配置solr集合

1、进入solr_home,开始配置solr的索引库、分词器、数据源和定时任务:

cd /data/web/solr/solr_app/WEB-INF/solr_home/

2、为某一个语言创建solr配置,首先需要该语言的目录,比如:英文

mkdir pc_EN
cd pc_EN
touch core.properties
mkdir conf
mkdir data

3、编辑core.properties文件,设置索引名称和索引存放的位置:

vim core.properties
--指定索引文件的存放位置(solr_index目录可以创建了mkdir -p /data/web/solr/solr_app/WEB-INF/solr_index)
--文件内容
name=pc_EN
dataDir=/data/web/solr/solr_app/WEB-INF/solr_index/master/pc_EN/data

4、进入conf目录设置索引的数据格式、数据源

cd conf
find /data -name solrconfig.xml

把rss文件夹下面的solrconfig.xml复制到pc_EN/conf目录里面

cp /data/solr-5.3./example/example-DIH/solr/rss/conf/solrconfig.xml solrconfig.xml

设置solrconfig.xml关联website-data-config.xml文件

vim solrconfig.xml --搜索name="/dataimport"

设置solrconfig.xml的solr搜索结果返回的数据格式为:xml

设置solrconfig.xml关联schema.xml文件,增加如下代码:

<requestHandler name="/replication" class="solr.ReplicationHandler" >
<lst name="master">
<str name="replicateAfter">commit</str>
<str name="replicateAfter">startup</str>
<str name="confFiles">schema.xml</str>
</lst>
</requestHandler>

完整的solrconfig.xml文件

 <?xml version="1.0" encoding="UTF-8" ?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--> <!--
This is a stripped down config file used for a simple example...
It is *not* a good example to work from.
-->
<config>
<luceneMatchVersion>5.3.</luceneMatchVersion>
<!-- The DirectoryFactory to use for indexes.
solr.StandardDirectoryFactory, the default, is filesystem based.
solr.RAMDirectoryFactory is memory based, not persistent, and doesn't work with replication. -->
<directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.NRTCachingDirectoryFactory}"/> <dataDir>${solr.data.dir:}</dataDir> <!-- To enable dynamic schema REST APIs, use the following for <schemaFactory>: <schemaFactory class="ManagedIndexSchemaFactory">
<bool name="mutable">true</bool>
<str name="managedSchemaResourceName">managed-schema</str>
</schemaFactory> When ManagedIndexSchemaFactory is specified, Solr will load the schema from
he resource named in 'managedSchemaResourceName', rather than from schema.xml.
Note that the managed schema resource CANNOT be named schema.xml. If the managed
schema does not exist, Solr will create it after reading schema.xml, then rename
'schema.xml' to 'schema.xml.bak'. Do NOT hand edit the managed schema - external modifications will be ignored and
overwritten as a result of schema modification REST API calls. When ManagedIndexSchemaFactory is specified with mutable = true, schema
modification REST API calls will be allowed; otherwise, error responses will be
sent back for these requests.
-->
<codecFactory class="solr.SchemaCodecFactory"/>
<schemaFactory class="ClassicIndexSchemaFactory"/> <updateHandler class="solr.DirectUpdateHandler2">
<updateLog>
<str name="dir">${solr.data.dir:}</str>
<int name="numVersionBuckets">${solr.ulog.numVersionBuckets:}</int>
</updateLog>
</updateHandler> <query>
<!-- Max Boolean Clauses Maximum number of clauses in each BooleanQuery, an exception
is thrown if exceeded. ** WARNING ** This option actually modifies a global Lucene property that
will affect all SolrCores. If multiple solrconfig.xml files
disagree on this property, the value at any given moment will
be based on the last SolrCore to be initialized. -->
<maxBooleanClauses></maxBooleanClauses> <!-- Solr Internal Query Caches There are two implementations of cache available for Solr,
LRUCache, based on a synchronized LinkedHashMap, and
FastLRUCache, based on a ConcurrentHashMap. FastLRUCache has faster gets and slower puts in single
threaded operation and thus is generally faster than LRUCache
when the hit ratio of the cache is high (> %), and may be
faster under other scenarios on multi-cpu systems.
--> <!-- Filter Cache Cache used by SolrIndexSearcher for filters (DocSets),
unordered sets of *all* documents that match a query. When a
new searcher is opened, its caches may be prepopulated or
"autowarmed" using data from caches in the old searcher.
autowarmCount is the number of items to prepopulate. For
LRUCache, the autowarmed items will be the most recently
accessed items. Parameters:
class - the SolrCache implementation LRUCache or
(LRUCache or FastLRUCache)
size - the maximum number of entries in the cache
initialSize - the initial capacity (number of entries) of
the cache. (see java.util.HashMap)
autowarmCount - the number of entries to prepopulate from
and old cache.
-->
<filterCache class="solr.FastLRUCache"
size=""
initialSize=""
autowarmCount=""/> <!-- Query Result Cache Caches results of searches - ordered lists of document ids
(DocList) based on a query, a sort, and the range of documents requested.
Additional supported parameter by LRUCache:
maxRamMB - the maximum amount of RAM (in MB) that this cache is allowed
to occupy
-->
<queryResultCache class="solr.LRUCache"
size=""
initialSize=""
autowarmCount=""/> <!-- Document Cache Caches Lucene Document objects (the stored fields for each
document). Since Lucene internal document ids are transient,
this cache will not be autowarmed.
-->
<documentCache class="solr.LRUCache"
size=""
initialSize=""
autowarmCount=""/> <!-- custom cache currently used by block join -->
<cache name="perSegFilter"
class="solr.search.LRUCache"
size=""
initialSize=""
autowarmCount=""
regenerator="solr.NoOpRegenerator" /> <!-- Lazy Field Loading If true, stored fields that are not requested will be loaded
lazily. This can result in a significant speed improvement
if the usual case is to not load all stored fields,
especially if the skipped fields are large compressed text
fields.
-->
<enableLazyFieldLoading>true</enableLazyFieldLoading> <!-- Result Window Size An optimization for use with the queryResultCache. When a search
is requested, a superset of the requested number of document ids
are collected. For example, if a search for a particular query
requests matching documents through , and queryWindowSize is ,
then documents through will be collected and cached. Any further
requests in that range can be satisfied via the cache.
-->
<queryResultWindowSize></queryResultWindowSize> <!-- Maximum number of documents to cache for any entry in the
queryResultCache.
-->
<queryResultMaxDocsCached></queryResultMaxDocsCached> <!-- Use Cold Searcher If a search request comes in and there is no current
registered searcher, then immediately register the still
warming searcher and use it. If "false" then all requests
will block until the first searcher is done warming.
-->
<useColdSearcher>false</useColdSearcher> <!-- Max Warming Searchers Maximum number of searchers that may be warming in the
background concurrently. An error is returned if this limit
is exceeded. Recommend values of - for read-only slaves, higher for
masters w/o cache warming.
-->
<maxWarmingSearchers></maxWarmingSearchers> </query> <requestDispatcher handleSelect="true" >
<requestParsers enableRemoteStreaming="true" multipartUploadLimitInKB="" formdataUploadLimitInKB="" />
</requestDispatcher> <requestHandler name="/select" class="solr.SearchHandler">
<lst name="defaults">
<str name="echoParams">explicit</str>
<str name="wt">xml</str>
<str name="indent">true</str>
<int name="rows"></int>
</lst>
</requestHandler> <requestHandler name="/analysis/field" startup="lazy" class="solr.FieldAnalysisRequestHandler" /> <requestHandler name="/admin/ping" class="solr.PingRequestHandler">
<lst name="invariants">
<str name="q">*:*</str>
</lst>
<lst name="defaults">
<str name="echoParams">all</str>
</lst>
</requestHandler> <requestHandler name="/dataimport" class="org.apache.solr.handler.dataimport.DataImportHandler">
<lst name="defaults">
<str name="config">website-data-config.xml</str>
</lst>
</requestHandler> <requestHandler name="/replication" class="solr.ReplicationHandler" >
<lst name="master">
<str name="replicateAfter">commit</str>
<str name="replicateAfter">startup</str>
<str name="confFiles">schema.xml</str>
</lst>
</requestHandler> <!-- config for the admin interface -->
<admin>
<defaultQuery>*:*</defaultQuery>
</admin> </config>

solrconfig.xml

schema.xml用来设置solr需要索引的字段

完整的schema.xml

 <?xml version="1.0" ?>

 <schema name="website" version="1.5">
<types>
<fieldType name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true" />
<fieldType name="boolean" class="solr.BoolField" sortMissingLast="true" omitNorms="true" />
<fieldType name="booleans" class="solr.BoolField" sortMissingLast="true" multiValued="true"/>
<fieldType name="int" class="solr.TrieIntField" precisionStep="0" omitNorms="true" positionIncrementGap="0" />
<fieldType name="float" class="solr.TrieFloatField" precisionStep="0" omitNorms="true" positionIncrementGap="0" />
<fieldType name="long" class="solr.TrieLongField" precisionStep="0" omitNorms="true" positionIncrementGap="0" />
<fieldType name="double" class="solr.TrieDoubleField" precisionStep="0" omitNorms="true" positionIncrementGap="0" />
<fieldType name="date" class="solr.TrieDateField" omitNorms="true" precisionStep="0" positionIncrementGap="0" />
<fieldType name="tint" class="solr.TrieIntField" precisionStep="8" omitNorms="true" positionIncrementGap="0" />
<fieldType name="sfloat" class="solr.TrieFloatField" precisionStep="8" omitNorms="true" positionIncrementGap="0" />
<fieldType name="tlong" class="solr.TrieLongField" precisionStep="8" omitNorms="true" positionIncrementGap="0" />
<fieldType name="tdouble" class="solr.TrieDoubleField" precisionStep="8" omitNorms="true" positionIncrementGap="0" />
<fieldType name="tdate" class="solr.TrieDateField" omitNorms="true" precisionStep="6" positionIncrementGap="0" />
<fieldType name="tdates" class="solr.TrieDateField" precisionStep="6" positionIncrementGap="0" multiValued="true"/>
<fieldType name="tints" class="solr.TrieIntField" precisionStep="8" positionIncrementGap="0" multiValued="true"/>
<fieldType name="tfloats" class="solr.TrieFloatField" precisionStep="8" positionIncrementGap="0" multiValued="true"/>
<fieldType name="tlongs" class="solr.TrieLongField" precisionStep="8" positionIncrementGap="0" multiValued="true"/>
<fieldType name="tdoubles" class="solr.TrieDoubleField" precisionStep="8" positionIncrementGap="0" multiValued="true"/>
<fieldType name="text" class="solr.TextField">
<analyzer type="index" class="org.apache.lucene.analysis.en.EnglishAnalyzer"/>
<analyzer type="query" class="org.apache.lucene.analysis.en.EnglishAnalyzer"/>
</fieldType>
</types>
<!-- general -->
<fields>
<field name="_version_" type="long" indexed="true" stored="true"/>
<field name="CultureID" type="int" indexed="false" stored="true" />
<field name="DescriptionFull" type="text" indexed="true" stored="false" />
<field name="DescriptionShort" type="text" indexed="true" stored="false" />
<field name="ImageJSON" type="text" indexed="false" stored="true" />
<field name="IsHot" type="int" indexed="false" stored="true" />
<field name="IsMutilColor" type="int" indexed="false" stored="true" default="" />
<field name="LeiMuNameJSON" type="text" indexed="true" stored="true" />
<field name="PID" type="string" indexed="true" stored="true" />
<field name="PropertyText" type="text" indexed="true" stored="true" />
<field name="RequiredText" type="text" indexed="true" stored="true" />
<field name="SPUID" type="long" indexed="true" stored="true" />
<field name="Sort" type="int" indexed="true" stored="true" />
<field name="Status" type="int" indexed="true" stored="true" />
<field name="Title" type="text" indexed="true" stored="true" />
<field name="UpTime" type="date" indexed="true" stored="true" />
<field name="Price" type="double" indexed="true" stored="true" />
<field name="SaleCount" type="long" indexed="true" stored="true" />
<field name="CustomerRatingCount" type="long" indexed="false" stored="true" />
<field name="DisCount" type="double" indexed="true" stored="true" />
<field name="Basic_search" type="text" indexed="true" stored="false" multiValued="true"/>
</fields> <!-- field to use to determine and enforce document uniqueness. -->
<uniqueKey>SPUID</uniqueKey>
<!-- field for the QueryParser to use when an explicit fieldname is absent -->
<defaultSearchField>Basic_search</defaultSearchField>
<!-- SolrQueryParser configuration: defaultOperator="AND|OR" -->
<solrQueryParser defaultOperator="OR"/>
<copyField source="PID" dest="Basic_search" />
<copyField source="DescriptionFull" dest="Basic_search" />
<copyField source="DescriptionShort" dest="Basic_search" />
<copyField source="LeiMuNameJSON" dest="Basic_search" />
<copyField source="PropertyText" dest="Basic_search" />
<copyField source="RequiredText" dest="Basic_search" />
<copyField source="Title" dest="Basic_search" />
</schema>

schema.xml

website-data-config.xml设置数据源和数据源格式与schema.xml的字段匹配

完整的website-data-config.xml

 <?xml version="1.0" encoding="UTF-8" ?>
<dataConfig>
<dataSource type="URLDataSource" encoding="UTF-8" />
<document>
<entity name="website"
processor="XPathEntityProcessor"
forEach="/LuceneSpuXmlModel/LuceneSpuModelList/LuceneSpuModel |/LuceneSpuXmlModel"
url="http://url/product?cultureId=1&amp;pageSize=100&amp;pageIndex=1&amp;siteId=6&amp;platform=1"
transformer="RegexTransformer,DateFormatTransformer"
connectionTimeout="120000"
readTimeout="300000"
stream="true">
<field column="SPUID" xpath="/LuceneSpuXmlModel/LuceneSpuModelList/LuceneSpuModel/SPUID" />
<field column="PID" xpath="/LuceneSpuXmlModel/LuceneSpuModelList/LuceneSpuModel/PID" />
<field column="Title" xpath="/LuceneSpuXmlModel/LuceneSpuModelList/LuceneSpuModel/Title" />
<field column="Status" xpath="/LuceneSpuXmlModel/LuceneSpuModelList/LuceneSpuModel/Status" />
<field column="CultureID" xpath="/LuceneSpuXmlModel/LuceneSpuModelList/LuceneSpuModel/CultureID" commonField="true" />
<field column="LeiMuNameJSON" xpath="/LuceneSpuXmlModel/LuceneSpuModelList/LuceneSpuModel/LeiMuNameJSON" />
<field column="DescriptionShort" xpath="/LuceneSpuXmlModel/LuceneSpuModelList/LuceneSpuModel/DescriptionShort" commonField="true" />
<field column="DescriptionFull" xpath="/LuceneSpuXmlModel/LuceneSpuModelList/LuceneSpuModel/DescriptionFull" commonField="true" />
<field column="Sort" xpath="/LuceneSpuXmlModel/LuceneSpuModelList/LuceneSpuModel/Sort" />
<field column="ImageJSON" xpath="/LuceneSpuXmlModel/LuceneSpuModelList/LuceneSpuModel/ImageJSON" />
<field column="PropertyText" xpath="/LuceneSpuXmlModel/LuceneSpuModelList/LuceneSpuModel/PropertyText" />
<field column="RequiredText" xpath="/LuceneSpuXmlModel/LuceneSpuModelList/LuceneSpuModel/RequiredText" />
<field column="IsHot" xpath="/LuceneSpuXmlModel/LuceneSpuModelList/LuceneSpuModel/IsHot" />
<field column="IsMutilColor" xpath="/LuceneSpuXmlModel/LuceneSpuModelList/LuceneSpuModel/IsMutilColor" />
<field column="UpTime" xpath="/LuceneSpuXmlModel/LuceneSpuModelList/LuceneSpuModel/UpTime" dateTimeFormat="yyyy-MM-dd'T'hh:mm:ss"/>
<field column="Price" xpath="/LuceneSpuXmlModel/LuceneSpuModelList/LuceneSpuModel/Price" />
<field column="SaleCount" xpath="/LuceneSpuXmlModel/LuceneSpuModelList/LuceneSpuModel/SaleCount" />
<field column="CustomerRatingCount" xpath="/LuceneSpuXmlModel/LuceneSpuModelList/LuceneSpuModel/CustomerRatingCount" />
<field column="DisCount" xpath="/LuceneSpuXmlModel/LuceneSpuModelList/LuceneSpuModel/DisCount" /> <field column="$hasMore" xpath="/LuceneSpuXmlModel/HasMore" />
<field column="$nextUrl" xpath="/LuceneSpuXmlModel/NextPageUrl" />
</entity>
</document>
</dataConfig>

website-data-config.xml

启动Tomcat运行solr出错:

复制数据倒入的包:

cp /data/solr-5.3.1/dist/solr-dataimporthandler-* /data/web/solr/solr_app/WEB-INF/lib/

启动tomcat_solr成功界面如下:

5、设置solr定时任务

1、复制定时任务包(如果没有复制过)

cp /data/solr-5.3.1/dist/solr-dataimporthandler-* /data/web/solr/solr_app/WEB-INF/lib/

2、还需要一个jar也复制到/data/web/solr/solr_app/WEB-INF/lib/下面:

apache-solr-dataimportscheduler-1.0.jar

3、修改Web.xml,添加配置节点:

<listener>
<listener-class>
org.apache.solr.handler.dataimport.scheduler.ApplicationListener
</listener-class>
</listener>

4、回到solr_home目录创建conf目录,创建dataimport.properties定时任务文件:

5、编辑dataimport.properties定时任务文件:

a、设置syncCores,server,port

b、设置时间间隔、开始时间:

http://my.oschina.net/lsf930709/blog/620738(参考文章)

solr 5.3.1安装配置的更多相关文章

  1. solr 4.6的安装配置

    从网上看了很多资料,很多都是老的.自己也算是结合着弄出来了. 1.下载的准备工作 tomcat8.solr4.6   具体的下载自己去找去吧.或者后期我在提供. 2.开始配置 tomcat路径:E:\ ...

  2. Zookeeper、Solr和Tomcat安装配置实践

    Zookeeper.Solr和Tomcat安装配置实践

  3. (一)Solr——简介和安装配置

    1. solr简介 1.1 Solr是什么 Solr是apache的顶级开源项目,它是使用java开发 ,基于lucene的全文检索服务器. Solr和lucene的版本是同步更新的,最新的版本是7. ...

  4. solr安装配置

    1.solr是基于tomcat安装部署的 2.网上下载solr-5.2.1 http://lucene.apache.org/solr/downloads.html 3.解压solr文件 tar zx ...

  5. solr学习篇(一) solr7.4 安装配置篇

    目录: solr简介 solr安装 创建core 1.solr简介 solr是企业级应用的全文检索项目,它是基于Apache Lucence搜索引擎开发出来的用于搜索的应用工程 运行环境:solr需要 ...

  6. solr4.5安装配置 linux+tomcat6.0+mmseg4j-1.9.1分词

    首先先介绍下solr的安装配置 solr下载地址 (我这用的solr-4.5.0) 运行环境 JDK 1.5或更高版本 下载地址(Solr 4以上版本,要求JDK 1.6)  我用的JDK1.6 ) ...

  7. 【转载】Solr4+IKAnalyzer的安装配置

    转载:http://www.cnblogs.com/madyina/p/4131751.html 一.下载Solr4.10.2 我们以Windows版本为例,solr-4.10.2.zip是目前最新版 ...

  8. Solr4+IKAnalyzer的安装配置

    一.下载Solr4.10.2 我们以Windows版本为例,solr-4.10.2.zip是目前最新版本,下载地址: http://www.apache.org/dyn/closer.cgi/luce ...

  9. elasticsearch系列一:elasticsearch(ES简介、安装&配置、集成Ikanalyzer)

    一.ES简介 1. ES是什么? Elasticsearch 是一个开源的搜索引擎,建立在全文搜索引擎库 Apache Lucene 基础之上 用 Java 编写的,它的内部使用 Lucene 做索引 ...

随机推荐

  1. 设置Linux中的Mysql不区分表名大小写

    1. MySQL数据库的表名在Linux系统下是严格区分大小写的,在Windows系统下开发的程序移植到Linux系统下,如果程序中SQL语句没有严格按照大小写访问数据库表,就可能会出现找不到表的错误 ...

  2. Sublime 格式化代码 设置快捷键以及插件使用

    实在sublime中已经自建了格式化按钮: Edit  ->  Line  ->  Reindent 只是sublime并没有给他赋予快捷键,所以只需加上快捷键即可 Preference ...

  3. 安装ecshop2.7时候的错误处理 php版本不兼容引起

    装ECShop2.7.3出现了一堆问题,主要是因为PHP版本过高引起的,不愿意降低版本,则只能一个个解决啦!这些问题包括:preg_replace.cls_image::gd_version.end( ...

  4. 创建mysql数据库并指定编码

    xplanner的readme.txt里有句话“XPlanner has only been tested on mysql 4.x, myslq 5.0, Tomcat 5.x, java 1.4, ...

  5. 利用RTMFP开发P2P应用

    利用RTMFP开发P2P应用 flash10使用RTMFP 开发点对点P2P应用 通过Stratus 服务器在Flash Player中使用RTMFP 开发 点对点应用 Adobe Flash Pla ...

  6. gdb 小技巧

    https://www.gitbook.com/book/wizardforcel/100-gdb-tips/details

  7. Maven的坐标与资源库

    在Maven世界中,每个工程都有它唯一的 组织名.模块名.版本 ,这三个就是maven项目的坐标,一个maven工程可以打包成jar.war.pom等形式,但是它们都是拥有上述三个坐标的.我们在项目过 ...

  8. 腾讯云ubuntu安装Mysql并配置远程访问

    转载请注明原文地址:http://www.cnblogs.com/ygj0930/p/6378914.html 一:修改SSH配置 输入 su 进入root模式.修改ssh配置: sudo vi /e ...

  9. 结合JSFL/actionscript 实现轮廓动画

    动画前半段通过JSFL获取轮廓数据,并在EnterFrame中逐个边缘画出的:后半段机枪动画是美术做好的flash动画. 这里只放出actionscript代码,而JSFL代码涉及到一个工程,暂时保密 ...

  10. 怎样解决WampServer #1405 - Access denied for user &#39;root&#39;@&#39;localhost&#39; (using password: NO)

    转载请注明出处:http://blog.csdn.net/xingjiarong/article/details/47903227 之前一直在用wampserver,然后环境配置也是正确的,可是过了一 ...