在上一篇文章中(详见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(续)--- 多核索引的配置的更多相关文章

  1. Linux下使用 github+hexo 搭建个人博客03-hexo配置优化

    上两张文章,我们说了 hexo 部署.主题的切换.博文的创建.MarkDown 简单使用和 hexo 部署到 GitHub Pages. 也说了我们会使用 next 主题做为我们后期博客的使用和维护. ...

  2. linux下配置tomcat7 + solr4.9

    一.安装准备 操作系统:CentOS 6.5 tomcat版本:apache-tomcat-7.0.54.tar.gz solr版本:solr-4.9.0.tgz 二.部署实施 安装tomcat:将t ...

  3. Linux下Solr单机版、集群版安装与配置

    一.安装 1.需要的安装包有apache-tomcat-7.0.47.tar.gz.solr-4.10.3.tgz.tgz(jdk自行安装) 这里默认大家已经安装好jdk与tomcat,所以在这里不做 ...

  4. Linux下安装tar.gz类型的jdk,并配置环境变量

    近期因要学习一门技术,必须在Linux下运行,故开始学习如何使用Linux. 在安装jdk时出现了困难,环境变量配置不成功,花了一天时间才搞定,特分享出来,供大家参考. Linux下安装jdk,步骤如 ...

  5. Linux下jvm、tomcat、mysql、log4j优化配置笔记

    小菜一直对操作系统心存畏惧,以前也很少接触,这次创业购买了Linux云主机,由于木有人帮忙,只能自己动手优化服务器了.... 小菜的云主机配置大致为:centeos6(32位),4核心cpu,4G内存 ...

  6. Linux下jvm、tomcat、mysql、log4j优化配置

    小菜一直对操作系统心存畏惧,以前也很少接触,这次创业购买了Linux云主机,由于木有人帮忙,只能自己动手优化服务器了.... 小菜的云主机配置大致为:centeos6(32位),4核心cpu,4G内存 ...

  7. Linux下jvm、tomcat、mysql、log4j优化配置笔记[转]

    小菜一直对操作系统心存畏惧,以前也很少接触,这次创业购买了Linux云主机,由于木有人帮忙,只能自己动手优化服务器了.... 小菜的云主机配置大致为:centeos6(32位),4核心cpu,4G内存 ...

  8. Linux下Tomcat catalina.out自动归档,以及logrotate 配置详解

    Linux下Tomcat catalina.out自动归档 如果 catalina.out 日志达到 2GB 大小的时候,Tomcat 因为缓存问题,便没有办法继续输出日志了.  为了避免这种情况,你 ...

  9. linux下的开源移动图像监测程序--motion编译与配置

    前几天在网上偶然看到一篇博客,是利用linxu下的开源的motion搭建嵌入式视频动态监控系统,感觉很好很强大于,是就想自己编译移植一下试试. 所谓移动图像监测,简单来说就是利用摄像头定点监测某个区域 ...

随机推荐

  1. find your present (2)

    Problem Description In the new year party, everybody will get a "special present".Now it's ...

  2. web 项目 布在tomcat服务器上出现的问题小记

    1.mysql  安装前需要安装.net framework 框架 mysql  无法安装  最后一布,start server 服务起不来. 原因,为上一次mysql没有删除,干净,导入无法安装. ...

  3. XACML-PolicySet与request结构简介

    本文由@呆代待殆原创,转载请注明出处. 一.PolicySet的结构 PolicySet 的基本嵌套结构如上图所示,下面让我们一个一个来说明. PolicySet:XACML策略架构的顶层元素,由Po ...

  4. KDE声音服务器 arts

    KDE声音服务器 arts arts介绍arts是KDE的核心声音系统,支持多音频流.全双工.网络声音请求.ALSA与OSS驱动后端.JACK声音服务器后端等扩展,它既是声音服务器,也 提供一套音频软 ...

  5. [转]在PHP语言中使用JSON

    本文转自:http://www.ruanyifeng.com/blog/2011/01/json_in_php.html 作者: 阮一峰 日期: 2011年1月14日 目前,JSON已经成为最流行的数 ...

  6. 剑指Offer36 数字在排序数组中出现的次数

    /************************************************************************* > File Name: 36_Number ...

  7. codeforces 677C C. Vanya and Label(组合数学+快速幂)

    题目链接: C. Vanya and Label time limit per test 1 second memory limit per test 256 megabytes input stan ...

  8. TortoiseSVN 更新时忽略指定文件夹

    命令行可以这么来svn update –set-depth=exclude 文件夹 那么TortoiseSVN客户端呢?在文件夹右键中的”更新至版本(U)”更新深度选”排除”,确定,搞定下次更新就不会 ...

  9. java初级开发中的报错问题

      1.典例1 错误原因:?useUnicode=true&characterEncoding=UTxF8 纠错:其中的? 是汉语的 2.典例2 纠错原因:数据库没有打开 纠错: 我的电脑-- ...

  10. Javascript常见操作

    图片预加载 var image = new Image();image.onload = onLoad;image.onerror = onLoad;image.src =src; image.com ...