Home | 簡體中文 | 繁體中文 | 雜文 | 打賞(Donations) | ITEYE 博客 | OSChina 博客 | Facebook | Linkedin | 知乎專欄 | Search | Email

第 59 章 Solr

solr-5.3.0

目錄

59.1. 安裝
59.2. Core Admin
59.2.1. Schema
59.3. 索引
59.3.1. Indexing a directory of "rich" files
59.3.2. Indexing Solr XML
59.3.3. Indexing JSON
59.3.4. Deleting Data
59.4. 介面
59.4.1. 查詢
59.5. FAQ
59.5.1. NOTE: Please install lsof as this script needs it to determine if Solr is listening on port 8983.
59.6. Solr 1.3.0
59.6.1. Embedded Jetty
59.6.2. Jetty
59.6.3. Tomcat
59.6.4. solr-php-client
59.6.5. multicore
59.6.6. 中文分詞
59.6.6.1. ChineseTokenizerFactory
59.6.6.2. CJK
59.6.6.3. mmseg4j
59.6.6.4. 中文分詞“庖丁解牛” Paoding Analysis

59.1. 安裝

安裝

yum install -y unzip java-1.8.0-openjdk

wget http://www.us.apache.org/dist/lucene/solr/5.3.0/solr-5.3.0.tgz
tar zxvf solr-5.3.0.tgz
mv solr-5.3.0 /srv/
ln -s /srv/solr-5.3.0/ /srv/solr

adduser -d /srv/solr -c "Apache Solr" solr
chown solr:solr -R /srv/solr-5.3.0

cp /srv/solr-5.3.0/bin/init.d/solr /etc/init.d/
sed -i 's:/opt/solr:/srv/solr:' /etc/init.d/solr
sed -i 's:/var/solr:/srv/solr/bin:' /etc/init.d/solr

chkconfig --add  solr
chkconfig solr on
		

啟動與停止

# service solr start
Waiting up to 30 seconds to see Solr running on port 8983 [/]
Started Solr server on port 8983 (pid=61909). Happy searching!

# service solr stop
Sending stop command to Solr running on port 8983 ... waiting 5 seconds to allow Jetty process 61909 to stop gracefully.
		

請使用service 或者 /etc/init.d/solr啟動,不建議使用root用戶如下啟動,會造成日誌檔案無權限等問題。

# /srv/solr/bin/solr start
Waiting up to 30 seconds to see Solr running on port 8983 [/]
Started Solr server on port 8983 (pid=56697). Happy searching!
		

我們將solr啟動後交給solr用戶完成。

# ps aux | grep solr
solr     62345 14.5  4.1 4103804 158960 ?      Sl   04:15   0:02 java -server -Xss256k -Xms512m -Xmx512m -XX:NewRatio=3 -XX:SurvivorRatio=4 -XX:TargetSurvivorRatio=90 -XX:MaxTenuringThreshold=8 -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:ConcGCThreads=4 -XX:ParallelGCThreads=4 -XX:+CMSScavengeBeforeRemark -XX:PretenureSizeThreshold=64m -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=50 -XX:CMSMaxAbortablePrecleanTime=6000 -XX:+CMSParallelRemarkEnabled -XX:+ParallelRefProcEnabled -verbose:gc -XX:+PrintHeapAtGC -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+PrintTenuringDistribution -XX:+PrintGCApplicationStoppedTime -Xloggc:/srv/solr/server/logs/solr_gc.log -Djetty.port=8983 -DSTOP.PORT=7983 -DSTOP.KEY=solrrocks -Duser.timezone=UTC -Djetty.home=/srv/solr/server -Dsolr.solr.home=/srv/solr/server/solr -Dsolr.install.dir=/srv/solr -jar start.jar -XX:OnOutOfMemoryError=/srv/solr/bin/oom_solr.sh 8983 /srv/solr/server/logs --module=http
root     62458  0.0  0.0 112640   964 pts/0    S+   04:15   0:00 grep --color=auto solr
		

Solr Admin UI: http://192.168.4.1:8983/solr/#/