天天看點

CentOS 8.2部署最新版Apache Solr 8.7.0搜尋服務

CentOS 8.2部署最新版Apache Solr 8.7.0搜尋服務

Apache Solr是一個開放式搜尋企業搜尋軟體。您将學習如何在CentOS 8上安裝Apache Solr Server。

目錄

  • 什麼是Solr?
  • 環境規格
  • 第一步:更新CentOS 8軟體包
  • 第二步:Linux伺服器上安裝OpenJDK
  • 第三步:CentOS伺服器上安裝Apache Solr

Solr(發音為“ solar”)是來自Apache Lucene項目的用Java編寫的開源企業搜尋平台。Solr可以在Apache License 2.0下使用。

Solr的主要功能包括全文搜尋,命中突出顯示,多面搜尋,實時索引,動态叢集,資料庫內建,NoSQL功能和豐富的文檔(例如Word,PDF)處理。提供分布式搜尋和索引複制。

Solr旨在實作可伸縮性和容錯能力。Solr被廣泛用于企業搜尋和分析用例,并擁有活躍的開發社群和正常版本。

Solr作為獨立的全文本搜尋伺服器運作。它以Lucene Java搜尋庫為核心進行全文索引和搜尋,并具有類似REST的HTTP / XML和JSON API,可從大多數流行的程式設計語言使用。Solr的外部配置使它可以針對多種類型的應用程式進行量身定制,而無需使用Java編碼,并且它具有插件架構來支援更進階的自定義。

Solr為許多世界上最大的網際網路站點提供搜尋和導航功能。

  • CPU :3.4 GHz(2核)
  • 記憶體:2 GB
  • 儲存空間:20 GB
  • 作業系統-:CentOS 8.2
  • 主機名:solrserver.lianglab.cn
  • IP位址-192.168.6.200/24

使用ssh用戶端以root使用者身份與solrserver.lianglab.cn連接配接。

【1】通過使用dnf指令,更新Linux伺服器中的軟體包。

[root@rsyncserver ~]# hostnamectl set-hostname solrserver.lianglab.cn
[root@solrserver ~]# dnf update -y
08:12:06 PM PKT.
Dependencies resolved.
Nothing to do.
Complete!
           

【2】驗證Linux作業系統和核心版本。

[root@solrserver ~]# uname -r
4.18.0-193.28.1.el8_2.x86_64
[root@solrserver ~]# cat /etc/redhat-release
CentOS Linux release 8.2.2004 (Core)
           

Apache Solr用Java程式設計語言編寫,是以它需要Java Development Kit(JDK)8或更高版本。

OpenJDK在标準yum存儲庫中可用,并且可以輕松安裝

我們在Linux伺服器上安裝OpenJDK 11。

[root@solrserver ~]# dnf install -y java-11-openjdk
Last metadata expiration check: 0:56:26 ago on Thu 24 Dec 2020 09:38:40 PM CST.
Dependencies resolved.
=============================================================================================================
 Package                        Architecture Version                                   Repository       Size
=============================================================================================================
Installing:
 java-11-openjdk                x86_64       1:11.0.9.11-0.el8_2                       AppStream       251 k
Installing dependencies:
 copy-jdk-configs               noarch       3.7-1.el8                                 AppStream        27 k
 java-11-openjdk-headless       x86_64       1:11.0.9.11-0.el8_2     
---------------------省略部分----------------------
Installed:
  copy-jdk-configs-3.7-1.el8.noarch                                                                          
  java-11-openjdk-1:11.0.9.11-0.el8_2.x86_64                                                                 
  java-11-openjdk-headless-1:11.0.9.11-0.el8_2.x86_64                                                        
  javapackages-filesystem-5.3.0-1.module_el8.0.0+11+5b8c10bd.noarch                                          
  lksctp-tools-1.0.18-3.el8.x86_64                                                                           
  ttmkfdir-3.0.9-54.el8.x86_64                                                                               
  tzdata-java-2020d-1.el8.noarch                                                                             
  xorg-x11-fonts-Type1-7.5-19.el8.noarch                                                                     

Complete!
[root@solrserver ~]# 

           

成功安裝後,請驗證Java版本。

[root@solrserver ~]# java -version
openjdk version "11.0.9" 2020-10-20 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.9+11-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.9+11-LTS, mixed mode, sharing)
[root@solrserver ~]# 

           

OpenJDK已安裝在Linux伺服器上。

【1】您可以從Github或其官方網站下載下傳Apache Solr。

CentOS 8.2部署最新版Apache Solr 8.7.0搜尋服務

【2】從Solr下載下傳頁面複制所需版本的Apache Solr的URL,然後使用wget指令從複制的URL下載下傳Solr。

[root@solrserver ~]#  cd /tmp
[root@solrserver tmp]# wget https://downloads.apache.org/lucene/solr/8.7.0/solr-8.7.0.tgz
--2020-12-24 22:38:28--  https://downloads.apache.org/lucene/solr/8.7.0/solr-8.7.0.tgz
Connecting to 192.168.6.175:3128... connected.
Proxy request sent, awaiting response... 200 OK

           

【3】如下所示從下載下傳的tar包中提取Solr安裝腳本。

[root@solrserver tmp]# ls
hsperfdata_root 
solr-8.7.0.tgz  
[root@solrserver tmp]# tar xf solr-8.7.0.tgz solr-8.7.0/bin/install_solr_service.sh --strip-components=2
[root@solrserver tmp]# ls
hsperfdata_root       
install_solr_service.sh  
solr-8.7.0.tgz
[root@solrserver tmp]# 

           

【4】使用提取的安裝腳本在您的Linux伺服器上安裝Apache Solr。

[root@solrserver tmp]# ./install_solr_service.sh solr-8.7.0.tgz
id: ‘solr’: no such user
Creating new user: solr

Extracting solr-8.7.0.tgz to /opt


Installing symlink /opt/solr -> /opt/solr-8.7.0 ...


Installing /etc/init.d/solr script ...


Installing /etc/default/solr.in.sh ...

Service solr installed.
Customize Solr startup configuration in /etc/default/solr.in.sh
Waiting up to 180 seconds to see Solr running on port 8983 [-]  
Started Solr server on port 8983 (pid=94325). Happy searching!
                                                                                                                           
Found 1 Solr nodes: 

Solr process 94325 running on port 8983
{
  "solr_home":"/var/solr/data",
  "version":"8.7.0 2dc63e901c60cda27ef3b744bc554f1481b3b067 - atrisharma - 2020-10-29 19:39:16",
  "startTime":"2020-12-24T14:52:42.122Z",
  "uptime":"0 days, 0 hours, 0 minutes, 10 seconds",
  "memory":"85.8 MB (%16.8) of 512 MB"}

[root@solrserver tmp]# netstat -anptl| grep 8983
tcp        0      0 0.0.0.0:8983            0.0.0.0:*               LISTEN      94325/java          
[root@solrserver tmp]# ps -ef | grep 94325
solr       94325       1  8 22:52 ?        00:00:07 java -server -Xms512m -Xmx512m -XX:+UseG1GC -XX:+PerfDisableSharedMem -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=250 -XX:+UseLargePages -XX:+AlwaysPreTouch -XX:+ExplicitGCInvokesConcurrent -Xlog:gc*:file=/var/solr/logs/solr_gc.log:time,uptime:filecount=9,filesize=20M -Dsolr.jetty.inetaccess.includes= -Dsolr.jetty.inetaccess.excludes= -Dsolr.log.dir=/var/solr/logs -Djetty.port=8983 -DSTOP.PORT=7983 -DSTOP.KEY=solrrocks -Duser.timezone=UTC -XX:-OmitStackTraceInFastThrow -Djetty.home=/opt/solr/server -Dsolr.solr.home=/var/solr/data -Dsolr.data.home= -Dsolr.install.dir=/opt/solr -Dsolr.default.confdir=/opt/solr/server/solr/configsets/_default/conf -Dlog4j.configurationFile=/var/solr/log4j2.xml -Xss256k -Dsolr.jetty.https.port=8983 -Dsolr.log.muteconsole -XX:OnOutOfMemoryError=/opt/solr/bin/oom_solr.sh 8983 /var/solr/logs -jar start.jar --module=http
root       94574   93094  0 22:54 pts/1    00:00:00 grep --color=auto 94325
[root@solrserver tmp]# 



#如果有遇到類似于這個報錯 請安裝losf軟體包

Installing /etc/default/solr.in.sh ...

Service solr installed.
Customize Solr startup configuration in /etc/default/solr.in.sh
*** [WARN] *** Your open file limit is currently 1024.
 It should be set to 65000 to avoid operational disruption.
 If you no longer wish to see this warning, set SOLR_ULIMIT_CHECKS to false in your profile or solr.in.sh
*** [WARN] ***  Your Max Processes Limit is currently 3674.
 It should be set to 65000 to avoid operational disruption.
 If you no longer wish to see this warning, set SOLR_ULIMIT_CHECKS to false in your profile or solr.in.sh
NOTE: Please install lsof as this script needs it to determine if Solr is listening on port 8983.

           

【5】根據Apache Solr的要求安裝lsof軟體包。

[root@solrserver tmp]# dnf install -y lsof
Last metadata expiration check: 1:07:30 ago on Sun 15 Nov 2020 08:12:06 PM PKT.
Dependencies resolved.
================================================================================
 Package        Architecture     Version                 Repository        Size
================================================================================
Installing:
 lsof           x86_64           4.91-2.el8              BaseOS           253 k

Transaction Summary
================================================================================
Install  1 Package

Total download size: 253 k
Installed size: 630 k
Downloading Packages:
lsof-4.91-2.el8.x86_64.rpm                      114 kB/s | 253 kB     00:02
--------------------------------------------------------------------------------
Total                                            76 kB/s | 253 kB     00:03
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                        1/1
  Installing       : lsof-4.91-2.el8.x86_64                                 1/1
  Running scriptlet: lsof-4.91-2.el8.x86_64                                 1/1
  Verifying        : lsof-4.91-2.el8.x86_64                                 1/1

Installed:
  lsof-4.91-2.el8.x86_64

Complete!
           

【6】使用以下Linux指令啟用Apache Solr服務。

[root@solrserver tmp]# systemctl enable solr
solr.service is not a native service, redirecting to systemd-sysv-install.
Executing: /usr/lib/systemd/systemd-sysv-install enable solr

           

【7】驗證Solr服務是否正在預設端口8983上運作。

[root@solrserver tmp]# netstat -anptl| grep 8983
tcp        0      0 0.0.0.0:8983            0.0.0.0:*               LISTEN      94325/java          
[root@solrserver tmp]# ss -tulpn | grep 8983
tcp     LISTEN   0        50               0.0.0.0:8983           0.0.0.0:*      users:(("java",pid=94325,fd=153))               
           

在Apache Solr啟動期間糾正有關檔案和程序限制的警告。您需要按照Apache Solr的要求定義安全限制。

【8】在vim編輯器中打開limits.conf檔案。

[root@solrserver tmp]# vi /etc/security/limits.d/solr.conf
           

并在此檔案中添加以下指令。

solr   soft   nofile   65536
solr   hard   nofile   65536
solr   soft   nproc    65536
solr   hard   nproc    65536
           

【9】使用舊版服務指令重新啟動Solr服務并檢視solr服務狀态。

[root@solrserver tmp]# service solr restart
Sending stop command to Solr running on port 8983 ... waiting up to 180 seconds to allow Jetty process 94325 to stop gracefully.
Waiting up to 180 seconds to see Solr running on port 8983 [|]  
Started Solr server on port 8983 (pid=95305). Happy searching!


[root@solrserver tmp]# service solr status 

Found 1 Solr nodes: 

Solr process 95305 running on port 8983
{
  "solr_home":"/var/solr/data",
  "version":"8.7.0 2dc63e901c60cda27ef3b744bc554f1481b3b067 - atrisharma - 2020-10-29 19:39:16",
  "startTime":"2020-12-24T14:59:08.493Z",
  "uptime":"0 days, 0 hours, 0 minutes, 52 seconds",
  "memory":"121.7 MB (%23.8) of 512 MB"}


           

【10】Apache Solr使用預設網絡端口8983/tcp。是以,您需要在Linux防火牆中允許該端口。

[root@solrserver tmp]# firewall-cmd --permanent --add-port=8983/tcp
success
[root@solrserver tmp]#  firewall-cmd --reload
success
           

【11】在Apache Solr伺服器中建立一個測試集合。

[root@solrserver tmp]# su - solr -c "/opt/solr/bin/solr create -c lianglabtest -n data_driven_schema_configs"

Created new core 'lianglabtest'
[root@solrserver tmp]# 

           

【12】在用戶端浏覽器中打開URL http://192.168.6.200:8983/solr/。

CentOS 8.2部署最新版Apache Solr 8.7.0搜尋服務

【14】您現在位于Apache Solr Web UI的儀表闆上。您可以通過從左側窗格的下拉框中選擇最近建立的集合來檢查它。

CentOS 8.2部署最新版Apache Solr 8.7.0搜尋服務

這是我們本文章的結尾。您已經學會了如何在CentOS 8.2安裝Apache Solr,如果在閱讀中遇到問題請及時留言,如果感覺文章對您有幫助請與朋友分享文章。

作者:zhangliangliang

出處:http://www.cnblogs.com/lianglab/

本文版權歸作者和部落格園共有,寫文不易,支援原創,歡迎轉載【點贊】,轉載請保留此段聲明,且在文章頁面明顯位置給出原文連接配接,謝謝。