SolrCloud集群环境搭建

来源:互联网 发布:西安交大网络缴费 编辑:程序博客网 时间:2024/05/16 06:33

系统架构图:

这里写图片描述

一、zookeeper集群搭建

  1. 准备三台机器10.202.39.188、10.202.39.189、10.202.39.190
  2. 准备安装包zookeeper-3.4.9.tar.gz
    tar -zxvf zookeeper-3.4.9.tar.gz解压到/app目录下
  3. 创建数据存放路径:
    mkdir -p /app/data
  4. 配置zoo.cfg文件
    cp zoo_sample.cfg zoo.cfg
    修改配置文件:
# The number of milliseconds of each ticktickTime=2000# The number of ticks that the initial # synchronization phase can takeinitLimit=10# The number of ticks that can pass between # sending a request and getting an acknowledgementsyncLimit=5# the directory where the snapshot is stored.# do not use /tmp for storage, /tmp here is just # example sakes.dataDir=/app/data# the port at which the clients will connectclientPort=2181server.1=10.202.39.188:2881:3881server.2=10.202.39.189:2881:3881server.3=10.202.39.190:2881:3881# the maximum number of client connections.# increase this if you need to handle more clients#maxClientCnxns=60## Be sure to read the maintenance section of the # administrator guide before turning on autopurge.## http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance## The number of snapshots to retain in dataDir#autopurge.snapRetainCount=3# Purge task interval in hours# Set to "0" to disable auto purge feature#autopurge.purgeInterval=1
  1. 创建ServerID标识
    在每台机器上创建/app/data/myid文件
    10.202.39.188赋值为1、10.202.39.189赋值为2、10.202.39.190赋值为3
  2. 分别启动三台zookeeper
    ./app/zookeeper-3.4.9/bin/zkServer.sh start

二、Solr单节点环境搭建

  1. 环境准备
    版本:solr 6.1.0、jdk 1.8 、tomcat8
    四台服务器:10.202.39.184、10.202.39.185、10.202.39.186、10.202.39.187
  2. 安装solr到tomcat
    把 solr-6.1.0\solr-6.1.0\server 下的solr-webapp 文件夹拷贝到tomcat 的webapps下,重命名为solr

  3. 添加jar包
    ·拷贝solr-6.1.0\server\lib\ext 下的jar包到 tomcat\webapps\ ·下solr 项目的WEB-INF\lib下;
    · 拷贝solr-6.1.0\dist下solr-dataimporthandler jar 包、solr-dataimporthandler-extras- 6.1.0.jar 包 到 tomcat\webapps\ 下solr 项目的WEB-INF\lib下;
    ·新增mysql-connector-java-5.1.34.jar到tomcat\webapps\ 下solr 项目的WEB-INF\lib下;

  4. 修改配置
    修改tomcat\webapps\solr(solr的项目名)\WEB-INF\web.xml, 找到如下代码,去掉注释,/put/your/solr/home/here 改为你自己的solrhome的路径, 如:/app/solrhome
<env-entry>       <env-entry-name>solr/home</env-entry-name>       <env-entry-value>/app/solrhome</env-entry-value>       <env-entry-type>java.lang.String</env-entry-type> </env-entry>
  1. 添加日志
    拷贝solr-6.1.0\server\resources下的log4j.properties到tomcat\webapps\solr\WEB-INF\classes,如果WEB-INF下没有classes文件那么就创建一个classes文件夹

三、Solr集群环境搭建

  1. 将10.202.39.185、10.202.39.186、10.202.39.187几台机器按照步骤二搭建单机环境
  2. 把solrhome中的配置文件上传到zookeeper集群
    使用zookeeper的客户端上传,使用solr安装包中的/usr/local/src/solr-6.1.0/server/scripts/cloud-scripts/zkcli.sh
 ./zkcli.sh -zkhost 10.202.39.188:2181,10.202.39.189:2181,10.202.39.190:2181 -cmd upconfig -confdir /app/solrhome/address/conf -confname address
  1. 修改solrhome中solr.xml文件,指定当前实例运行的ip地址及端口号
<solrcloud>    <str name="host">${host:10.202.39.184}</str>    <int name="hostPort">${jetty.port:8080}</int>    <str name="hostContext">${hostContext:solr}</str>    <bool name="genericCoreNodeNames">${genericCoreNodeNames:true}</bool>    <int name="zkClientTimeout">${zkClientTimeout:30000}</int>    <int name="distribUpdateSoTimeout">${distribUpdateSoTimeout:600000}</int>    <int name="distribUpdateConnTimeout">${distribUpdateConnTimeout:60000}</int>    <str name="zkCredentialsProvider">${zkCredentialsProvider:org.apache.solr.common.cloud.DefaultZkCredentialsProvider}</str>    <str name="zkACLProvider">${zkACLProvider:org.apache.solr.common.cloud.DefaultZkACLProvider}</str>  </solrcloud>
  1. 修改每一台solr的tomcat 的 bin目录下catalina.sh文件中加入DzkHost指定zookeeper服务器地址
 JAVA_OPTS="-DzkHost=10.202.39.188:2181,10.202.39.189:2181,10.202.39.190:2181"
1 0
原创粉丝点击