4、安装Solr集群
wget https://mirrors.tuna.tsinghua.edu.cn/apache/lucene/solr/6.5.1/solr-6.5.0.tgz
yum install -y lsof
tar -vxzf solr-6.5.0.tgz
cp -R ~/solr-6.5.0/server/solr-webapp/webapp /usr/local/tomcat/webapps/solr
cp -R ~/solr-6.5.0/server/lib/ext/* /usr/local/tomcat/webapps/solr/WEB-INF/lib/
cp -R ~/solr-6.5.0/server/lib/metrics*.* /usr/local/tomcat/webapps/solr/WEB-INF/lib/
cp ~/solr-6.5.0/dist/solr-dataimporthandler-* /usr/local/tomcat/webapps/solr/WEB-INF/lib/
mkdir /usr/local/tomcat/webapps/solr/WEB-INF/classes
cp ~/solr-6.5.0/server/resources/log4j.properties /usr/local/tomcat/webapps/solr/WEB-INF/classes/
# 创建solr home 目录
mkdir /var/solr
cp -R ~/solr-6.5.0/server/solr/* /var/solr
vi /usr/local/tomcat/webapps/solr/WEB-INF/web.xml
<env-entry>
<env-entry-name>solr/home</env-entry-name>
<!-- 填写上一步创建的solr home目录 -->
<env-entry-value>/var/solr</env-entry-value>
<env-entry-type>java.lang.String</env-entry-type>
</env-entry>
<!-- 以下内容注释掉 -->
<!--
<security-constraint>
<web-resource-collection>
<web-resource-name>Disable TRACE</web-resource-name>
<url-pattern>/</url-pattern>
<http-method>TRACE</http-method>
</web-resource-collection>
<auth-constraint/>
</security-constraint>
<security-constraint>
<web-resource-collection>
<web-resource-name>Enable everything but TRACE</web-resource-name>
<url-pattern>/</url-pattern>
<http-method-omission>TRACE</http-method-omission>
</web-resource-collection>
</security-constraint>
-->
vi /usr/local/tomcat/bin/catalina.sh
JAVA_OPTS="-DzkHost=node1:2181,node2:2182,node3:2183" #zookeeper集群的地址
java -classpath :/usr/local/tomcat/webapps/solr/WEB-INF/lib/* org.apache.solr.cloud.ZkCLI -cmd upconfig -zkhost node1:2181,node2:2181,node3:2181 -cmd upconfig -confdir ~/solr-6.5.0/example/example-DIH/solr/solr/conf/ -confname myconf
# 创建
# numShards指分几个片区
# replicationFactor 每个片区分配几个节点
# maxShardsPerNode 最多分配几个节点
http://node1:9080/solr/admin/collections?action=CREATE&name=collection&numShards=2&replicationFactor=3&maxShardsPerNode=6
# 删除
http://node1:9080/solr/admin/collections?action=DELETE&name=collection