SolrCloud安裝手冊(cè)_基于solr5.2.1_第1頁(yè)
SolrCloud安裝手冊(cè)_基于solr5.2.1_第2頁(yè)
SolrCloud安裝手冊(cè)_基于solr5.2.1_第3頁(yè)
SolrCloud安裝手冊(cè)_基于solr5.2.1_第4頁(yè)
SolrCloud安裝手冊(cè)_基于solr5.2.1_第5頁(yè)
已閱讀5頁(yè),還剩11頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、solrCloud集群安裝手冊(cè)基于solr5.2.1版本號(hào)修訂內(nèi)容修訂人時(shí)間1.0安裝步驟、架構(gòu)設(shè)計(jì),索引服務(wù)、分片備份高揚(yáng)20150722一、 solrCloud集群架構(gòu)概覽1.1 SolrCloud索引架構(gòu)其中每一個(gè)分片有兩份數(shù)據(jù),一個(gè)是leader,另一個(gè)是備份。分別存儲(chǔ)在不同機(jī)器上,可以保證在某一臺(tái)服務(wù)器down掉后,仍可提供完整的數(shù)據(jù)服務(wù)。 SolrCloud的索引存儲(chǔ)中,三臺(tái)服務(wù)器都要存索引。1.2 ZooKeeper架構(gòu)ZooKeeper集群,同時(shí)在三臺(tái)服務(wù)器中配置ZooKeeper。二、 硬件環(huán)境硬件版本JDKJDK-1.8SolrSolr-5.2.1ZooKeeperzook

2、eeper-3.4.6tomcatapache-tomcat-8.0.14mysqlmysql-5.6.25服務(wù)器linux三、 安裝步驟3.1 JDK配置(1)解壓JDK的壓縮包至 /usr/local/ 目錄下tar -zxvf JDK壓縮包位置 -C /usr/local/(2)修改配置文件vi /etc/profile在下面添加如下內(nèi)容export JAVA_HOME=/usr/local/jdk1.8.0_45export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jarexport PATH=$JAVA_HOME/bin:$PA

3、TH然后在命令行中輸入 source /etc/profile輸入命令 java -version 查看是否安裝正確3.2 Tomcat配置(1)解壓tomcat的壓縮包至 /home/dell/software 目錄下tar zxvf apache-tomcat-8.0.14.tar.gz(2)運(yùn)行tomcat中的startup.sh運(yùn)行tomcat(3)由于防火墻的原因無(wú)法訪問(wèn)8080端口,以下步驟為開(kāi)放8080端口:/sbin/iptables -I INPUT -p tcp -dport 8080 -j ACCEPTservice iptables saveservice iptabl

4、es restart或者直接禁用防火墻:停止/啟動(dòng)防火墻/sbin/service iptables restart -重啟/sbin/service iptables stop -停止/sbin/service iptables start -啟動(dòng)1) 重啟后生效 開(kāi)啟: chkconfig iptables on 關(guān)閉: chkconfig iptables off2) 即時(shí)生效,重啟后失效 開(kāi)啟: service iptables start 關(guān)閉: service iptables stop然后訪問(wèn)服務(wù)器的8080端口查看tomcat是否安裝正確。(4)修改tomcat中conf/se

5、rver.xml文件。找到以下部分修改為 3.3 Mysql配置(可參考網(wǎng)站(1)在線安裝mysqlyum install -y mysql-server mysql mysql-devel查看已安裝版本命令rpm -qi mysql-server開(kāi)啟MySQL服務(wù)/etc/init.d/mysqld start(2)修改MySQL中root初始密碼安裝MySQL成功后root初始密碼為空進(jìn)入MySQL界面命令:mysql -u root -p輸入quit;退出mysql修改初始化密碼命令:mysqladmin-u用戶(hù)名-p舊密碼password新密碼如:mysqladmin -u root

6、password密碼(3)實(shí)現(xiàn)MySQL遠(yuǎn)程連接進(jìn)入MySQL界面 (myuser替換為用戶(hù)名, mypassword替換為密碼)mysql GRANT ALL PRIVILEGES ON *.* TO myuser% IDENTIFIED BY mypassword WITH GRANT OPTION;(4)開(kāi)啟MySQL服務(wù)自動(dòng)開(kāi)啟命令chkconfig mysqld on查看MySQL服務(wù)是否自動(dòng)開(kāi)啟命令chkconfig -list | grep mysqld(5)重啟mysql/etc/init.d/mysqld restart3.4 Solr配置(1)我們這里使用solr-5.2.

7、1版本。 解壓縮solr-5.2.1.tgz,得到solr-5.2.1文件夾。(2)將solr-5.2.1/server/webapps/ solr.war復(fù)制到tomcat的webapps文件夾下,啟動(dòng)tomcat $tomcat_home/bin/startup.sh ,webapps下自動(dòng)生成solr目錄。關(guān)閉tomcat,刪除solr.war包。(3)將solr-5.2.1/dist/目錄下的solr-dataimporthandler-5.2.1.jar和solr-dataimporthandler-extras-5.2.1.jar復(fù)制到tomcat下的solr/WEB-INF/li

8、b中。將solr-5.2.1/server/lib/ext目錄下的jar文件復(fù)制到tomcat下的solr/WEB-INF/lib中。另外,將mysql-connector-java-5.1.31-bin.jar和IK-Analyzer-ForSolr5.jar復(fù)制到solr/WEB-INF/lib中。(注意:solr5后的版本與IK最新的分詞器不兼容,因此特別訂定制了IK,見(jiàn)附件)IK-Analyzer-ForSolr5.jar是中文分詞器mysql-connector-java-5.1.26-bin.jar是java連接mysql數(shù)據(jù)庫(kù)的驅(qū)動(dòng)打開(kāi)apache-tomcat-8.0.14/w

9、ebapps/solr/WEB-INF/web.xml修改如下部分 !- solr/home /put/your/solr/home/here java.lang.String -改為 solr/home /home/dell/software/solrhome/ java.lang.String注意:要將注釋符號(hào)去掉(4)將solr-5.2.1/server/solr/solr.xml復(fù)制到/home/dell/software/solrhome 目錄下。將jetty.port改為8080。注意:這個(gè)8080是我們創(chuàng)建collection以及分片用的服務(wù)端口。而不是用來(lái)指向tomcat的80

10、80端口。$host: $jetty.port:8080 $hostContext:solr(5)在apache-tomcat-8.0.14/webapps/solr/WEB-INF下新建classes文件夾,將solr-5.2.1/server/resources下的perties文件COPY到classes文件夾下。這個(gè)是solr的日志文件,方便solr出錯(cuò)的時(shí)候查看日志進(jìn)行解決。打開(kāi)perties,配置日志文件路徑log4j.appender.file.File=/home/dell/software/solrhome/logs/solr.log(6)

11、運(yùn)行tomcat,訪問(wèn)01:8080/solr 查看是否安裝正確。3.5 ZooKeeper配置(可參考這里以三臺(tái)計(jì)算機(jī)為例,分別為89 master43 slave102 slave2可修改配置文件/etc/hosts,添加89 master43 slave102 slave2(每臺(tái)機(jī)器hosts文件此處配置部分保持一致)然后運(yùn)行命令source /etc/hosts即可用master代替8

12、9 等等(1)將ZooKeeper-3.4.6壓縮包解壓至/home/dell/software/ 目錄下。進(jìn)入ZooKeeper-3.4.6文件夾,在ZooKeeper-3.4.6文件夾中創(chuàng)建data文件夾和logs文件夾。(2)在ZooKeeper-3.4.6/conf文件夾中創(chuàng)建文件zoo.cfg。vi conf/zoo.cfg在zoo.cfg中,輸入tickTime=2000dataDir=/home/dell/software/zookeeper-3.4.6/datadataLogDir=/home/dell/software/zookeeper-3.4.6/logsclientPo

13、rt=2181initLimit=5syncLimit=2server.1=master:2888:3888server.2=slave1:2888:3888server.3=slave2:2888:3888server.X=A:B:C 其中X是一個(gè)數(shù)字, 表示這是第幾號(hào)server。A是該server所在的IP地址.。B配置該server和集群中的leader交換消息所使用的端口。C配置選舉leader時(shí)所使用的端口。(3)在之前創(chuàng)建的data文件夾中創(chuàng)建一個(gè)myid文件。寫(xiě)入一個(gè)數(shù)字,該數(shù)字表示這是第幾號(hào)server。該數(shù)字必須和zoo.cfg文件中的server.X中的X一一對(duì)應(yīng)。即,若

14、本機(jī)是server.1,則寫(xiě)入1 。3.6 SolrCloud集成配置(可參考(1)任選一臺(tái)機(jī)器上(如89)創(chuàng)建SolrCloud配置文件目錄/home/dell/software/solrconfig_files和Solr Zk CLI庫(kù)文件目錄/home/dell/software/solrlib_files(2)將solr-5.2.1/server/solr/configsets/sample_techproducts_configs/conf下的solr票配置文件Copy到SolrCloud配置文件目錄solrconfig_files中將tomcat/webap

15、ps中的solr WEB-INF/lib中的jar文件Copy到Solr Zk CLI庫(kù)文件目錄solrlib_files中(3)打開(kāi)三臺(tái)服務(wù)器的zookeeperzookeeper-3.4.6/bin/zkServer.sh start將SolrCloud的配置文件上傳到ZooKeeper中,在命令行中輸入java -classpath .:/home/dell/software/solrlib_files/* org.apache.solr.cloud.ZkCLI -cmd upconfig -zkhost 89:2181,43:2181,1

16、02:2181 -confdir /home/dell/software/solrconfig_files/ -confname iipconf可使用次配置直接創(chuàng)建collection,在瀏覽器中輸入89:8080/solr/admin/collections?action=create&name=collection1&numShards=3&replicationFactor=2&maxShardsPerNode=2&collection.configName=iipconf這條指令的各參數(shù)意義如下:參數(shù)名說(shuō)明Name要?jiǎng)?chuàng)建的集合名

17、稱(chēng)numShards指定集合Shard的數(shù)量replicationFactor指定每個(gè)Shard副本數(shù)量maxShardsPerNode每個(gè)Solr服務(wù)器節(jié)點(diǎn)上最大Shard數(shù)量createNodeSet還不明白什么用collection.configName配置的名稱(chēng)(必須已存儲(chǔ)在ZooKeeper)使用這個(gè)新的集合。如果沒(méi)有提供創(chuàng)建操作將默認(rèn)配置名稱(chēng)的集合名稱(chēng)??蛇B上zookeeper,查看配置信息cd zookeeper/bin./zkCli.sh -server localhost:2181執(zhí)行查詢(xún)命令: ls /configs/myconf,即可看到上傳到ZooKeeper的所有配置

18、信息也可在命令行中輸入指令改變某一collection的配置,java -classpath .:/home/dell/software/solrlib_files/* org.apache.solr.cloud.ZkCLI -cmd linkconfig -collection collection1 -confname conf1 -zkhost 89:2181,43:2181,02:2181(4)進(jìn)入tomcat目錄下,修改bin/catalina.sh在開(kāi)頭的注釋之后# OS specific support. $

19、var _must_ be set to either true or false.的上面添加一行:export JAVA_OPTS=$JAVA_OPTS -DzkHost=master:2181,slave1:2181,slave2:2181(5)啟動(dòng)各服務(wù)器的tomcat: apache-tomcat-8.0.14/bin/startup.sh訪問(wèn)solr管理頁(yè): 89:8080/solr 查看狀態(tài)四、SolrCloud定時(shí)增量索引(完全無(wú)人值守)4.1 簡(jiǎn)介Solr官方提供了很強(qiáng)大的Data Import Request Handler,同時(shí)提供了一個(gè)

20、簡(jiǎn)單的 Scheduler,Url:/solr/DataImportHandler.(原定時(shí)器作者是:Marko Bonaci, 在此表示感謝!)The original Scheduling source by Marko Bonaci, Thank him!4.2 使用說(shuō)明將 apache-solr-dataimportscheduler-modified.jar(官方提供的dataimportscheduler有POST BUG請(qǐng)使用該修正版,jar包在附件當(dāng)中) 和solr自帶的 apache-solr-dataimporthandler-.j

21、ar, apache-solr-dataimporthandler-extras-.jar 放到tomcat/solr/WEB-INF的lib目錄下面修改solr.war中WEB-INF/web.xml, 在servlet節(jié)點(diǎn)前面增加: org.apache.solr.handler.dataimport.scheduler.ApplicationListener 將apache-solr-dataimportscheduler-.jar 中 perties 取出并根據(jù)實(shí)際情況修改,然后放到 solr.home/conf (不是solr.home/collectio

22、n1/conf) 目錄下面重啟tomcat或者jboss 即可perties配置說(shuō)明syncEnabled:是否定激活時(shí)索引,1激活,其他不激活syncCores:要索引的core或collectionserver:solr服務(wù)器ip地址port: tomcat下solr應(yīng)用端口webapp:tomcat下solr應(yīng)用名稱(chēng)params:其中entity參數(shù)代表data-config.xml中要索引的數(shù)據(jù)源,不指定則索引所有數(shù)據(jù)源interval:索引間隔時(shí)間(分)perties文件示例# perties exa

23、mple# From this example, copy everything bellow dataimport scheduler properties to your# perties file and then change params to fit your needs# IMPORTANT:# Regardless of whether you have single or multiple-core Solr,# use perties located in your solr.home/conf (NOT solr.h

24、ome/core/conf)# For more info and context see here:# /solr/DataImportHandler#perties_example#Tue Jul 21 12:10:50 CEST 2010metadataObject.last_index_time=2010-09-20 11:12:47last_index_time=2010-09-20 11:12:47# # dataimport scheduler properties # # to sync or not to

25、sync# 1 - active; anything else - inactivesyncEnabled=1# which cores to schedule# in a multi-core environment you can decide which cores you want syncronized# leave empty or comment it out if using single-core deploymentsyncCores=collection1# solr server name or IP address# defaults to localhost if

26、emptyserver=localhost# solr server port# defaults to 80 if emptyport=8080# application name/context# defaults to current ServletContextListeners context (app) namewebapp=solr# URL params mandatory# remainder of URLparams=/select?qt=/dataimport&command=delta-import&clean=false&commit=true&entity= DT_

27、CLEAR_DATA_SLAVE1# schedule interval# number of minutes between two runs# defaults to 30 if emptyinterval=10例如,我們實(shí)驗(yàn)室solrcloud中的data-config.xml中配置的entity名稱(chēng)為 DT_CLEAR_DATA_SLAVE1,DT_CLEAR_DATA_SLAVE2我們?nèi)_(tái)機(jī)器中的參數(shù)分別指定了上述兩個(gè)entity,因此solrCloud會(huì)定期對(duì)兩個(gè)數(shù)據(jù)源分別做索引,做到完全無(wú)人值守。 $dataimporter.DT_CLEAR_DATA_SLAVE1.last_i

28、ndex_time $dataimporter.DT_CLEAR_DATA_SLAVE2.last_index_time 五、 可選5.1 Add Replica(1)通過(guò)api配置/admin/collections?action=ADDREPLICA&collection=collection&shard=shard&node=solr_node_nameAdd a replica to a shard in a collection. The node name can be specified if the replica is to be created in a specific

29、nodeInputQuery ParametersKeyTypeRequiredDescriptioncollectionstringYesThe name of the collection.shardstringNoThe name of the shard to which replica is to be added. Either shard or _route_ must be provided_route_stringNoIf the shard name is not known, just pass the _route_ value and the system would identify the name of the shardnodestringNoThe name of the node where the replica should be createdinstanceDirstringNoThe in

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論