How to install Apache Solr on CentOS 8

Share on Social Media

Apache Solr is an open source enterprise search software. In this guide, you will learn how to install Apache Solr on CentOS 8 based server. #centlinux #linux #solr

What is Solr? :

Solr (pronounced “solar”) is an open-source enterprise-search platform, written in Java, from the Apache Lucene project. Solr is available to use under Apache License 2.0.

Solr major features include full-text search, hit highlighting, faceted search, real-time indexing, dynamic clustering, database integration, NoSQL features and rich document (e.g., Word, PDF) handling. Providing distributed search and index replication.

Solr is designed for scalability and fault tolerance. It is widely used for enterprise search and analytics use cases and has an active development community and regular releases.

Apache Solr enterprise search server runs as a standalone full-text search engine. It uses the Lucene Java library at its core for full-text indexing and search, and has REST-like HTTP/XML and JSON APIs that make it usable from most popular programming languages.

Solr’s external configuration allows it to be tailored to many types of applications without Java coding, and it has a plugin architecture to support more advanced customization.

Apache Solr powers the search and navigation features of many of the world’s largest internet sites.

Environment Specification:

We are using a minimal CentOS 8 KVM machine with following specifications.

  • CPU – 3.4 Ghz (2 cores)
  • Memory – 2 GB
  • Storage – 20 GB
  • Operating System – CentOS 8.2
  • Hostname – solr-01.centlinux.com
  • IP Address – 192.168.116.230 /24

Update Linux Software Packages:

Connect with solr-01.centlinux.com as root user by using a ssh client.

By using dnf command, update software packages in your Linux operating system.

# dnf update -y

Verify the Linux operating system and Kernel version.

# uname -r
4.18.0-193.28.1.el8_2.x86_64

# cat /etc/redhat-release
CentOS Linux release 8.2.2004 (Core)

Install OpenJDK on Linux Server:

Apache Solr is written in Java programming language, therefore it requires Java Development Kit (JDK) 8 or later to run enterprise search services.

OpenJDK is available in standard yum repository and can be installed easily. Alternatively, you can also install Oracle Java SE on your Linux server.

For the sake of simplicity, we are installing OpenJDK 11 on the Linux server.

# dnf install -y java-11-openjdk

After successful installation, verify the Java version.

# 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 has been installed on your Linux server.

Install Apache Solr on Linux Server:

You can download Apache Solr from Github or their official website.

Apache Solr Download Page

From official download page, copy the URL of your required version of Apache Solr software and then use wget command to download it.

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

Extract the installation script from downloaded tarball as follows.

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

Now, execute the extracted installation script to install Apache Solr Enterprise Search Server on your Linux machine.

# ./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.

Don’t worry about the above warnings, we will rectify them one by one.

Install lsof software package as required by the Apache Solr.

# dnf install -y lsof

Enable Solr search service by using following Linux command.

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

Verify that the Solr search service is running on default port 8983.

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

To rectify the warnings during startup of service due to File and Process limits. You need to define the security limits as required by the Apache Solr Enterprise Search Server.

Open limits.conf file in vim editor.

# vi /etc/security/limits.conf

And add following directives in this file.

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

Restart the Solr service using legacy service command. There will be no warnings this time.

# 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 uses default network port 8983/tcp. Therefore, you need to allow this port in Linux firewall.

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

Create a solar example collection in enterprise search server.

# su - solr -c "/opt/solr/bin/solr create -c testcol1 -n data_driven_schema_configs"

Created new core 'testcol1'

Open URL http://192.168.116.230:8983/solr/ in a client browser.

Apache Solr Dashboard 1

You are now at the dashboard of the Apache Solr web UI. You can check the recently created collection by selecting it from the drop-down box in left-side pane.

Apache Solr Dashboard 2

Conclusion:

In this installation guide, you have learned how to install Apache Solr Enterprise Search Server on CentOS 8. Have a look at Mastering Apache Solr 7.x: An expert guide to advancing, optimizing, and scaling your enterprise search (PAID LINK) by Packt Publishing.

Scroll to Top