
How to Install Apache Solr on CentOS 8: A Step-by-Step Guide
Apache Solr is a powerful, open-source search platform built on Apache Lucene. It provides enterprise-level full-text search, real-time indexing, and dynamic clustering, making it a popular choice for powering search and navigation features on websites and applications. If you’re running a CentOS 8 server, getting Solr up and running is a straightforward process.
This guide provides a comprehensive walkthrough for installing Apache Solr on CentOS 8, from initial system setup to creating your first search core.
Prerequisites
Before you begin, ensure you have the following:
- A server running a fresh installation of CentOS 8.
- A non-root user with
sudoprivileges. - Access to a terminal or command-line interface.
Step 1: Install Java and Update Your System
Solr is a Java-based application, so the Java Development Kit (JDK) is a mandatory prerequisite. We will install OpenJDK 11, which is a stable and widely compatible version.
First, update your system’s package index to ensure you have the latest information on available software.
sudo dnf update -y
Next, install the OpenJDK package.
sudo dnf install java-11-openjdk-devel -y
Once the installation is complete, you can verify that Java was installed correctly by checking its version.
java -version
You should see output confirming that OpenJDK version 11 is installed, which means your server is now ready for Solr.
Step 2: Download and Install Apache Solr
We will download the official binary release of Apache Solr directly from their website. While you can visit the official Apache Solr downloads page to find the absolute latest version, we will use wget to download a recent stable release directly.
Navigate to the /tmp directory, a good location for temporary downloads.
cd /tmp
Now, download the Solr archive. Be sure to replace 9.0.0 with the latest version number if a newer one is available.
wget https://downloads.apache.org/lucene/solr/9.0.0/solr-9.0.0.tgz
After the download is complete, you will find an installation script packaged within the archive. Extract the archive to access this script.
tar xzf solr-9.0.0.tgz
Step 3: Run the Official Installation Script
The Solr package includes a convenient installation script that automates much of the setup process. This script will:
- Create a dedicated
solruser and group. - Extract the Solr distribution to
/opt. - Set up a
systemdservice file to manage Solr as a background service.
Navigate into the extracted directory and run the script.
cd solr-9.0.0/bin/
sudo ./install_solr_service.sh /tmp/solr-9.0.0.tgz
The script will handle the installation and display the configuration details upon completion, including the service name and the directory locations.
Step 4: Start and Enable the Solr Service
With the service installed, the next step is to start it and configure it to launch automatically on system boot.
To start the Solr service, use the following command:
sudo systemctl start solr
To ensure Solr automatically restarts after a server reboot, you must enable the service.
sudo systemctl enable solr
Finally, you can check the status of the service to confirm it is running without errors.
sudo systemctl status solr
If the service is active and running, you’re ready for the final configuration step.
Step 5: Configure the Firewall
By default, the CentOS 8 firewall will block external access to the Solr port. You need to create a rule to allow traffic. Apache Solr runs on port 8983 by default.
Use the firewall-cmd utility to add a permanent rule for this port.
sudo firewall-cmd --permanent --add-port=8983/tcp
After adding the rule, you must reload the firewall for the changes to take effect.
sudo firewall-cmd --reload
Your server is now configured to accept connections to the Solr web interface.
Verifying the Installation and Creating a Core
The best way to confirm that your installation is fully functional is by accessing the web-based administration panel and creating your first Solr “core.” A core is essentially a single search index and its associated configuration files.
Accessing the Solr Admin UI
Open your web browser and navigate to the following address, replacing your_server_ip with your server’s public IP address or domain name:
http://your_server_ip:8983
You should be greeted by the Solr Admin dashboard. This interface provides detailed information about your Solr instance, including memory usage, system uptime, and JVM arguments.
Creating Your First Solr Core
To make Solr useful, you need to create a core where your data will be indexed. You can do this easily from the command line using the solr user.
The following command will create a new core named my_new_core using a pre-configured, data-driven schema.
sudo -u solr /opt/solr/bin/solr create -c my_new_core -n data_driven_schema_configs
After running the command, refresh the Solr Admin UI in your browser. You can now select my_new_core from the “Core Selector” dropdown on the left-hand menu to manage and query your new index.
Important Security Considerations
Now that Solr is running, it’s crucial to consider security, especially in a production environment.
- Dedicated User: The installation script automatically created a
solruser. Never run Solr as the root user, as this poses a significant security risk. - Firewall Access: Only open port 8983 to trusted IP addresses if possible. If the search service is only used by your web application on the same server, consider binding Solr to
127.0.0.1(localhost) to prevent external access entirely. - Authentication: For production use, it is highly recommended to enable Solr’s built-in authentication and authorization plugins to secure the admin panel and API endpoints. Never expose an unsecured Solr instance to the public internet.
Conclusion
You have successfully installed and configured a running Apache Solr instance on your CentOS 8 server. By following these steps, you have set up the Java prerequisite, installed the Solr service, configured the firewall, and created your first core. Your powerful new search platform is now ready for you to start indexing documents and building sophisticated search applications.
Source: https://kifarunix.com/install-latest-apache-solr-on-centos-8/


