安裝
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/#/