solr 5.3.1安装配置
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&pageSize=100&pageIndex=1&siteId=6&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安装配置的更多相关文章
- solr 4.6的安装配置
从网上看了很多资料,很多都是老的.自己也算是结合着弄出来了. 1.下载的准备工作 tomcat8.solr4.6 具体的下载自己去找去吧.或者后期我在提供. 2.开始配置 tomcat路径:E:\ ...
- Zookeeper、Solr和Tomcat安装配置实践
Zookeeper.Solr和Tomcat安装配置实践
- (一)Solr——简介和安装配置
1. solr简介 1.1 Solr是什么 Solr是apache的顶级开源项目,它是使用java开发 ,基于lucene的全文检索服务器. Solr和lucene的版本是同步更新的,最新的版本是7. ...
- solr安装配置
1.solr是基于tomcat安装部署的 2.网上下载solr-5.2.1 http://lucene.apache.org/solr/downloads.html 3.解压solr文件 tar zx ...
- solr学习篇(一) solr7.4 安装配置篇
目录: solr简介 solr安装 创建core 1.solr简介 solr是企业级应用的全文检索项目,它是基于Apache Lucence搜索引擎开发出来的用于搜索的应用工程 运行环境:solr需要 ...
- 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 ) ...
- 【转载】Solr4+IKAnalyzer的安装配置
转载:http://www.cnblogs.com/madyina/p/4131751.html 一.下载Solr4.10.2 我们以Windows版本为例,solr-4.10.2.zip是目前最新版 ...
- Solr4+IKAnalyzer的安装配置
一.下载Solr4.10.2 我们以Windows版本为例,solr-4.10.2.zip是目前最新版本,下载地址: http://www.apache.org/dyn/closer.cgi/luce ...
- elasticsearch系列一:elasticsearch(ES简介、安装&配置、集成Ikanalyzer)
一.ES简介 1. ES是什么? Elasticsearch 是一个开源的搜索引擎,建立在全文搜索引擎库 Apache Lucene 基础之上 用 Java 编写的,它的内部使用 Lucene 做索引 ...
随机推荐
- pip通过requirements.txt安装依赖
pip install -t . -r requirements.txt requirements.txt Keras==2.0.8 gensim torchvision opencv-python ...
- Python requests如何将第一个请求得到的 cookie 通过 POST 提交给第二个请求
#coding=utf-8 import requests import json url_login, url_test = "http://192.168.0.162/login&quo ...
- (纪录片)《星际穿越》中的科学 The Science of Interstellar
简介: 导演: Gail Willumsen编剧: Gail Willumsen主演: 克里斯托弗·诺兰 / 乔纳森·诺兰 / 基普·索恩 / 马修·麦康纳类型: 纪录片 / 短片制片国家/地区: 美 ...
- tomcat7部署多个web应用不同编码,端口
1个tomcat部署多个web应用可以设置不同编码,端口,server.xml配置如下: <?xml version='1.0' encoding='utf-8'?><Server ...
- Swift语言精要 - 浅谈代理模式(Delegate)
在iOS编程中,我们经常谈到代理代理,也就是delegate,那么什么是代理呢? 我们来看一下cocoa对它的描述: Delegation is Cocoa’s term for passing of ...
- iOS界面篇 - bounds和frame的相同和区别
相同点: 他们都是CGRect类型,且拥有属性origin(x, y), size(weight, height) 不同点: bounds是你画的视图的边界,和父视图没有半毛钱关系 frames则一 ...
- iOS开发,更改状态栏(StatusBar)文字颜色为白色
详细实现步骤 1.如图在Info.plist中进行设置,主要用于处理启动画面中状态栏(StatusBar)文字颜色. watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5u ...
- 最好使的歌词编辑工具--Beslyric
https://www.cnblogs.com/BensonLaur/p/6262565.html 感谢开发这么好的工具! 下载地址:http://beslyric.320.io/BesBlog/ ...
- GitHub搭建个人网站详细教程
GitHub搭建个人网站详细教程: http://blog.csdn.net/gane_cheng/article/details/52203759
- 亲历H5移动端游戏微信支付接入及那些坑(四)——参考文档
写完三篇后,我觉得微信支付的文档确实比较乱,所以在此做一个整理汇总 支付流程相关文档 一下文档已经按照接入顺序排列,请依次参考阅读 微信公众号网页授权两种access_token区别,获取用户open ...