solrCloud+tomcat+zookeeper配置(一)

来源:互联网 发布:linux dracut timeout 编辑:程序博客网 时间:2024/05/16 08:19

感谢有奉献精神的人

转自:http://blog.csdn.net/clj198606061111/article/details/21893005

一、环境准备:

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 XP SP3、JDK 1.6.0_10-rc2

环境规划:

Solr:2个solr服务;单collection,2个shard。每个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新建solr1、solr2文件夹。

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.0为solr。

删除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中加入下面4个jar包。

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在CODE上查看代码片派生到我的代码片
  1. <!--
  2. <env-entry>
  3. <env-entry-name>solr/home</env-entry-name>
  4. <env-entry-value>/put/your/solr/home/here</env-entry-value>
  5. <env-entry-type>java.lang.String</env-entry-type>
  6. </env-entry>
  7. -->

改为:

[html] view plaincopy在CODE上查看代码片派生到我的代码片
  1. <env-entry>
  2. <env-entry-name>solr/home</env-entry-name>
  3. <env-entry-value>D:\\solr_home\\solr1</env-entry-value>
  4. <env-entry-type>java.lang.String</env-entry-type>
  5. </env-entry>

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

[html] view plaincopy在CODE上查看代码片派生到我的代码片
  1. 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里面配置的所有的solrcore到zookeeper,也就是所有的core将被集群管理

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

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

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

[html] view plaincopy在CODE上查看代码片派生到我的代码片
  1. <intname="hostPort">${jetty.port:8983}</int>

改为:

[html] view plaincopy在CODE上查看代码片派生到我的代码片
  1. <intname="hostPort">${jetty.port:8080}</int>

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

[html] view plaincopy在CODE上查看代码片派生到我的代码片
  1. <libdir="../../../contrib/extraction/lib"regex=".*\.jar"/>
  2. <libdir="../../../dist/"regex="solr-cell-\d.*\.jar"/>
  3. <libdir="../../../contrib/clustering/lib/"regex=".*\.jar"/>
  4. <libdir="../../../dist/"regex="solr-clustering-\d.*\.jar"/>
  5. <libdir="../../../contrib/langid/lib/"regex=".*\.jar"/>
  6. <libdir="../../../dist/"regex="solr-langid-\d.*\.jar"/>
  7. <libdir="../../../contrib/velocity/lib"regex=".*\.jar"/>
  8. <libdir="../../../dist/"regex="solr-velocity-\d.*\.jar"/>

改为

[html] view plaincopy在CODE上查看代码片派生到我的代码片
  1. <!--
  2. <libdir="../../../contrib/extraction/lib"regex=".*\.jar"/>
  3. <libdir="../../../dist/"regex="solr-cell-\d.*\.jar"/>
  4. <libdir="../../../contrib/clustering/lib/"regex=".*\.jar"/>
  5. <libdir="../../../dist/"regex="solr-clustering-\d.*\.jar"/>
  6. <libdir="../../../contrib/langid/lib/"regex=".*\.jar"/>
  7. <libdir="../../../dist/"regex="solr-langid-\d.*\.jar"/>
  8. <libdir="../../../contrib/velocity/lib"regex=".*\.jar"/>
  9. <libdir="../../../dist/"regex="solr-velocity-\d.*\.jar"/>
  10. -->

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.0为solr。

删除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中加入下面4个jar包。

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在CODE上查看代码片派生到我的代码片
  1. <!--
  2. <env-entry>
  3. <env-entry-name>solr/home</env-entry-name>
  4. <env-entry-value>/put/your/solr/home/here</env-entry-value>
  5. <env-entry-type>java.lang.String</env-entry-type>
  6. </env-entry>
  7. -->

改为:

[html] view plaincopy在CODE上查看代码片派生到我的代码片
  1. <env-entry>
  2. <env-entry-name>solr/home</env-entry-name>
  3. <env-entry-value>D:\\solr_home\\solr2</env-entry-value>
  4. <env-entry-type>java.lang.String</env-entry-type>
  5. </env-entry>

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

[html] view plaincopy在CODE上查看代码片派生到我的代码片
  1. 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在CODE上查看代码片派生到我的代码片
  1. <intname="hostPort">${jetty.port:8983}</int>

改为:

[html] view plaincopy在CODE上查看代码片派生到我的代码片
  1. <intname="hostPort">${jetty.port:8180}</int>

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

[html] view plaincopy在CODE上查看代码片派生到我的代码片
  1. <libdir="../../../contrib/extraction/lib"regex=".*\.jar"/>
  2. <libdir="../../../dist/"regex="solr-cell-\d.*\.jar"/>
  3. <libdir="../../../contrib/clustering/lib/"regex=".*\.jar"/>
  4. <libdir="../../../dist/"regex="solr-clustering-\d.*\.jar"/>
  5. <libdir="../../../contrib/langid/lib/"regex=".*\.jar"/>
  6. <libdir="../../../dist/"regex="solr-langid-\d.*\.jar"/>
  7. <libdir="../../../contrib/velocity/lib"regex=".*\.jar"/>
  8. <libdir="../../../dist/"regex="solr-velocity-\d.*\.jar"/>

改为

[html] view plaincopy在CODE上查看代码片派生到我的代码片
  1. <!--
  2. <libdir="../../../contrib/extraction/lib"regex=".*\.jar"/>
  3. <libdir="../../../dist/"regex="solr-cell-\d.*\.jar"/>
  4. <libdir="../../../contrib/clustering/lib/"regex=".*\.jar"/>
  5. <libdir="../../../dist/"regex="solr-clustering-\d.*\.jar"/>
  6. <libdir="../../../contrib/langid/lib/"regex=".*\.jar"/>
  7. <libdir="../../../dist/"regex="solr-langid-\d.*\.jar"/>
  8. <libdir="../../../contrib/velocity/lib"regex=".*\.jar"/>
  9. <libdir="../../../dist/"regex="solr-velocity-\d.*\.jar"/>
  10. -->

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

1)8005改为8105。

2)8080改为8180。

3)8443改为8583。

4)8009改为8109。

启动2个tomcat,在浏览器输入地址

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

或者

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

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



参考文献:

http://my.oschina.net/132722/blog/142096

http://blog.csdn.net/shirdrn/article/details/9718387

0 0
原创粉丝点击