最近需要搭建一個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