FedoraRHEL Based

How To Install Apache Solr on Fedora 41

Install Apache Solr on Fedora 41

In this tutorial, we will show you how to install Apache Solr on Fedora 41. Apache Solr, built on Apache Lucene, offers advanced full-text search capabilities, along with features like faceting, highlighting, and geospatial search. Its scalability and flexibility make it an excellent choice for businesses of all sizes. By installing Solr on Fedora 41, you’ll be leveraging a stable and secure Linux distribution known for its cutting-edge features and strong community support.

In this tutorial, we’ll cover everything from system preparation to post-installation configuration, ensuring you have a fully functional Solr instance ready for your projects. Whether you’re a seasoned Linux administrator or a newcomer to the world of search engines, this guide will provide you with the knowledge and steps needed to successfully deploy Solr on your Fedora 41 system.

Prerequisites

Before we dive into the installation process, let’s ensure you have everything needed to proceed smoothly:

  • A Fedora 41 system with at least 2GB of RAM and 10GB of free disk space
  • Root access or sudo privileges on your Fedora machine
  • Basic familiarity with Linux command-line operations
  • A stable internet connection for downloading packages
  • Access to a terminal or SSH connection to your Fedora server

Having these prerequisites in place will help ensure a smooth installation process and optimal performance of your Solr instance.

System Preparation

Proper system preparation is crucial for a successful Solr installation. Let’s start by updating your Fedora system and installing necessary dependencies.

Updating System Packages

First, update your system packages to ensure you have the latest security patches and software versions:

sudo dnf update -y

Installing Required Dependencies

Solr requires certain packages to function correctly. Install them using the following command:

sudo dnf install -y wget unzip lsof

Setting Up System Limits

Solr can be resource-intensive, so it’s important to adjust system limits. Create a new file named solr.conf in the /etc/security/limits.d/ directory:

sudo nano /etc/security/limits.d/solr.conf

Add the following lines to the file:

solr soft nofile 65000
solr hard nofile 65000
solr soft nproc 65000
solr hard nproc 65000

Save and close the file.

Configuring Firewall Settings

If you have firewalld enabled, you’ll need to open the port Solr uses (typically 8983). Run these commands:

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

Java Installation

Apache Solr is a Java-based application, so installing Java is a crucial step in the process.

Installing OpenJDK 11

Fedora 41 comes with OpenJDK 11, which is compatible with the latest versions of Solr. Install it using:

sudo dnf install -y java-11-openjdk java-11-openjdk-devel

Verifying Java Installation

After installation, verify that Java is correctly installed by checking its version:

java -version

You should see output indicating Java 11 is installed.

Setting JAVA_HOME Environment Variable

Set the JAVA_HOME environment variable by adding it to your .bash_profile file:

echo "export JAVA_HOME=$(dirname $(dirname $(readlink $(readlink $(which javac)))))" >> ~/.bash_profile
source ~/.bash_profile

Testing Java Configuration

Verify that JAVA_HOME is set correctly:

echo $JAVA_HOME

This should output the path to your Java installation.

Apache Solr Installation

Now that we have our system prepared and Java installed, let’s proceed with the Apache Solr installation.

Downloading Latest Solr Version

First, download the latest stable version of Solr. At the time of writing, it’s version 9.3.0, but you should check the official Apache Solr website for the most recent version:

wget https://downloads.apache.org/lucene/solr/9.3.0/solr-9.3.0.tgz

Extracting Installation Files

Extract the downloaded tarball:

tar xzf solr-9.3.0.tgz solr-9.3.0/bin/install_solr_service.sh --strip-components=2

Running Installation Script

Now, run the installation script:

sudo bash ./install_solr_service.sh solr-9.3.0.tgz

This script will install Solr as a service, create a Solr user, and set up the necessary directory structure.

Directory Structure Explanation

After installation, Solr’s directory structure will look like this:

  • /opt/solr: Solr installation directory
  • /var/solr: Data directory for Solr cores
  • /etc/default/solr.in.sh: Configuration file for Solr service

Service Configuration

The installation script automatically configures Solr as a systemd service. You can manage it using standard systemctl commands.

Post-Installation Configuration

With Solr installed, let’s configure and start the service.

Starting Solr Service

Start the Solr service using systemctl:

sudo systemctl start solr

Enabling Automatic Startup

To ensure Solr starts automatically on system boot:

sudo systemctl enable solr

Verifying Installation

Check if Solr is running correctly:

sudo systemctl status solr

You should see output indicating that Solr is active and running.

Accessing Web Interface

Solr provides a web interface for management and querying. Access it by opening a web browser and navigating to:

http://your_server_ip:8983/solr/

Install Apache Solr on Fedora 41

Basic Security Settings

By default, Solr’s web interface is accessible without authentication. For production environments, it’s crucial to set up basic authentication. Edit the solr.in.sh file:

sudo nano /etc/default/solr.in.sh

Add the following lines:

SOLR_AUTH_TYPE="basic"
SOLR_AUTHENTICATION_OPTS="-Dbasicauth=solr:SolrRocks"

Replace “SolrRocks” with a strong password. Restart Solr for changes to take effect:

sudo systemctl restart solr

Creating Your First Core

A Solr core is where you store your data and configuration. Let’s create a sample core.

Core Creation Process

Use the following command to create a new core named “mycore”:

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

Basic Configuration

The core’s configuration files are located in /var/solr/data/mycore/conf/. You can customize managed-schema and solrconfig.xml to fit your needs.

Verification Steps

Verify that your core was created successfully by checking the Solr admin interface. You should see “mycore” listed under the “Core Admin” section.

Performance Optimization

Optimizing Solr’s performance is crucial for efficient operation, especially in production environments.

Memory Settings

Adjust Solr’s memory allocation in /etc/default/solr.in.sh:

SOLR_JAVA_MEM="-Xms2g -Xmx4g"

Adjust these values based on your server’s available memory.

JVM Configuration

Fine-tune JVM settings for better performance. Add the following to /etc/default/solr.in.sh:

GC_TUNE="-XX:+UseG1GC -XX:+PerfDisableSharedMem -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=250 -XX:+UseLargePages -XX:+AlwaysPreTouch"

System Limits Adjustment

We’ve already set some system limits earlier, but you may need to adjust them further based on your specific use case and server resources.

Performance Testing

Use Apache JMeter or Solr’s built-in logging to monitor and test your Solr instance’s performance under various load conditions.

Troubleshooting Common Issues

Even with careful installation, you might encounter some issues. Here are solutions to common problems:

Port Conflicts

If Solr fails to start due to a port conflict, change the port in /etc/default/solr.in.sh:

SOLR_PORT="8984"

Permission Issues

Ensure the Solr user has proper permissions:

sudo chown -R solr:solr /var/solr

Service Startup Problems

If Solr fails to start, check the logs:

sudo journalctl -u solr

Connection Errors

If you can’t connect to Solr, ensure your firewall settings are correct and Solr is bound to the correct interface in solr.in.sh.

Security Considerations

Security is paramount when deploying Solr, especially in production environments.

Basic Security Measures

Always change default credentials and restrict access to the Solr admin interface.

Authentication Setup

Implement strong authentication mechanisms. Consider using LDAP or Kerberos for enterprise environments.

SSL/TLS Configuration

Enable SSL/TLS to encrypt traffic to and from Solr. Generate a certificate and configure Solr to use HTTPS.

Firewall Rules

Implement strict firewall rules to allow only necessary traffic to your Solr instance.

Congratulations! You have successfully installed Apache Solr. Thanks for using this tutorial for installing the Apache Solr on your Fedora 41 system. For additional or useful information, we recommend you check the official Apache website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button