solrCloud+tomcat+zookeeper配置

一、环境准备:

Solr版本:4.7.0

下载地址:http://www.apache.org/dyn/closer.cgi/lucene/solr/4.7.0

 

Tomcat版本:6.0.39

下载地址:http://tomcat.apache.org/download-60.cgi

 

ZooKeeer版本:3.4.6

下载地址:http://www.apache.org/dyn/closer.cgi/zookeeper/

 

二、配置

实验环境:

   Windows JDK 1.6.0_10-rc2

环境规划:

Solr2solr服务;单collection2shard。每个shard一个reception

ZooKeeper:单个ZooKeeper服务。

 

1  配置ZooKeeper

D盘根目录建立一个ZooKeeper文件夹。

把下载的ZooKeeper发布包解压D:\ZooKeeper,重命名为server1

D:\ZooKeeper\server1目录下新建一个data文件夹。

D:\ZooKeeper\server1\conf下面的zoo_sample.cfg文件改名为zoo.cfg

修改zoo.cfg配置文件dataDir=/tmp/zookeeper改为dataDir=D:\\ZooKeeper\\server1\\data

完成上面操作,便完成了ZooKeeper的配置了。

进入D:\ZooKeeper\server1\bin,双击zkServer.cmd便可以启动ZooKeeper

 

2  配置solr+tomcat

D盘新建一个tomcat文件夹。

D盘新建一个solr_home文件夹。

D:\solr_home新建solr1solr2文件夹。

 

2.1配置第一个solr

把下载的tomcat发布包解压到D:\tomcat,重命名为tomcat6.0.39_solr_01

solr发布包下的solr-4.7.0\dist\solr-4.7.0.war

复制到D:\tomcat\tomcat6.0.39_solr_01\webapps下面。

D:\tomcat\tomcat6.0.39_solr_01\webapps\solr-4.7.0.war解压到

D:\tomcat\tomcat6.0.39_solr_01\webapps下面,重命名solr-4.7.0solr

删除D:\tomcat\tomcat6.0.39_solr_01\webapps\solr-4.7.0.war

 

D:\tomcat\tomcat6.0.39_solr_01\webapps\solr\WEB-INF\lib中加入下面4jar包。

1  commons-logging-1.1.jar

2  slf4j-log4j12-1.6.6.jar

3  slf4j-api-1.6.6.jar

4  dom4j-1.6.1.jar

修改D:\tomcat\tomcat6.0.39_solr_01\webapps\solr\WEB-INF\web.xml

[html] view plaincopy

<!--  

  <env-entry>  

     <env-entry-name>solr/home</env-entry-name>  

     <env-entry-value>/put/your/solr/home/here</env-entry-value>  

     <env-entry-type>java.lang.String</env-entry-type>  

  </env-entry>  

 -->  

 

改为:

[html] view plaincopy

<env-entry>  

   <env-entry-name>solr/home</env-entry-name>  

   <env-entry-value>D:\\solr_home\\solr1</env-entry-value>  

   <env-entry-type>java.lang.String</env-entry-type>  

</env-entry>  

 

修改D:\tomcat\tomcat6.0.39_solr_01\bin\catalina.bat,在第二行加入如下这段配置:

[html] view plaincopy

set "JAVA_OPTS=-server -Xmx1024m -Xms256m -DzkHost=127.0.0.1:2181 -Dbootstrap_conf=true  -DnumShards=2"  

 

-DzkHost来指定zookeeper地址

zookeeper是集群,应该写成 -DzkHost=localhost:9983,localhost:8574,localhost:9900

bootstrap_conf=true将会上传你在web.xml里面solr/home里配置的数据目录下面solr.xml里面配置的所有的solrcorezookeeper,也就是所有的core将被集群管理

-DnumShards=2是指定我的集群分为两个shard

solr发布包\solr-4.7.0\example\solr下所有文件复制到D:\solr_home\solr1下面。

修改D:\solr_home\solr1\solr.xml

[html] view plaincopy

<int name="hostPort">${jetty.port:8983}</int>  

 

改为:

[html] view plaincopy

<int name="hostPort">${jetty.port:8080}</int>  

 

修改D:\solr_home\solr1\collection1\conf\solrconfig.xml

[html] view plaincopy

<lib dir="../../../contrib/extraction/lib" regex=".*\.jar" />  

<lib dir="../../../dist/" regex="solr-cell-\d.*\.jar" />  

  

<lib dir="../../../contrib/clustering/lib/" regex=".*\.jar" />  

<lib dir="../../../dist/" regex="solr-clustering-\d.*\.jar" />  

  

<lib dir="../../../contrib/langid/lib/" regex=".*\.jar" />  

<lib dir="../../../dist/" regex="solr-langid-\d.*\.jar" />  

  

<lib dir="../../../contrib/velocity/lib" regex=".*\.jar" />  

<lib dir="../../../dist/" regex="solr-velocity-\d.*\.jar" />  

 

改为

[html] view plaincopy

  <!--  

    <lib dir="../../../contrib/extraction/lib" regex=".*\.jar" />  

<lib dir="../../../dist/" regex="solr-cell-\d.*\.jar" />  

  

<lib dir="../../../contrib/clustering/lib/" regex=".*\.jar" />  

<lib dir="../../../dist/" regex="solr-clustering-\d.*\.jar" />  

  

<lib dir="../../../contrib/langid/lib/" regex=".*\.jar" />  

<lib dir="../../../dist/" regex="solr-langid-\d.*\.jar" />  

  

<lib dir="../../../contrib/velocity/lib" regex=".*\.jar" />  

<lib dir="../../../dist/" regex="solr-velocity-\d.*\.jar" />  

  -->  

 

2.2配置第二个solr

把下载的tomcat发布包解压到D:\tomcat,重命名为tomcat6.0.39_solr_02

solr发布包下的solr-4.7.0\dist\solr-4.7.0.war

复制到D:\tomcat\tomcat6.0.39_solr_02\webapps下面。

D:\tomcat\tomcat6.0.39_solr_02\webapps\solr-4.7.0.war解压到

D:\tomcat\tomcat6.0.39_solr_02\webapps下面,重命名solr-4.7.0solr

删除D:\tomcat\tomcat6.0.39_solr_02\webapps\solr-4.7.0.war

 

D:\tomcat\tomcat6.0.39_solr_02\webapps\solr\WEB-INF\lib中加入下面4jar包。

1  commons-logging-1.1.jar

2  slf4j-log4j12-1.6.6.jar

3  slf4j-api-1.6.6.jar

4  dom4j-1.6.1.jar

修改D:\tomcat\tomcat6.0.39_solr_02\webapps\solr\WEB-INF\web.xml

[html] view plaincopy

<!--  

  <env-entry>  

     <env-entry-name>solr/home</env-entry-name>  

     <env-entry-value>/put/your/solr/home/here</env-entry-value>  

     <env-entry-type>java.lang.String</env-entry-type>  

  </env-entry>  

 -->  

 

改为:

[html] view plaincopy

<env-entry>  

  

   <env-entry-name>solr/home</env-entry-name>  

  

   <env-entry-value>D:\\solr_home\\solr2</env-entry-value>  

  

   <env-entry-type>java.lang.String</env-entry-type>  

 </env-entry>  


修改D:\tomcat\tomcat6.0.39_solr_02\bin\catalina.bat,在第二行加入如下这段配置:

[html] view plaincopy

set "JAVA_OPTS=-server -Xmx1024m -Xms256m  -DzkHost=127.0.0.1:2181  -DnumShards=2"  

 

solr发布包\solr-4.7.0\example\solr下所有文件复制到D:\solr_home\solr2下面。

 

修改D:\solr_home\solr1\solr.xml

[html] view plaincopy

<int name="hostPort">${jetty.port:8983}</int>  

 

改为:

[html] view plaincopy

<int name="hostPort">${jetty.port:8180}</int>  

 

修改D:\solr_home\solr1\collection1\conf\solrconfig.xml

[html] view plaincopy

  <lib dir="../../../contrib/extraction/lib" regex=".*\.jar" />  

<lib dir="../../../dist/" regex="solr-cell-\d.*\.jar" />  

  

<lib dir="../../../contrib/clustering/lib/" regex=".*\.jar" />  

<lib dir="../../../dist/" regex="solr-clustering-\d.*\.jar" />  

  

<lib dir="../../../contrib/langid/lib/" regex=".*\.jar" />  

<lib dir="../../../dist/" regex="solr-langid-\d.*\.jar" />  

  

<lib dir="../../../contrib/velocity/lib" regex=".*\.jar" />  

<lib dir="../../../dist/" regex="solr-velocity-\d.*\.jar" />  

 

改为

[html] view plaincopy

<!--  

      <lib dir="../../../contrib/extraction/lib" regex=".*\.jar" />  

  <lib dir="../../../dist/" regex="solr-cell-\d.*\.jar" />  

  

  <lib dir="../../../contrib/clustering/lib/" regex=".*\.jar" />  

  <lib dir="../../../dist/" regex="solr-clustering-\d.*\.jar" />  

  

  <lib dir="../../../contrib/langid/lib/" regex=".*\.jar" />  

  <lib dir="../../../dist/" regex="solr-langid-\d.*\.jar" />  

  

  <lib dir="../../../contrib/velocity/lib" regex=".*\.jar" />  

  <lib dir="../../../dist/" regex="solr-velocity-\d.*\.jar" />  

    -->  

 

修改D:\tomcat\tomcat6.0.39_solr_02\conf\server.xml各端口,避免和solr1tomcat端口冲突。

18005改为8105

28080改为8180

38443改为8583

48009改为8109

 

 1、启动zk

2、分别启动2tomcat,在浏览器输入地址

http://localhost:8080/solr/#/~cloud

或者

http://localhost:8180/solr/#/~cloud

便可以看到如下图solr集群服务了。


添加用户权限:

1、在tomcat-users.xml下添加

    <user password="admin" roles="manager-script,admin" username="admin"/>
    
    <role rolename="solr"/>
    <user username="admin" password="123456" roles="solr"/>

2、在solr\web-inf\web.xml

 <security-constraint>
    <web-resource-collection>
        <web-resource-name>Solr Lockdown</web-resource-name>
        <url-pattern>/</url-pattern>        
    </web-resource-collection>
    <auth-constraint>
        <role-name>solr</role-name>
        <role-name>admin</role-name>
    </auth-constraint>
    </security-constraint>
    
    <login-config>
        <auth-method>BASIC</auth-method>
        <realm-name>Solr></realm-name>
    </login-config>

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值