Apache Solr是一個開放式搜索企業搜索軟件。您將學習如何在CentOS 8上安裝Apache Solr Server。html
Solr(發音爲「 solar」)是來自Apache Lucene項目的用Java編寫的開源企業搜索平臺。Solr能夠在Apache License 2.0下使用。java
Solr的主要功能包括全文搜索,命中突出顯示,多面搜索,實時索引,動態集羣,數據庫集成,NoSQL功能和豐富的文檔(例如Word,PDF)處理。提供分佈式搜索和索引複製。node
Solr旨在實現可伸縮性和容錯能力。Solr被普遍用於企業搜索和分析用例,並擁有活躍的開發社區和常規版本。linux
Solr做爲獨立的全文本搜索服務器運行。它以Lucene Java搜索庫爲核心進行全文索引和搜索,並具備相似REST的HTTP / XML和JSON API,可從大多數流行的編程語言使用。Solr的外部配置使它能夠針對多種類型的應用程序進行量身定製,而無需使用Java編碼,而且它具備插件架構來支持更高級的自定義。git
Solr爲許多世界上最大的互聯網站點提供搜索和導航功能。github
使用ssh客戶端以root用戶身份與solrserver.lianglab.cn鏈接。shell
【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操做系統和內核版本。apache
[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。
【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,若是在閱讀中遇到問題請及時留言,若是感受文章對您有幫助請與朋友分享文章。