美文网首页
分布式环境搭建4--安装Solr集群

分布式环境搭建4--安装Solr集群

作者: Nil_Woo | 来源:发表于2017-05-16 12:48 被阅读0次

4、安装Solr集群

  • 下载
wget https://mirrors.tuna.tsinghua.edu.cn/apache/lucene/solr/6.5.1/solr-6.5.0.tgz
  • 安装依赖
yum install -y lsof
  • 解压&复制文件到tomcat下
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
  • 编辑web.xml文件
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>
-->
  • 配置tomcat到zookeeper
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
  • 创建&删除Collection
# 创建
# 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

相关文章

网友评论

      本文标题:分布式环境搭建4--安装Solr集群

      本文链接:https://www.haomeiwen.com/subject/lqllxxtx.html