Home | 简体中文 | 繁体中文 | 杂文 | 打赏(Donations) | ITEYE 博客 | OSChina 博客 | Facebook | Linkedin | 知乎专栏 | Search | Email

第 24 章 Solr

solr-5.3.0

目录

24.1. 安装
24.2. Core Admin
24.2.1. Schema
24.3. 索引
24.3.1. Indexing a directory of "rich" files
24.3.2. Indexing Solr XML
24.3.3. Indexing JSON
24.3.4. Deleting Data
24.4. 接口
24.4.1. 查询
24.5. FAQ
24.5.1. NOTE: Please install lsof as this script needs it to determine if Solr is listening on port 8983.
24.6. Solr 1.3.0
24.6.1. Embedded Jetty
24.6.2. Jetty
24.6.3. Tomcat
24.6.4. solr-php-client
24.6.5. multicore
24.6.6. 中文分词
24.6.6.1. ChineseTokenizerFactory
24.6.6.2. CJK
24.6.6.3. mmseg4j
24.6.6.4. 中文分词“庖丁解牛” Paoding Analysis

24.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/#/