在Ubuntu 19.04/18.04 /16.04和Debian 9上安装最新的Apache Solrr

时间:2020-02-23 14:32:59  来源:igfitidea点击:

Apache Solr是在Java中编写的高度可扩展,可靠和容错的开源搜索工具。
Solr旨在提供具有自动故障转移和恢复的分布式索引,复制和负载平衡查询。

SOLR为世界上许多最大的互联网的搜索和导航功能服务。
在本教程中,我们将研究如何在Ubuntu 19.04/18.04/16.04和Debian 9上安装最新的Apache Solr。

第1步:安装Java

Apache Solr需要安装Java。
在Ubuntu 19.04/18.04 /16.04和Debian 9上安装OpenJDK:

sudo apt install -y default-jdk

安装后,确认我们可以运行 java来自终端的命令。

$java -version
openjdk version "11.0.2" 2019-01-15
OpenJDK Runtime Environment (build 11.0.2+9-Ubuntu-3ubuntu118.04.3)
OpenJDK 64-Bit Server VM (build 11.0.2+9-Ubuntu-3ubuntu118.04.3, mixed mode, sharing)

第2步:在Ubuntu 18.04/debian 9上安装最新的apache solr

Apache Solr在Ubuntu和Debian上游存储库上不可用,需要手动下载和安装。
Apache Solr的版本在官方上提供,请在将版本保存到中,查看链接 LATEST_VER多变的。

export LATEST_VER="8.0.0"
curl -O https://www-eu.apache.org/dist/lucene/solr/${LATEST_VER}/solr-${LATEST_VER}.tgz

提取下载的存档:

tar xvf solr-${LATEST_VER}.tgz

现在将Apache Solr Service Installer脚本运行到设置索尔环境。

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

示例

...
id: 'solr': no such user
Creating new user: solr
Adding system user `solr' (UID 111) ...
Adding new group `solr' (GID 116) ...
Adding new user `solr' (UID 111) with group `solr' ...
Creating home directory `/var/solr' ...
Extracting /home/vagrant/solr-8.0.0.tgz to /opt
Installing symlink /opt/solr -> /opt/solr-8.0.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

脚本将安装并启动solr服务。
我们可以通过运行检查状态:

$systemctl status solr.service
* solr.service - LSB: Controls Apache Solr as a Service
   Loaded: loaded (/etc/init.d/solr; generated)
   Active: active (exited) since Thu 2019-04-25 22:32:27 PDT; 2min 45s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 19840 ExecStart=/etc/init.d/solr start (code=exited, status=0/SUCCESS)
Apr 25 22:32:21 ubuntu-01 solr[19840]: *** [WARN] *** Your open file limit is currently 1024.
Apr 25 22:32:21 ubuntu-01 solr[19840]:  It should be set to 65000 to avoid operational disruption.
Apr 25 22:32:21 ubuntu-01 solr[19840]:  If you no longer wish to see this warning, set SOLR_ULIMIT_CHECKS to false in your profile or solr.in.sh
Apr 25 22:32:21 ubuntu-01 solr[19840]: *** [WARN] ***  Your Max Processes Limit is currently 3700.
Apr 25 22:32:21 ubuntu-01 solr[19840]:  It should be set to 65000 to avoid operational disruption.
Apr 25 22:32:21 ubuntu-01 solr[19840]:  If you no longer wish to see this warning, set SOLR_ULIMIT_CHECKS to false in your profile or solr.in.sh
Apr 25 22:32:27 ubuntu-01 solr[19840]: [194B blob data]
Apr 25 22:32:27 ubuntu-01 solr[19840]: Started Solr server on port 8983 (pid=19912). Happy searching!
Apr 25 22:32:27 ubuntu-01 solr[19840]: [14B blob data]
Apr 25 22:32:27 ubuntu-01 systemd[1]: Started LSB: Controls Apache Solr as a Service.

确保服务设置为启动启动。

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

第3步:访问SOLR仪表板

默认情况下Solr在端口上运行 8983
如果我们有一个UFW防火墙运行,请允许端口8983.

sudo ufw allow 8983

仪表板应在URL上访问。

http://<IP|Hostname>:8983

我们应该获得类似于下面的仪表板:

第4步:创建Solr Collection

我们现在可以创建第一个Solr Collection:

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

示例

INFO  - 2019-04-25 22:37:32.110; org.apache.solr.util.configuration.SSLCredentialProviderFactory; Processing SSL Credential Provider chain: env;sysprop
Created new core 'collection1'