在CentOS/Fedora/Rocky Linux上安装Apache Solr

本文介绍如何在CentOS/Fedora/Rocky Linux操作系统上安装Apache Solr的方法。

安装Apache Solr的详细步骤

步骤1:在CentOS/Fedora/Rocky上安装Java

Apache Solr需要Java。如果系统上没有安装Java,请按如下所示进行安装:

sudo yum install lsof java-11-openjdk  java-11-openjdk-devel -y

安装Java后,可以使用以下命令快速确认版本:

$ java -version

openjdk version "11.0.16.1"

OpenJDK Runtime Environment (Red_Hat-11.0.16.1.1-1.el7_9) (build 11.0.16.1+1-LTS)

OpenJDK 64-Bit Server VM (Red_Hat-11.0.16.1.1-1.el7_9) (build 11.0.16.1+1-LTS, mixed mode, sharing)

步骤2:在CentOS/Fedora上安装最新的Apache Solr

Apache Solr在CentOS和Fedora上游存储库上不可用,您必须下载并手动安装。您可以检查Apache Solr的最新版本,地址在https://solr.apache.org/downloads.html,然后将其保存到latest_VER变量中,我们可以安装Solr 9.1.0版本:

在CentOS/Fedora/Rocky Linux上安装Apache Solr

所需要执行的命令如下:

cd ~/

export LATEST_VER="9.1.0"

curl -O https://dlcdn.apache.org/solr/solr/$LATEST_VER/solr-$LATEST_VER.tgz

提取下载的存档文件:

tar xvf solr-${LATEST_VER}.tgz

现在运行ApacheSolr服务安装程序脚本来设置Solr环境:

cd solr-${LATEST_VER}/bin/

sudo ./install_solr_service.sh ~/solr-${LATEST_VER}.tgz

样本输出:

id: solr: no such user

Creating new user: solr

Extracting /root/solr-9.1.0.tgz to /opt

Installing symlink /opt/solr -> /opt/solr-9.1.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

*** [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 4096.

 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

/opt/solr/bin/solr: line 2263: /opt/solr/bin/solr-8983.pid: Permission denied

Waiting up to 180 seconds to see Solr running on port 8983 [/]

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

Found 1 Solr nodes:

Solr process 1754 running on port 8983

{

  "solr_home":"/var/solr/data",

  "version":"9.1.0"}

使用SysV Init检查服务状态:

$ service solr status

Found 1 Solr nodes:

Solr process 1221 running on port 8983

{

  "solr_home":"/var/solr/data",

  "version":"9.1.0"}

系统方式:

$ systemctl status solr

 solr.service - LSB: Controls Apache Solr as a Service

   Loaded: loaded (/etc/rc.d/init.d/solr; bad; vendor preset: disabled)

   Active: active (exited)

步骤3:访问Solr仪表板

默认情况下,Solr在端口8983上运行。如果您有活动防火墙,请允许端口8983:

sudo firewall-cmd  --permanent --add-port=8983/tcp

sudo firewall-cmd --reload

应该可以在服务器IP地址/主机名和端口8983上访问仪表板,地址格式为http://<IP|Hostname>:8983。

进入后就可以看到Solr仪表板界面了:

在CentOS/Fedora/Rocky Linux上安装Apache Solr

步骤4:创建Solr Collection

现在,您可以创建第一个Solr Collection:

sudo su - solr -c "/opt/solr/bin/solr create -c testcollection -n data_driven_schema_configs"

其中testcollection是要创建的Collection的名称。

样本输出:

org.apache.solr.util.configuration.SSLCredentialProviderFactory; Processing SSL Credential Provider chain: env;sysprop

Created new core 'testcollection'

所创建的Collection在仪表板的“Collection”左侧面板中可用:

在CentOS/Fedora/Rocky Linux上安装Apache Solr

至此,在CentOS/Fedora/Rocky Linux系统上安装Apache Solr完成了。

栏目相关文章