How To Install Apache Solr on CentOS Stream 10
Apache Solr is recognized for its high performance, scalability, and adaptability when indexing vast collections of data. Its distributed indexing feature and fault-tolerant nature make it suitable for enterprise applications. It also offers a web-based administrative dashboard to simplify tasks like managing collections, analyzing logs, and tuning performance. On the other hand, CentOS Stream 10 serves as the upstream (rolling) release for CentOS, receiving updates ahead of Red Hat Enterprise Linux. This forward-focused approach ensures administrators can experiment with technology updates without jeopardizing system stability.
Combining these two technologies results in a modern, functionality-rich platform. The instructions below present a step-by-step procedure for installing, configuring, and testing Apache Solr on CentOS Stream 10.
Prerequisites and System Requirements
Before proceeding, confirm that your server meets the hardware and software prerequisites required for a smooth installation of Apache Solr. While a minimal system can technically run Solr, more CPU and RAM resources are advisable for production environments. Aim for at least two CPU cores and 2 GB of memory for basic setups. High-traffic or data-intensive use cases may require significantly more.
- Operating System: CentOS Stream 10.
- Software Dependencies: OpenJDK or Oracle Java (version 8 or later). Tools such as
dnf
,wget
,tar
, andlsof
should be present. - User Permissions: Root account or
sudo
privileges to install packages, configure the firewall, and manage system services. - Networking: An available TCP port (default is 8983) for Solr’s HTTP-based interface.
Having Java installed and correctly configured is critical for Apache Solr because Solr runs on the Java Virtual Machine. Set the JAVA_HOME environment variable to ensure that any Java-based application recognizes the correct path to the JRE or JDK.
Updating Packages on CentOS Stream 10
Running a streamlined and secure environment for Apache Solr begins by ensuring CentOS Stream 10 is fully updated. The process is relatively straightforward. Begin with a short command, then let it run until it completes.
sudo dnf update -y
This command updates the package index and refreshes already installed packages to their latest versions. It occasionally prompts you about updated dependencies or kernel packages. If you see any updates for critical system components, let them install. After completion, reboot the server if a new kernel version was installed:
sudo reboot
Keeping the system current is recommended, especially for a secure production environment. Regular updates help fix bugs, patch known vulnerabilities, and offer performance enhancements that benefit your Apache Solr installation.
Installing Java
Apache Solr depends on Java to drive its powerful indexing and query capabilities. OpenJDK represents a reliable solution for organizations seeking a straightforward approach to Java. Oracle Java is another option, but in most cases, OpenJDK is perfectly adequate and free.
To install OpenJDK on CentOS Stream 10:
sudo dnf install java-17-openjdk -y
After installation, verify the version of Java using:
java -version
It should display something similar to: openjdk version “17.x.x” …. If the version reflects Java 17 or later, the environment is compatible with Apache Solr. Optionally, set JAVA_HOME in the /etc/profile
or ~/.bashrc
:
echo "export JAVA_HOME=/usr/lib/jvm/java-17-openjdk" | sudo tee -a /etc/profile
source /etc/profile
Ensuring JAVA_HOME is properly defined vanquishes environment variable conflicts that may trigger installation or runtime errors in Solr.
Downloading the Apache Solr Package
Apache Solr packages are available from the official Apache Software Foundation website. Access the downloads page to locate the latest stable version. With CentOS Stream 10, a stable or long-term release of Solr helps ensure optimal compatibility and fewer regression issues.
Use wget
to download the latest Solr archive:
cd /tmp
wget https://downloads.apache.org/lucene/solr/[VERSION]/solr-[VERSION].tgz
Replace [VERSION] with the latest release. This compressed tarball includes the Solr source, scripts, and essential configuration files. Confirm that the file downloaded correctly and ensure you have enough disk space before proceeding.
Extracting and Installing Apache Solr
The included installation script, install_solr_service.sh
, simplifies the process by automating several steps, such as managing directories and creating a dedicated user. First, extract the script from the tarball:
tar xzf solr-[VERSION].tgz solr-[VERSION]/bin/install_solr_service.sh --strip-components=2
This command unpacks only the script into the current directory, removing unneeded components. Then, run the script:
sudo bash ./install_solr_service.sh solr-[VERSION].tgz
The script creates a dedicated solr user if none exists and installs Solr in /opt
by default. It also creates a symlink /opt/solr
, sets up core directories under /var/solr
, and positions an init script (or systemd service file) to manage the Solr service. Monitor the script’s output carefully for warnings, especially regarding the open file limit. A recommendation often appears instructing you to increase the default open file limit from 1024 to 65000:
sudo nano /etc/security/limits.conf
# Add the following lines:
solr soft nofile 65000
solr hard nofile 65000
Raising the file descriptor limit helps prevent any “Too many open files” errors in busy indexing environments.
Configuring the Firewall for Apache Solr
Solr by default listens on port 8983 for incoming HTTP requests. If a firewall is present (commonly the case on CentOS Stream 10 servers), it is essential to open that port so traffic can reach the Solr instance.
Execute the following commands:
sudo firewall-cmd --add-port=8983/tcp --permanent
sudo firewall-cmd --reload
These commands permanently enable traffic on port 8983 and reload the firewall configuration so the update takes immediate effect. Double-check your server’s network environment if you use external firewalls or NAT rules. Also confirm that port 8983 is not blocked upstream by hosting providers or any network configuration, especially in production scenarios.
Starting and Testing the Solr Service
Upon successful installation, the script automatically registers Apache Solr as a service. This means standard commands such as service
or systemctl
can manage its behavior. Use one of the following protocols:
sudo service solr start
or
sudo systemctl start solr
Check Solr’s status to ensure the service is running smoothly:
sudo service solr status
If it shows something along the lines of “Solr is running” with an associated process ID, then everything is operational. Next, navigate to the Solr Admin Interface using a web browser. Visit:
http://<your-server-ip>:8983/solr
This interface includes multiple sections for monitoring, configuring, and analyzing the server. If the dashboard loads, it indicates that the HTTP interface is open. In case you are unable to access the dash, confirm that the correct port was opened in the firewall, that Solr is actually running, and that your server’s IP address is valid for external connectivity.
Solr Security and Basic Authentication
Solr’s Admin UI does not use a default password, leaving it exposed if the port is publicly accessible. For production, it is prudent to activate security measures. One method is to set up Basic Authentication through Solr’s internal security configuration.
- Locate the Configuration File:
The primary settings for authentication can be stored in thesolr.in.sh
file or a designated configuration snippet. - Create Security JSON:
Generate or update asecurity.json
file with credentials. For instance:{ "authentication":{ "blockUnknown": true, "class":"solr.BasicAuthPlugin", "credentials":{ "solr":"<BASE64_ENCODED_PASSWORD>" } }, "authorization":{ "class":"solr.RuleBasedAuthorizationPlugin", "user-role":{ "solr":"admin" }, "permissions":[{ "name":"all", "role":"admin" }] } }
- Apply Security Config:
Uploadsecurity.json
to Solr using thebin/solr
script./opt/solr/bin/solr zk cp file:/path/to/security.json zk:/security.json -z localhost:9983
Restart Solr to ensure the settings take effect. Once complete, the Admin UI and API endpoints require a username and password to proceed, adding a much-needed layer of protection. For even tighter security, consider employing a VPN or restricting public HTTP access behind a reverse proxy like Nginx or Apache HTTPD configured for SSL/TLS.
Adjusting Memory and Performance Settings
Solr includes built-in defaults convenient for testing but not necessarily optimal for production. The environment variable SOLR_HEAP controls memory allocation. Most production tasks benefit from at least 8GB, depending on data volumes and concurrency:
sudo nano /etc/default/solr.in.sh
# Example:
SOLR_HEAP="8g"
Further adjustments can be made to GC_TUNE for more advanced garbage collection strategies. Tuning garbage collection can help reduce system pauses during heavy indexing, especially if large amounts of data or queries are processed.
Performance optimization is multifaceted. In high-throughput scenarios, configuring the underlying Java Virtual Machine and the OS file system significantly impacts your search engine’s throughput. It is also wise to keep an eye on the solr.log
and gc.log
for warning signs of memory pressure or slow queries.
Creating and Managing Solr Cores
Once installation is complete, the next step is to create a core (or multiple cores) to store and index data. A Solr core is essentially an individual index that can hold unique configurations, schemas, and data sets.
sudo su - solr
/opt/solr/bin/solr create -c <core_name> -n data_driven_schema_configs
The above command employs the data-driven schema that automatically adjusts field types when new documents are ingested. For more control, define a custom schema and config sets if your use case demands specialized indexing rules, tokenizers, or analyzers.
Tall indexes or search-heavy traffic can produce performance bottlenecks if the index design is suboptimal. Automate index merges, replicate data across multiple Solr instances, or use SolrCloud for distributed search. Make sure reindexing routines are minimized or well-planned to avoid extended downtime or system slowdowns.
Troubleshooting Tips
Installing Apache Solr on CentOS Stream 10 usually proceeds without major complications, but it’s wise to be prepared for occasional hiccups. Here are typical issues and ways to address them:
- Service Fails to Start: Check if Java is installed and that
java -version
returns the expected result. Also verify theJAVA_HOME
environment variable and open file limits. - Web Interface Not Accessible: Ensure the firewall or SELinux is not blocking port 8983. Look at
journalctl -xe
or/var/log/solr
to pinpoint the error. - Out of Memory Exceptions: Increase
SOLR_HEAP
or revise Java garbage collection settings insolr.in.sh
. Monitor logs for excessive GC activities or memory leaks in custom components. - Error “Too Many Open Files”: Modify
/etc/security/limits.conf
to raise the nofile parameter for the Solr user. The recommended level is65000
or higher. - Authentication or Permission Issues: If Basic Authentication is set, confirm the new credentials are correct. Double-check the
security.json
file or the RuleBasedAuthorizationPlugin settings for typos.
Logs are always the first place to investigate. Inspect the solr.log
in /var/solr/logs
or the system logs to piece together the chain of events leading to an error. That can help uncover misconfiguration, resource limitations, or unexpected interactions with installed plugins.
Uninstallation or Upgrading Apache Solr
It might become necessary to remove or upgrade Apache Solr, particularly if your application demands a newer version or a fresh environment. For removal, follow these steps:
- Stop the Solr service:
sudo service solr stop
- Delete the Solr directories:
sudo rm -rf /opt/solr /var/solr
This method completely removes file traces, so ensure you make backups of important indexes, config sets, or logs prior to executing these commands.
For an upgrade, the typical approach is to download the latest Solr package, shut down the service, run the installation script again, and then copy over existing configuration files or index data. Always review the official Solr release notes for any major version changes that require schema modifications or reindexing.
Congratulations! You have successfully installed Apache Solr. Thanks for using this tutorial for installing the Apache Solr on your CentOS Stream 10 system. For additional or useful information, we recommend you check the official Apache website.