centos tomcat下安装多个solr应用

tomcat安装路径:/usr/local/tomcat/

solr安装路径:/usr/local/solr/

solr.war路径:/usr/local/solr/solr.war(已把IK分词和其他jar包都加入进去)

solr2.war路径:/usr/local/solr/solr2.war(已把IK分词和其他jar包都加入进去)

如果solr.war,solr2.war没有加入IK分词等信息,则手动加入进去。

用7-zip等解压缩软件打开/usr/local/solr/solr.war,找到WEB-INF\lib\目录。

一、把/usr/local/solr/dist/目录下的11个jar包(本文所用的solr4.6版本的下面有11个jar包),拖进打开的war包的WEB-INF\lib\目录(提示覆盖则覆盖)。

二、把IK分词的jar包IKAnalyzer2012FF_u1.jar拖进此目录。

三、任意地方新建一个classes目录,把IK分词的IKAnalyzer.cfg.xml,stopword.dic,ext.dic文件复制到此目录。把classes目录拖到war包的WEB-INF\目录下。

此时solr.war的WEB-INF\目录下的文件结构如下:

classes

          ext.dic

         IKAnalyzer.cfg.xml

         stopword.dic

lib

         xxx.jar

         ......

web.xml

weblogic.xml


1. /usr/local/tomcat/conf/Catalina/localhost/下增加solr.xml,solr2.xml文件。

solr.xml内容如下:

<?xml version="1.0" encoding="UTF-8" ?>
<Context docBase="/usr/local/solr/solr.war" debug="0" crossContext="true">
    <Environment name="solr/home" type="java.lang.String" value="/usr/local/solr/example/solr" override="true" />
</Context>
solr2.xml内容如下:

<?xml version="1.0" encoding="UTF-8" ?>
<Context docBase="/usr/local/solr/solr2.war" debug="0" crossContext="true">
    <Environment name="solr/home" type="java.lang.String" value="/usr/local/solr/example/solr2" override="true" />
</Context>
2. /usr/local/solr/example/目录下有个solr目录(官方下载包里本就存在的目录),修改此目录下的solr.xml文件,配置为多core,内容如下:

<?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 an example of a simple "solr.xml" file for configuring one or 
   more Solr Cores, as well as allowing Cores to be added, removed, and 
   reloaded via HTTP requests.

   More information about options available in this configuration file, 
   and Solr Core administration can be found online:
   http://wiki.apache.org/solr/CoreAdmin
-->

<solr persistent="true">
  <cores adminPath="/admin/cores">
    <core name="collection1" instanceDir="/usr/local/solr/example/solr/collection1/"/>
    
    <core name="core0" instanceDir="/usr/local/solr/example/solr/core0"/>
    
    <core name="core1" instanceDir="/usr/local/solr/example/solr/core1"/>

    <core config="/usr/local/solr/example/solr/core2/conf/solrconfig.xml" name="core2" instanceDir="/usr/local/solr/example/solr/core2/" schema="/usr/local/solr/example/solr/core2/conf/schema.xml" dataDir="/usr/local/solr/example/solr/core2/data/"/>

    <core config="/usr/local/solr/example/solr/core3/conf/solrconfig.xml" name="core3" instanceDir="/usr/local/solr/example/solr/core3/" schema="/usr/local/solr/example/solr/core3/conf/schema.xml" dataDir="/usr/local/solr/example/solr/core3/data/"/>
</cores>
</solr>
其中collection1是官方示例自带的,保留空的放在那不管,以后配置错了或者忘了什么,到collection1的配置中查看。core0,core1,core2,core3是新建的4个core。

复制一份collection1重命名为core0,使用curl执行下面格式的命令可创建一个core(复制下面的命令是不能直接执行的,因为有回车换行,把他们变为一行就可以了)。

创建core
curl http://localhost:8080/solr/admin/cores?action=CREATE
\&name=core0
\&instanceDir=/usr/local/solr/example/solr/core0/
\&dataDir=/usr/local/solr/example/solr/core0/data/
\&config=/usr/local/solr/example/solr/core0/conf/solrconfig.xml
\&schema=/usr/local/solr/example/solr/core0/conf/schema.xml
3. /usr/local/solr/example/solr2/solr.xml文件内容如下:

<?xml version="1.0" encoding="UTF-8" ?>
<solr persistent="true">
  <cores adminPath="/admin/cores">
    <core name="collection1" instanceDir="/usr/local/solr/example/solr2/collection1/"/>
    <core name="core0" instanceDir="/usr/local/solr/example/solr2/core0"/>
    <core name="core1" instanceDir="/usr/local/solr/example/solr2/core1"/>
    <core name="core2" instanceDir="/usr/local/solr/example/solr2/core2/"/>
    <core name="core3" instanceDir="/usr/local/solr/example/solr2/core3/"/>
</cores>
</solr>
solr2应用也创建了4个core(就是solr应用复制一份,改名为solr2,修改下solr.xml配置文件中的路径而已。)


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值