linux下配置tomcat7 + solr4.9(续)--- 多核索引的配置
在上一篇文章中(详见http://www.cnblogs.com/bxljoy/p/3850263.html),我们已经介绍了tomcat+solr的索引服务器的配置,但是文中创建的服务器只能支持存储单一索引,很多情况下,我们需要对多个表或者多组不同的数据分别创建索引,如果每次需要创建一个索引库,就要部署一套solr服务,那明显是不合算的,所以本文就来介绍一下solr的进阶应用,在同一台服务器中配置多核索引。
进入我们解压好的solr文件目录:
cd /home/hadoop2/solr/example/multicore ls core0 core1 exampledocs README.txt solr.xml zoo.cfg
将此文件夹下的所有内容都复制到我们solr服务器的home目录,如下:
cp -r * /home/hadoop2/solrhome ls bin collection1 controller core0 core1 logs README.txt solrindex solr.xml zoo.cfg
其中solr.xml配置文件内容如下:
<solr persistent="false"> <!--
adminPath: RequestHandler path to manage cores.
If 'null' (or absent), cores will not be manageable via request handler
-->
<cores adminPath="/admin/cores" host="${host:}" hostPort="" hostContext="${hostContext:solr}">
<core name="core0" instanceDir="core0" />
<core name="core1" instanceDir="core1" />
<core name="controller" instanceDir="controller" />
<shardHandlerFactory name="shardHandlerFactory" class="HttpShardHandlerFactory"> <str name="urlScheme">${urlScheme:}</str> </shardHandlerFactory> </cores> </solr>
其中红字部分需要注意:端口需要改成与自己配置的tomcat服务器端口一致,本文中为6688,;而下面的红字core属性为自定义的索引文件夹,在solrhome目录中分别对应core0、core1和controller索引文件夹,其中包含配置文件和索引数据文件:
ls /home/hadoop2/solrhome/controller/conf logs schema.xml solrconfig.xml ls /home/hadoop2/solrhome/core0/conf logs schema.xml solrconfig.xml ls /home/hadoop2/solrhome/core1/conf logs schema.xml solrconfig.xml
其中solrconfig.xml无需修改,只要修改schema.xml即可:
<schema name="example core zero" version="1.1"> <fieldtype name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true"/>
<fieldType name="long" class="solr.TrieLongField" precisionStep="" positionIncrementGap=""/>
<!-- general -->
<field name="id" type="string" indexed="true" stored="true" multiValued="false" required="true"/>
<field name="type" type="string" indexed="true" stored="true" multiValued="false" />
<field name="name" type="string" indexed="true" stored="true" multiValued="false" />
<field name="core0" type="string" indexed="true" stored="true" multiValued="false" />
<field name="_version_" type="long" indexed="true" stored="true"/> <!-- field to use to determine and enforce document uniqueness. -->
<uniqueKey>id</uniqueKey> <!-- field for the QueryParser to use when an explicit fieldname is absent -->
<defaultSearchField>name</defaultSearchField> <!-- SolrQueryParser configuration: defaultOperator="AND|OR" -->
<solrQueryParser defaultOperator="OR"/>
</schema>
系统默认的uniqueKey为id,如果有需要,我们可以修改uniqueKey,并添加我们需要创建的索引字段,如下:
<schema name="example core zero" version="1.1"> <fieldtype name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true"/>
<fieldType name="long" class="solr.TrieLongField" precisionStep="" positionIncrementGap=""/>
<!-- general -->
<!--
<field name="id" type="string" indexed="true" stored="true" multiValued="false" required="true"/>
-->
<field name="type" type="string" indexed="true" stored="true" multiValued="false" />
<field name="name" type="string" indexed="true" stored="true" multiValued="false" />
<field name="core0" type="string" indexed="true" stored="true" multiValued="false" />
<field name="_version_" type="long" indexed="true" stored="true"/> <!-- field to use to determine and enforce document uniqueness. -->
<uniqueKey>rowkey</uniqueKey>
<field name="rowkey" type="string" indexed="true" stored="true" multiValued="false" required="true"/>
<field name="one" type="string" indexed="true" stored="true" multiValued="false" />
<field name="two" type="string" indexed="true" stored="true" multiValued="false" />
<field name="three" type="string" indexed="true" stored="true" multiValued="false" /> <!-- field for the QueryParser to use when an explicit fieldname is absent -->
<defaultSearchField>name</defaultSearchField> <!-- SolrQueryParser configuration: defaultOperator="AND|OR" -->
<solrQueryParser defaultOperator="OR"/>
</schema>
以上的配置文件中,我们将uniqueKey修改为rowkey,并注释掉id字段的定义,或者修改id字段的required属性为fasle也可以,然后我们添加了需要创建索引的字段。
之前介绍的配置文件的修改,我们在core0、core1和controller三个文件夹中都需要做,根据建立的三个不同索引的需要,配置不同的uniqueKey和索引字段。然后重启tomcat服务器,访问对应的solr服务器的url:http://10.1.5.242:6688/solr,会看到如下图页面:

点击左侧菜单栏中的 Core Admin选项,就可以看到多个索引的状态页面了,如下图:

点击controller、core0和core1中间菜单栏,就可以切换索引状态界面,查看索引的具体信息。
solr服务器的多核索引配置步骤就是这样,后面我会介绍使用solr的java API,对索引进行创建、更新和删除等基本操作。
转载请注明出处:http://www.cnblogs.com/bxljoy/p/3861003.html
linux下配置tomcat7 + solr4.9(续)--- 多核索引的配置的更多相关文章
- Linux下使用 github+hexo 搭建个人博客03-hexo配置优化
上两张文章,我们说了 hexo 部署.主题的切换.博文的创建.MarkDown 简单使用和 hexo 部署到 GitHub Pages. 也说了我们会使用 next 主题做为我们后期博客的使用和维护. ...
- linux下配置tomcat7 + solr4.9
一.安装准备 操作系统:CentOS 6.5 tomcat版本:apache-tomcat-7.0.54.tar.gz solr版本:solr-4.9.0.tgz 二.部署实施 安装tomcat:将t ...
- Linux下Solr单机版、集群版安装与配置
一.安装 1.需要的安装包有apache-tomcat-7.0.47.tar.gz.solr-4.10.3.tgz.tgz(jdk自行安装) 这里默认大家已经安装好jdk与tomcat,所以在这里不做 ...
- Linux下安装tar.gz类型的jdk,并配置环境变量
近期因要学习一门技术,必须在Linux下运行,故开始学习如何使用Linux. 在安装jdk时出现了困难,环境变量配置不成功,花了一天时间才搞定,特分享出来,供大家参考. Linux下安装jdk,步骤如 ...
- Linux下jvm、tomcat、mysql、log4j优化配置笔记
小菜一直对操作系统心存畏惧,以前也很少接触,这次创业购买了Linux云主机,由于木有人帮忙,只能自己动手优化服务器了.... 小菜的云主机配置大致为:centeos6(32位),4核心cpu,4G内存 ...
- Linux下jvm、tomcat、mysql、log4j优化配置
小菜一直对操作系统心存畏惧,以前也很少接触,这次创业购买了Linux云主机,由于木有人帮忙,只能自己动手优化服务器了.... 小菜的云主机配置大致为:centeos6(32位),4核心cpu,4G内存 ...
- Linux下jvm、tomcat、mysql、log4j优化配置笔记[转]
小菜一直对操作系统心存畏惧,以前也很少接触,这次创业购买了Linux云主机,由于木有人帮忙,只能自己动手优化服务器了.... 小菜的云主机配置大致为:centeos6(32位),4核心cpu,4G内存 ...
- Linux下Tomcat catalina.out自动归档,以及logrotate 配置详解
Linux下Tomcat catalina.out自动归档 如果 catalina.out 日志达到 2GB 大小的时候,Tomcat 因为缓存问题,便没有办法继续输出日志了. 为了避免这种情况,你 ...
- linux下的开源移动图像监测程序--motion编译与配置
前几天在网上偶然看到一篇博客,是利用linxu下的开源的motion搭建嵌入式视频动态监控系统,感觉很好很强大于,是就想自己编译移植一下试试. 所谓移动图像监测,简单来说就是利用摄像头定点监测某个区域 ...
随机推荐
- eclipse[downloads]
下载J2EE:http://www.eclipse.org/downloads/ 下载WPT插件:http://download.eclipse.org/webtools/updates 下载TOMC ...
- 杂乱无章之Oracle(二)
六.IMPDP用法 1.导入表 impdp hsiufo/hsiufo directory=dump_dir dumpfile=full.dmp tables=scott.emp remap_sche ...
- 给力的轻量级JavaScript动画框架 - jsMorph
jsMorph 是一个独立的轻量级 JavaScript 动画框架,可以用它来操纵多个 HTML 元素的样式,实现动画效果.此框架会自动检测起始位置.转换单位.调整渲染的速度,以此来获得更流畅的渲染体 ...
- codeforces Good Bye 2013 379D New Year Letter
题目链接:http://codeforces.com/problemset/problem/379/D [题目大意] 告诉你初始字符串S1.S2的长度和递推次数k, 使用类似斐波纳契数列的字符串合并的 ...
- 剑指Offer03 逆序输出链表&链表逆序
多写了个逆序链表 /************************************************************************* > File Name: ...
- LeetCode 337
House Robber III The thief has found himself a new place for his thievery again. There is only one e ...
- WPF ScrollViewer(滚动条) 自定义样式表制作 再发一套样式 细节优化
艾尼路 出的效果图 本人嵌套 WPF ScrollViewer(滚动条) 自定义样式表制作 图文并茂 WPF ScrollViewer(滚动条) 自定义样式表制作 (改良+美化) 源代码
- CSS其他
1.元素的宽度由内容撑开 display:inline;——不支持高度 display:inline-block;——在IE6下,不支持块标签 float position:absolute——每项设 ...
- Part 2 Creating, altering and dropping a database
A SQL Server database can be created, altered and dropped1. Graphically using SQL Server Management ...
- Part 64 to 66 Talking about Indexers in C#
Part 64 - C# Tutorial - How and where are indexers used in .net Part 65 - C# Tutorial - Indexers in ...