solrcloud就是solr的集群邑滨,本文將闡述如何搭建solrcloud集群。
1泻肯、前提約束
- 三臺CentOS服務(wù)器
作者的三臺CentOS服務(wù)器ip分別為192.168.100.134、135、136疲吸;且相互ping通 - 三臺機子上已安裝zookeeper集群 http://www.reibang.com/p/48f142f876d4
- 每臺機子都已經(jīng)安裝solr http://www.reibang.com/p/de807e2ef12f
2、修改solr.xml
(1)修改192.168.100.134中的/root/solr-4.10.3/example/solr/solr.xml
<str name="host">${host:}</str>
<int name="hostPort">${jetty.port:8983}</int>
為
<str name="host">192.168.100.134</str>
<int name="hostPort">8080</int>
(2)修改192.168.100.135中的/root/solr-4.10.3/example/solr/solr.xml
<str name="host">${host:}</str>
<int name="hostPort">${jetty.port:8983}</int>
為
<str name="host">192.168.100.135</str>
<int name="hostPort">8080</int>
(3)修改192.168.100.136中的/root/solr-4.10.3/example/solr/solr.xml
<str name="host">${host:}</str>
<int name="hostPort">${jetty.port:8983}</int>
為
<str name="host">192.168.100.136</str>
<int name="hostPort">8080</int>
3前鹅、分別修改三個機子上的/root/apache-tomcat-8.5.38/bin/catalina.sh
在第2行加入:
JAVA_OPTS="-DzkHost=192.168.100.134:2181,192.168.100.135:2181,192.168.100.136:2181"
4摘悴、使用zookeeper統(tǒng)一管理solr配置文件
#進入zookeeper的bin目錄
cd /root/zookeeper-3.4.11/bin/
#上傳solr的配置文件,注意舰绘,上傳一次即可蹂喻,即在一臺機子中執(zhí)行一次就行。
#-zkhost:指定zookeeper的地址列表捂寿;upconfig :上傳配置文件口四;-confdir :指定配置文件所在目錄;-confname:指定上傳到zookeeper后的目錄名秦陋。
/root/solr-4.10.3/example/scripts/cloud-scripts/zkcli.sh -zkhost 192.168.100.134:2181,192.168.100.135:2181,192.168.100.136:2181 -cmd upconfig -confdir /root/solr-4.10.3/example/solr/collection1/conf -confname myconf
5窃祝、分別重新啟動tomcat
在瀏覽器中查看任何一個機子的solr管理界面,例如http://192.168.100.134:8080/solr/#/collection1,會看到以下頁面:
solrcloud多出來一個Cloud
至此粪小,我們完成了solrcloud的搭建大磺。