Saturday, December 28, 2024
Google search engine
HomeGuest BlogsInstall Apache Solr on CentOS / Fedora / Rocky Linux

Install Apache Solr on CentOS / Fedora / Rocky Linux

Apache Solr is an open source, fault-tolerant and highly scalable search tool written in Java. Apache Solr powers the search and navigation features of many of the world’s largest internet sites. In this tutorial, we will look at how to  Install Apache Solr on CentOS / Fedora / Rocky Linux system.

Step 1: Install Java on CentOS / Fedora / Rocky

Apache Solr requires Java. If you don’t have Java installed on your system, install it as shown below.

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

After the installation of Java, you can quickly confirm the version using the following command:

$ java -version
openjdk version "11.0.16.1" 2022-08-12 LTS
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)

Step 2: Install Latest Apache Solr on CentOS / Fedora

Apache Solr is not available on CentOS & Fedora upstream repositories, you have to download it and do a manual installation. You can check the latest release of Apache Solr then save it to the LATEST_VER variable.

cd ~/
export LATEST_VER="9.0.0"
curl -O https://dlcdn.apache.org/solr/solr/$LATEST_VER/solr-$LATEST_VER.tgz

Extract the archive downloaded:

tar xvf solr-${LATEST_VER}.tgz

Now run the Apache Solr service installer script to setup Solr environment.

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

Sample output:

id: solr: no such user
Creating new user: solr

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

Installing symlink /opt/solr -> /opt/solr-9.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
*** [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.0.0 a4eb7aa123dc53f8dac74d80b66a490f2d6b4a26 - janhoy - 2022-05-05 01:00:08",
  "startTime":"2022-10-17T16:56:40.472Z",
  "uptime":"0 days, 0 hours, 0 minutes, 19 seconds",
  "memory":"91.5 MB (%17.9) of 512 MB"}

Checking service status using SysV Init:

$ service solr status
Found 1 Solr nodes:

Solr process 1221 running on port 8983

{
  "solr_home":"/var/solr/data",
  "version":"9.0.0 a4eb7aa123dc53f8dac74d80b66a490f2d6b4a26 - janhoy - 2022-05-05 01:00:08",
  "startTime":"2022-10-17T16:58:59.283Z",
  "uptime":"0 days, 0 hours, 11 minutes, 19 seconds",
  "memory":"73.2 MB (%14.3) of 512 MB"}

Systemd way:

$ 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) since Mon 2022-10-17 17:15:50 UTC; 4min 1s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 1051 ExecStart=/etc/rc.d/init.d/solr start (code=exited, status=0/SUCCESS)

Oct 17 17:15:33 cent7.mylab.io solr[1051]: *** [WARN] ***  Your Max Processes Limit is currently 4096.
Oct 17 17:15:33 cent7.mylab.io solr[1051]: It should be set to 65000 to avoid operational disruption.
Oct 17 17:15:33 cent7.mylab.io solr[1051]: If you no longer wish to see this warning, set SOLR_ULIMIT_CHECKS to false in your profile or solr.in.sh
Oct 17 17:15:33 cent7.mylab.io solr[1051]: /opt/solr/bin/solr: line 2263: /opt/solr/bin/solr-8983.pid: Permission denied
Oct 17 17:15:33 cent7.mylab.io solr[1051]: Warning: Available entropy is low. As a result, use of the UUIDField, SSL, or any other features that require
Oct 17 17:15:33 cent7.mylab.io solr[1051]: RNG might not work properly. To check for the amount of available entropy, use 'cat /proc/sys/kernel/random/entropy_avail'.
Oct 17 17:15:50 cent7.mylab.io solr[1051]: [386B blob data]
Oct 17 17:15:50 cent7.mylab.io solr[1051]: Started Solr server on port 8983 (pid=1219). Happy searching!
Oct 17 17:15:50 cent7.mylab.io systemd[1]: Started LSB: Controls Apache Solr as a Service.
Oct 17 17:15:50 cent7.mylab.io solr[1051]: [14B blob data]

Step 3: Access Solr Dashboard

By default Solr runs on port 8983. If you have an active firewall, allow port 8983.

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

The dashboard should be accessible on the Server IP Address / Hostname and port 8983.

http://<IP|Hostname>:8983

You should get a dashboard similar to one below:

install apache solr ubuntu 18.04 debian 9 02

Step 4: Create Solr Collection

You can now create your first Solr collection:

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

Where testcollection is the name of the collection to be created.

Sample output:

INFO - 2018-11-18 13:48:05.538; org.apache.solr.util.configuration.SSLCredentialProviderFactory; Processing SSL Credential Provider chain: env;sysprop
Created new core 'testcollection'

The created collections are available on the dashboard from the Collections left panel.

install apache solr centos 7 fedora 29 28 01

Beginning with Solr 4.4, a detailed reference guide is available online or as a PDF download.

For Ubuntu / Debian refer to Install Latest Apache Solr on Ubuntu/Debian

RELATED ARTICLES

Most Popular

Recent Comments