
Apache Solr是一個開放式搜索企業搜索軟體,您將學習如何在CentOS 8上安裝Apache Solr Server,
目錄- 什么是Solr?
- 環境規格
- 第一步:更新CentOS 8軟體包
- 第二步:Linux服務器上安裝OpenJDK
- 第三步:CentOS服務器上安裝Apache Solr
什么是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.116.230 / 24
第一步:更新CentOS 8軟體包
使用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)
第二步:Linux服務器上安裝OpenJDK
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服務器上,
第三步:CentOS服務器上安裝Apache Solr
【1】您可以從Github或其官方網站下載Apache Solr,

【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/,

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

這是我們本文章的結尾,您已經學會了如何在CentOS 8.2安裝Apache Solr,如果在閱讀中遇到問題請及時留言,如果感覺文章對您有幫助請與朋友分享文章,
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/239941.html
標籤:其他
