共计 3354 个字符,预计需要花费 9 分钟才能阅读完成。
集群:高可用,备份,数据可分片
需要运行 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
3、修改 16 个配置文件
3.1 solr 中的配置文件
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
3.2 tomcat 中的配置文件
server.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
4、上传配置文件至 zookeeper
调用 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…
5、启动 4 个 tomcat
为方便查看日志,复制四个窗口进行操作,分别切换到各自对应的目录
[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
本文永久更新链接地址 :http://www.linuxidc.com/Linux/2018-01/150381.htm