1. 程式人生 > 其它 >CentOs7.3 搭建 Solr單機服務

CentOs7.3 搭建 Solr單機服務

CentOs7.3 搭建 Solr單機服務

Solr是什麼?

Solr是一款優秀的基於Lucene的全文檢索伺服器,它對Lucene進行了擴充套件,提供了非常豐富的查詢語言,並對查詢進行了效能優化。Solr和Lucene都由Apache Software Foundation(www.apache.org)管理。

Apache Solr 參考指南

http://lucene.apache.org/solr/guide/6_6/about-this-guide.html

環境

VMware版本號:12.0.0 CentOS版本:CentOS 7.3.1611 Solr 版本:solr-6.6.0 JDK環境:jdk-8u144-linux-x64.tar.gz 具體參考

《CentOs7.3 安裝 JDK1.8》

https://segmentfault.com/a/1190000010716919

注意事項

關閉防火牆

$ systemctl stop firewalld.service 

Solr 安裝

提取tar檔案

$ cd /opt/
$ wget https://mirrors.tuna.tsinghua.edu.cn/apache/lucene/solr/6.6.0/solr-6.6.0.tgz
$ tar -zxf solr-6.6.0.tgz 
$ cd solr-6.6.0

Solr 操作

1.啟動服務

說明:加 -force 是因為solr不允許使用 root 進行操作的,其他賬戶可不加

$ /opt/solr-6.6.0/bin/solr start -force

響應

Warning: Available entropy is low. As a result, use of the UUIDField, SSL, or any other features that require
RNG might not work properly. To check for the amount of available entropy, use 'cat /proc/sys/kernel/random/entropy_avail'.

NOTE: Please install lsof as this script needs it to determine if Solr is listening on port 8983.

Started Solr server on port 8983 (pid=3020). Happy searching!

啟動Solr與不同的埠,要更改Solr監聽埠,可以-p在啟動時使用引數

例如:

$ /opt/solr-6.6.0/bin/solr start -p 8984

2.訪問管理UI

瀏覽器輸入 ip:port

http://192.168.252.121:8983/solr/

如果Solr沒有執行,您的瀏覽器會抱怨說它無法連線到伺服器。檢查您的埠號,然後重試。

3.服務狀態

如果您不確定Solr是否在本地執行

$ /opt/solr-6.6.0/bin/solr status

響應

Found 1 Solr nodes: 

Solr process 4177 running on port 8983
{
  "solr_home":"/opt/solr-6.6.0/server/solr",
  "version":"6.6.0 5c7a7b65d2aa7ce5ec96458315c661a18b320241 - ishan - 2017-05-30 07:32:53",
  "startTime":"2017-08-23T16:18:24.088Z",
  "uptime":"0 days, 0 hours, 0 minutes, 18 seconds",
  "memory":"32.9 MB (%6.7) of 490.7 MB"}

4.建立Solr庫

bin/solr create -c <name>

說明:加 -force 是因為solr不允許使用 root 進行操作的,其他賬戶可不加

$ /opt/solr-6.6.0/bin/solr create -c ymq -force

響應

Copying configuration to new core instance directory:
/opt/solr-6.6.0/server/solr/ymq

Creating new core 'ymq' using command:
http://localhost:8983/solr/admin/cores?action=CREATE&name=ymq&instanceDir=ymq

{
  "responseHeader":{
    "status":0,
    "QTime":2665},
  "core":"ymq"}

瀏覽器輸入 ip:port

http://192.168.252.121:8983/solr/

5.停止服務

$ /opt/solr-6.6.0/bin/solr stop -p 8983

響應

Sending stop command to Solr running on port 8983 ... waiting up to 180 seconds to allow Jetty process 3554 to stop gracefully.

可以使用該-all引數來停止所有執行的Solr例項

$ /opt/solr-6.6.0/bin/solr stop -all

響應

Sending stop command to Solr running on port 8983 ... waiting up to 180 seconds to allow Jetty process 3249 to stop gracefully.

Contact