最新版solr7.2集群搭建详细步骤
需要运行4个tomcat
1、tomcat端口号(默认占用8005,8009,8080三个端口)tomcat服务
占用端口
tomcat1
6005、6060、6009
tomcat2
7005、7070、7009
tomcat3
8005、8080、8009
tomcat4
9005、9090、9009
2、创建solr集群目录,将单节点的solr复制共计4份至该目录创建目录
[root@node004 ]# mkdir -p /usr/local/solrCloud
复制单节点
[root@node004 ~]# cp /usr/local/solr /usr/local/solrCloud/solr1 -rf
[root@node004 ~]# cp /usr/local/solr /usr/local/solrCloud/solr2 -rf
[root@node004 ~]# cp /usr/local/solr /usr/local/solrCloud/solr3 -rf
[root@node004 ~]# cp /usr/local/solr /usr/local/solrCloud/solr4 -rf
注意:删除每个solrhome实例目录下的core.properties
[root@node004 ~]# rm /usr/local/solrCloud/solr1/home/jonychen/core.properties -rf
[root@node004 ~]# rm /usr/local/solrCloud/solr2/home/jonychen/core.properties -rf
[root@node004 ~]# rm /usr/local/solrCloud/solr3/home/jonychen/core.properties -rf
[root@node004 ~]# rm /usr/local/solrCloud/solr4/home/jonychen/core.properties -rf
solr.xml
[root@node004 ~]# vi /usr/local/solrCloud/solr1/home/solr.xml
[root@node004 ~]# vi /usr/local/solrCloud/solr2/home/solr.xml
[root@node004 ~]# vi /usr/local/solrCloud/solr3/home/solr.xml
[root@node004 ~]# vi /usr/local/solrCloud/solr4/home/solr.xml
[root@node004 ~]# vi /usr/local/solrCloud/solr1/apache-tomcat-8.5.24/conf/server.xml
[root@node004 ~]# vi /usr/local/solrCloud/solr2/apache-tomcat-8.5.24/conf/server.xml
[root@node004 ~]# vi /usr/local/solrCloud/solr3/apache-tomcat-8.5.24/conf/server.xml
[root@node004 ~]# vi /usr/local/solrCloud/solr4/apache-tomcat-8.5.24/conf/server.xml
web.xml
[root@node004 ~]# vi /usr/local/solrCloud/solr1/apache-tomcat-8.5.24/webapps/solr/WEB-INF/web.xml
[root@node004 ~]# vi /usr/local/solrCloud/solr2/apache-tomcat-8.5.24/webapps/solr/WEB-INF/web.xml
[root@node004 ~]# vi /usr/local/solrCloud/solr3/apache-tomcat-8.5.24/webapps/solr/WEB-INF/web.xml
[root@node004 ~]# vi /usr/local/solrCloud/solr4/apache-tomcat-8.5.24/webapps/solr/WEB-INF/web.xml
catalina.sh
[root@node004 ~]# vi /usr/local/solrCloud/solr1/apache-tomcat-8.5.24/bin/catalina.sh
[root@node004 ~]# vi /usr/local/solrCloud/solr2/apache-tomcat-8.5.24/bin/catalina.sh
[root@node004 ~]# vi /usr/local/solrCloud/solr3/apache-tomcat-8.5.24/bin/catalina.sh
[root@node004 ~]# vi /usr/local/solrCloud/solr4/apache-tomcat-8.5.24/bin/catalina.sh
调用solr解压目录zkCli.sh上传配置文件
[root@node004 ~]# cd /root/solr-7.2.0/server/scripts/cloud-scripts/ [root@node004 cloud-scripts]# ls log4j.properties snapshotscli.sh zkcli.bat zkcli.sh [root@node004 cloud-scripts]# ./zkcli.sh -zkhost 192.168.178.161:2181,192.168.178.161:2182,192.168.178.161:2183 -cmd upconfig -confdir /usr/local/s olrCloud/solr1/home/jonychen/conf/ -confname jonychen
查看是否上传成功
[root@node001 ~]# /usr/local/zkCluster/zk1/bin/zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /usr/local/zkCluster/zk1/bin/../conf/zoo.cfg
Mode: follower
[root@node001 ~]# /usr/local/zkCluster/zk1/bin/zkCli.sh
有configs则说明上传成功
[zk: localhost:2181(CONNECTED) 1] quit
Quitting...
为方便查看日志,复制四个窗口进行操作,分别切换到各自对应的目录
[root@node004 ~]# cd /usr/local/solrCloud/solr1
[root@node004 solr1]# ls
apache-tomcat-8.5.24 home logs
[root@node004 solr1]# ./apache-tomcat-8.5.24/bin/startup.sh && tailf ./apache-tomcat-8.5.24/logs/catalina.out
启动成功界面
6、创建集群
创建
http://192.168.178.164:6060/solr/admin/collections?action=CREATE&name=jonychen&numShards=2&replicationFactor=2
删除
http://192.168.178.164:6060/solr/admin/collections?action=DELETE&name=jonychen