linux下搭建solrClou集群搭建(二)
首先准备4个tomcat
[[email protected] ~]# cp -r apache-tomcat-7.0.47 /usr/local/solr-cloud/tomcat01
[[email protected] ~]# cp -r apache-tomcat-7.0.47 /usr/local/solr-cloud/tomcat02
[[email protected] ~]# cp -r apache-tomcat-7.0.47 /usr/local/solr-cloud/tomcat03
[[email protected] ~]# cp -r apache-tomcat-7.0.47 /usr/local/solr-cloud/tomcat04
[[email protected] solr-cloud]# cp -r ../solr/tomcat/webapps/solr/ tomcat02/webapps/
[[email protected] solr-cloud]# cp -r ../solr/tomcat/webapps/solr/ tomcat03/webapps/
[[email protected] solr-cloud]# cp -r ../solr/tomcat/webapps/solr/ tomcat04/webapps/
[[email protected] solr-cloud]# cp -r ../solr/solrhome/ solrhome01---这是之前整合好的solrhome
[[email protected] solr-cloud]# cp -r ../solr/solrhome/ solrhome02
[[email protected] solr-cloud]# cp -r ../solr/solrhome/ solrhome03
[[email protected] solr-cloud]# cp -r ../solr/solrhome/ solrhome04
编写solrhome01下面的solr.xml
<solr>
<solrcloud>
<str name="host">192.168.25.127</str>
<int name="hostPort">8180</int>
<str name="hostContext">${hostContext:solr}</str>
<int name="zkClientTimeout">${zkClientTimeout:30000}</int>
<bool name="genericCoreNodeNames">${genericCoreNodeNames:true}</bool>
</solrcloud>
<shardHandlerFactory name="shardHandlerFactory"
class="HttpShardHandlerFactory">
<int name="socketTimeout">${socketTimeout:0}</int>
<int name="connTimeout">${connTimeout:0}</int>
</shardHandlerFactory>
</solr>
每一个solrhome都要修改
修改此路tomcat下面solr工程下面的web.xml
[[email protected] solr-cloud]# vi tomcat01/webapps/solr/WEB-INF/web.xml
<env-entry>
<env-entry-name>solr/home</env-entry-name>
<env-entry-value>/usr/local/solr-cloud/solrhome01</env-entry-value>
<env-entry-type>java.lang.String</env-entry-type>
</env-entry>
做完以上步骤 tomcat中的solr和solrhome已经建立了联系
现在solr和zookeeper建立联系
修改tomcat/bin目录下面的catalina.sh
在这个注释上面Execute The Requested Command
JAVA_OPTS="-DzkHost=192.168.25.127:2182,192.168.25.127:2183,192.168.25.127:2184"
# ----- Execute The Requested Command -----------------------------------------
其他三个tomcat都要改;
下面要使用一个工具把solrhome下面的conf下面的配置文件上床到zookeeper 让zookeeper管理
在root根目录下面的解压文件 solr-4.10.3/exampel/srcipts/ cloud-scriptscd/zkcli.sh
在[[email protected] cloud-scripts]# 目录下面执行下面的命令
.zkcli.sh -zkhost 192.168.25.127:2182,192.168.25.127:2183,192.168.25.127:2184 -cmd upconfig
-confdir /usr/local/solr-cloud/solrhome01/collection1/conf/ -confname myconf
连接zookeeper的命令
[[email protected] bin]# ./zkCli.sh -server 192.168.25.127:2182

[[email protected] ~]# cp -r apache-tomcat-7.0.47 /usr/local/solr-cloud/tomcat01
[[email protected] ~]# cp -r apache-tomcat-7.0.47 /usr/local/solr-cloud/tomcat02
[[email protected] ~]# cp -r apache-tomcat-7.0.47 /usr/local/solr-cloud/tomcat03
[[email protected] ~]# cp -r apache-tomcat-7.0.47 /usr/local/solr-cloud/tomcat04
因为是在一台电脑上搭建的伪集群 索引这几个tomcat启动的时候 必须的都把端口号修改一下 要不就端口冲突;
四个个tomcat端口号都修改:端口号修改的时候 要有一定的规律
例如
第一个tomcat所涉及的端口号:8005 8080 8009 可以修改8105 8180 8109
第二个tomcat所涉及的端口号:8005 8080 8009 可以修改8205 8280 8209
第三个tomcat所涉及的端口号:8005 8080 8009 可以修改8305 8380 8309
第四个tomcat所涉及的端口号:8005 8080 8009 可以修改8305 8380 8309
见tomcat与solr单机版整合的这编文章
搭建伪集群 建议先把这篇文章的单机版整合搭建一下
http://blog.****.net/weixin_36695293/article/details/77171202
[[email protected] solr-cloud]# cp -r ../solr/tomcat/webapps/solr/ tomcat02/webapps/
[[email protected] solr-cloud]# cp -r ../solr/tomcat/webapps/solr/ tomcat03/webapps/
[[email protected] solr-cloud]# cp -r ../solr/tomcat/webapps/solr/ tomcat04/webapps/
[[email protected] solr-cloud]# cp -r ../solr/solrhome/ solrhome01---这是之前整合好的solrhome
[[email protected] solr-cloud]# cp -r ../solr/solrhome/ solrhome02
[[email protected] solr-cloud]# cp -r ../solr/solrhome/ solrhome03
[[email protected] solr-cloud]# cp -r ../solr/solrhome/ solrhome04
编写solrhome01下面的solr.xml
<solr>
<solrcloud>
<str name="host">192.168.25.127</str>
<int name="hostPort">8180</int>
<str name="hostContext">${hostContext:solr}</str>
<int name="zkClientTimeout">${zkClientTimeout:30000}</int>
<bool name="genericCoreNodeNames">${genericCoreNodeNames:true}</bool>
</solrcloud>
<shardHandlerFactory name="shardHandlerFactory"
class="HttpShardHandlerFactory">
<int name="socketTimeout">${socketTimeout:0}</int>
<int name="connTimeout">${connTimeout:0}</int>
</shardHandlerFactory>
</solr>
每一个solrhome都要修改
修改此路tomcat下面solr工程下面的web.xml
[[email protected] solr-cloud]# vi tomcat01/webapps/solr/WEB-INF/web.xml
<env-entry>
<env-entry-name>solr/home</env-entry-name>
<env-entry-value>/usr/local/solr-cloud/solrhome01</env-entry-value>
<env-entry-type>java.lang.String</env-entry-type>
</env-entry>
做完以上步骤 tomcat中的solr和solrhome已经建立了联系
现在solr和zookeeper建立联系
修改tomcat/bin目录下面的catalina.sh
在这个注释上面Execute The Requested Command
JAVA_OPTS="-DzkHost=192.168.25.127:2182,192.168.25.127:2183,192.168.25.127:2184"
# ----- Execute The Requested Command -----------------------------------------
其他三个tomcat都要改;
下面要使用一个工具把solrhome下面的conf下面的配置文件上床到zookeeper 让zookeeper管理
在root根目录下面的解压文件 solr-4.10.3/exampel/srcipts/ cloud-scriptscd/zkcli.sh
在[[email protected] cloud-scripts]# 目录下面执行下面的命令
.zkcli.sh -zkhost 192.168.25.127:2182,192.168.25.127:2183,192.168.25.127:2184 -cmd upconfig
-confdir /usr/local/solr-cloud/solrhome01/collection1/conf/ -confname myconf
连接zookeeper的命令
[[email protected] bin]# ./zkCli.sh -server 192.168.25.127:2182
把四个tomcat全部重新启动
访问http://192.168.25.127:8480/solr/
如果 刚打开的时候 弹出一个 There exits no core ~cloud 先不要着急 换个浏览器试一下 如果不行 请参考linux下tomcat和solr服务器整合笔记 步骤有木有落下什么
集群分片命令
http://192.168.25.127:8180/solr/admin/collections?action=CREATE&name=collection2&numShards=2&replicationFactor=2
删除collection命令