在 Linux 服务器上安装 OpenJDK

Apache Solr 是用 Java 编程语言编写的,因此它需要 Java Development Kit (JDK) 8 或者更高版本才能运行企业搜索服务。

OpenJDK 在标准 yum 存储库中可用,并且可以轻松安装。
或者,我们也可以在 Linux 服务器上安装 Oracle Java SE。

为简单起见,我们在 Linux 服务器上安装 OpenJDK 11.

# dnf install -y java-11-openjdk

安装成功后,验证Java版本。

# 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)

OpenJDK 已安装在 Linux 服务器上。

在 CentOS/RHEL 8 上安装 Apache Solr 服务器

Apache Solr 是一个开源企业搜索软件。
在本教程中,我们将学习如何在基于 CentOS/RHEL 8 的服务器上安装它。

查看更多教程 https://on  itroad.com

在 Linux 服务器上安装 Apache Solr

我们可以从 Github 或者其官方网站下载 Apache Solr。

从官方下载页面,复制所需版本的 Apache Solr 软件的 URL,然后使用 wget 命令下载它。

# cd /tmp
# wget https://downloads.apache.org/lucene/solr/8.7.0/solr-8.7.0.tgz

从下载的 tar包 中提取安装脚本,如下所示。

# tar xf solr-8.7.0.tgz solr-8.7.0/bin/install_solr_service.sh --strip-components=2

现在,执行提取的安装脚本以在 Linux 机器上安装 Apache Solr Enterprise Search Server。

# ./install_solr_service.sh solr-8.7.0.tgz
We recommend installing the 'lsof' command for more stable start/stop of Solr
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
*** [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.
Started Solr server on port 8983 (pid=2241). Happy searching!

Found 1 Solr nodes:
Solr process 2241 running on port 8983
Solr at http://localhost:8983/solr not online.

以上警告不用担心,我们会一一整改。

根据 Apache Solr 的要求安装 lsof 软件包。

# dnf install -y lsof

使用以下 Linux 命令启用 Solr 搜索服务。

# systemctl enable solr
solr.service is not a native service, redirecting to systemd-sysv-install.
Executing: /usr/lib/systemd/systemd-sysv-install enable solr

验证 Solr 搜索服务是否在默认端口 8983 上运行。

# ss -tulpn | grep 8983
tcp    LISTEN  0       50                         *:8983                *:*      users:(("java",pid=2241,fd=153))

纠正由于文件和进程限制而在服务启动期间的警告。
我们需要根据 Apache Solr Enterprise Search Server 的要求定义安全限制。

在vim 编辑器中打开limits.conf 文件。

# vi /etc/security/limits.conf

并在此文件中添加以下指令。

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

使用 legacy service 命令重新启动 Solr 服务。
这次不会有任何警告。

# service solr restart
Sending stop command to Solr running on port 8983 ... waiting up to 180 seconds to allow Jetty process 4524 to stop gracefully.
Waiting up to 180 seconds to see Solr running on port 8983 [/]
Started Solr server on port 8983 (pid=4865). Happy searching!

Apache Solr 使用默认网络端口 8983/tcp 。
因此,我们需要在 Linux 防火墙中允许该端口。

# firewall-cmd --permanent --add-port=8983/tcp
success
# firewall-cmd --reload
success

在企业搜索服务器中创建一个太阳能示例集合。

# su - solr -c "/opt/solr/bin/solr create -c testcol1 -n data_driven_schema_configs"
Created new core 'testcol1'

在客户端浏览器中打开 URL http://192.168.1.230:8983/solr/。

将看到 Apache Solr Web UI 的仪表板。
我们可以通过从左侧窗格的下拉框中选择它来检查最近创建的集合。

日期:2020-09-17 00:16:37 来源:oir作者:oir