zoukankan      html  css  js  c++  java
  • solr +zookeeper+tomcat 集群搭建

    最近需要搭建一个cloudSolr集群,写下记录。基础环境是在centos6.5 64bit

    3个下载地址:

    1、 下载Solr-4.x http://lucene.apache.org/solr/downloads.html
    2、下载Tomcat http://tomcat.apache.org/download-70.cgi
    3、下载Zookeeper http://zookeeper.apache.org/releases.html

    第一:安装zookeeper集群

    zookeeper的安装比较简单

    记得关闭防火墙,否则会提示启动失败(重要)
    chkconfig iptables off 重启后生效 
    在zoo.cfg配置文件中
    tickTime=2000
    # The number of ticks that the initial 
    # synchronization phase can take
    initLimit=10
    # The number of ticks that can pass between 
    # sending a request and getting an acknowledgement
    syncLimit=5
    # the directory where the snapshot is stored.
    # do not use /tmp for storage, /tmp here is just 
    # example sakes.
    dataDir=/home/hadoop/package/zookeeper-3.4.5/data
    # the port at which the clients will connect
    clientPort=2181
    server.1=192.168.0.146:2888:3888  
    server.2=192.168.0.142:2888:3888    
    server.3=192.168.0.145:2888:3888
    
    需要修改的:
    dataDir=/home/hadoop/package/zookeeper-3.4.5/data
    里需要创建一个myid文件里面的值是配置文件中server.后的值
    如:server.1=192.168.0.146:2888:3888  里面的值是1 

    第二: 安装tomcat+solr集成

      参照我上篇文章tomcat集成solr

    http://www.cnblogs.com/zhanggl/p/3897105.html

    在主节点147 安装后,复制到148,149 服务器上。

    第三zk和solr+tomcat集成

    修改tomcat 下 配置文件:在主192.168.0.157 服务器上的tomcat 目录下bin的
    配置文件

     JAVA_OPTS = "
    -DzkHost=192.168.0.157:2181,192.168.0.158:2181,192.168.0.159:2181
    -Dbootstrap_confdir=/home/hadoop/package/solrhome/collection1/conf -Dcollection.configName=myconf
    -Dbootstrap_conf=true
    -DnumShards=2"

    在192.168.0.158, 192.168.0.159 服务上的tomcat  bin目录下catalina.sh 添加

    set JAVA_OPTS = -DzkHost=192.168.0.157:2181,192.168.0.158:2181,192.168.0.159:2181

    打开后出现错误提示:

    Loading of "/solr/zookeeper?wt=json" failed (HTTP-Status 404)
    
    "Zookeeper is not configured for this Solr Core. Please try connecting to an alternate zookeeper address."

    将配置文件复制到其他服务器上:

    java -classpath .:/home/hadoop/cloudsolr/tomcat-7.0.55/webapps/solr/WEB-INF/lib/*  org.apache.solr.cloud.ZkCLI -cmd upconfig -zkhost 192.168.0.157:2181,1192.168.0.158:2181,192.168.0.159:2181 -confdir /home/hadoop/cloudsolr/solrhome/collection1/conf  -confname myconf 

    同步到节点:

     java -classpath .:/home/hadoop/cloudsolr/tomcat-7.0.55/webapps/solr/WEB-INF/lib/*  org.apache.solr.cloud.ZkCLI -cmd linkconfig -collection collection1 -confname myconf -zkhost 192.168.0.157:2181,1192.168.0.158:2181,192.168.0.159:2181

    错误提示:log4j:WARN No appenders could be found for logger (org.apache.zookeeper.ZooKeeper).
    log4j:WARN Please initialize the log4j system properly.
    log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

    错误提示

    adoop@slave3 solrlib]$ java -classpath .:/home/hadoop/package/solrlib/*  org.apache.solr.cloud.ZkCLI -cmd upconfig -zkhost 192.168.0.157:2181,192.168.0.158:2181,192.168.0.159:2181 -confdir .:/home/hadoop/package/solrconfig -confname myconf
    Failed to instantiate SLF4J LoggerFactory
    Reported exception:
    java.lang.NoClassDefFoundError: org/apache/log4j/Level
    	at org.slf4j.LoggerFactory.bind(LoggerFactory.java:129)
    	at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:108)
    	at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:302)
    	at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:276)
    	at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:288)
    	at org.apache.solr.common.cloud.SolrZkClient.<clinit>(SolrZkClient.java:72)
    	at org.apache.solr.cloud.ZkCLI.main(ZkCLI.java:175)
    Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Level
    	at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    	... 7 more
    Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/Level
    	at org.slf4j.LoggerFactory.bind(LoggerFactory.java:129)
    	at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:108)
    	at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:302)
    	at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:276)
    	at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:288)
    	at org.apache.solr.common.cloud.SolrZkClient.<clinit>(SolrZkClient.java:72)
    	at org.apache.solr.cloud.ZkCLI.main(ZkCLI.java:175)
    Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Level
    	at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    	at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    	... 7 more
    

     解决办法:下载http://yunpan.cn/cdpSQiMZbfe33 (提取码:49e0) 将jar导入即可

    1、启动的时候错误提示:

    Load collection config from:/collections/collection1
    2465 [coreLoadExecutor-6-thread-1] ERROR org.apache.solr.common.cloud.ZkStateReader  ?.Specified config does not exist in ZooKeeper:collection1
    2469 [coreLoadExecutor-6-thread-1] ERROR org.apache.solr.core.CoreContainer  ?.Error creating core [collection1]: Specified config does not exist in ZooKeeper:collection1
    org.apache.solr.common.cloud.ZooKeeperException: Specified config does not exist in ZooKeeper:collection1

    错误原因:

     启动错误提示:

    HTTP Status 500 - {msg=SolrCore 'collection1' is not available due to init failure: Could not load conf for core collection1:
    Error loading solr config from solr/collection1/conf/solrconfig.xml,trace=org.apache.solr.common.SolrException: SolrCore 'collection1'
    is not available due to init failure: Could not load conf for core collection1: Error loading solr config from solr/collection1/conf/solrconfig.xml at
  • 相关阅读:
    MySQL Cluster --01
    TPCC-MySQL(转自imysql.com)
    MySQL mha 高可用集群搭建
    Redis--初入
    Python之Fabric
    MySQL pt-table-checksum及pt-table-sync校验及修复主从一致性
    MySQL GTID
    MySQL Batched Key Access
    MySQL Block Nested-Loop Join(BNL)
    MySQL Index Condition Pushdown
  • 原文地址:https://www.cnblogs.com/zhanggl/p/4711225.html
Copyright © 2011-2022 走看看