Efficient Steps To Install Apache Solr on Rocky Linux 9

Posted on

Efficient Steps To Install Apache Solr on Rocky Linux 9

Efficient Steps To Install Apache Solr on Rocky Linux 9

This tutorial guides you through the process of Install Apache Solr on Rocky Linux 9. Apache Solr, built upon Apache Lucene, is a powerful open-source search platform providing distributed indexing, replication, and query capabilities. It’s a robust NoSQL database with transactional support, making it suitable for a wide array of applications that require fast and efficient search functionality.

You can follow this guide on the Orcacore website to start your Apache Solr in the latest version on Rocky Linux 9.

Before diving into the installation, ensure you’re logged into your Rocky Linux 9 server as a non-root user with sudo privileges. It’s also crucial to have a basic firewall configured for security. If you haven’t already done so, refer to our article on Initial Server Setup with Rocky Linux 9 for detailed instructions.

With the preliminary steps completed, let’s proceed with the following steps to Install Apache Solr on Rocky Linux 9.

Step 1 – Install Java on Rocky Linux 9

Java is a prerequisite for running Apache Solr. Start by updating your system’s package repository:

sudo dnf update -y

Next, install the EPEL (Extra Packages for Enterprise Linux) repository, which contains additional packages not available in the default repositories:

sudo dnf install epel-release -y

Now, install the latest OpenJDK version:

sudo dnf install java-latest-openjdk -y

Verify the Java installation by checking its version:

java -version

You should see output similar to the following:

**Output**
openjdk version "20.0.1" 2023-04-18
OpenJDK Runtime Environment (Red_Hat-20.0.1.0.9-4.rolling.el9) (build 20.0.1+9)
OpenJDK 64-Bit Server VM (Red_Hat-20.0.1.0.9-4.rolling.el9) (build 20.0.1+9, mixed mode, sharing)

Step 2 – Download and Run Apache Solr on Rocky Linux 9

Visit the Apache Solr Downloads page to find the latest Solr version.

At the time of writing, the latest version of Solr was 9.3.0.

Download the Apache Solr distribution using the wget command:

sudo wget https://dlcdn.apache.org/solr/solr/9.3.0/solr-9.3.0.tgz

Extract the downloaded archive:

sudo tar xzf solr-9.3.0.tgz

Note: If the tar command is not installed, install it with:

sudo dnf install tar -y

Now, Install Apache Solr on Rocky Linux 9 using the provided installation script:

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

During the installation, you might encounter warnings about file and process limits. To address these, adjust the security limits as required by Apache Solr. Open the /etc/security/limits.conf file using your preferred text editor (e.g., vi):

sudo vi /etc/security/limits.conf

Add the following lines to the end of the file:

...
*               soft    nofile      65000
*               hard    nofile      65000
*               soft    nproc       65000
*               hard    nproc       65000

Save the changes and close the file.

Restart Apache Solr on Rocky Linux 9 to apply the updated limits:

sudo su - solr -c "/opt/solr/bin/solr restart"

Step 3 – Configure Firewall for Apache Solr

Assuming you have already enabled the firewall, allow traffic on port 8983, which is the default port for Solr:

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

Reload the firewall to activate the new rule:

sudo firewall-cmd --reload

Step 4 – Access Apache Solr Web Interface

Access the Apache Solr web interface by navigating to your server’s IP address followed by port 8983 in your web browser:

http://<your-server-ip-address>:8983/solr

You should now see the Apache Solr dashboard.

Solr dashboard
Install Apache Solr on Rocky Linux 9

You have successfully completed the installation.

Conclusion

You have successfully learned to Install Apache Solr on Rocky Linux 9 and access its dashboard through the web interface. Feel free to connect with us on Facebook, Instagram, and Twitter.

Alternative Solutions to Install Apache Solr on Rocky Linux 9

While the above method utilizes the installation script provided with the Solr distribution, alternative approaches can streamline or automate the process. Here are two such alternatives:

1. Using Docker:

Docker provides a containerization platform that simplifies application deployment. Instead of manually installing Solr and its dependencies, you can use a pre-built Solr Docker image. This approach offers several advantages:

  • Isolation: Solr runs in a container, preventing conflicts with other applications on your system.
  • Reproducibility: The Docker image ensures consistent deployment across different environments.
  • Simplified Management: Docker provides tools for managing the Solr container, such as starting, stopping, and restarting.

To use Docker, first, ensure Docker is installed on your Rocky Linux 9 system. Follow the official Docker documentation for installation instructions. Then, pull the official Solr image from Docker Hub:

sudo docker pull solr

Once the image is downloaded, you can run a Solr container:

sudo docker run -d -p 8983:8983 -t solr solr:9.3.0

This command does the following:

  • docker run: Creates and starts a new container.
  • -d: Runs the container in detached mode (in the background).
  • -p 8983:8983: Maps port 8983 on the host to port 8983 in the container.
  • -t solr: Specifies the Docker image to use.
  • solr:9.3.0: Specifies the image tag.

You can now access the Solr web interface at http://<your-server-ip-address>:8983/solr.

2. Ansible Automation:

Ansible is an automation tool that allows you to define and execute infrastructure as code. You can create an Ansible playbook to automate the Install Apache Solr on Rocky Linux 9 process. This approach is particularly useful for deploying Solr across multiple servers or for ensuring consistent configurations.

Here’s an example of an Ansible playbook to install Solr:

---
- hosts: solr_servers
  become: true
  tasks:
    - name: Update package cache
      dnf:
        update_cache: yes

    - name: Install Java
      dnf:
        name: java-latest-openjdk
        state: present

    - name: Download Solr
      get_url:
        url: https://dlcdn.apache.org/solr/solr/9.3.0/solr-9.3.0.tgz
        dest: /tmp/solr-9.3.0.tgz

    - name: Extract Solr
      unarchive:
        src: /tmp/solr-9.3.0.tgz
        dest: /opt
        creates: /opt/solr-9.3.0

    - name: Install Solr service
      shell: bash /opt/solr-9.3.0/bin/install_solr_service.sh /tmp/solr-9.3.0.tgz
      args:
        chdir: /opt

    - name: Set file limits
      lineinfile:
        path: /etc/security/limits.conf
        line: "{{ item }}"
      loop:
        - "*               soft    nofile          65000"
        - "*               hard    nofile          65000"
        - "*               soft    nproc           65000"
        - "*               hard    nproc           65000"

    - name: Restart Solr
      service:
        name: solr
        state: restarted

This playbook defines the following tasks:

  • Updates the package cache.
  • Installs Java.
  • Downloads the Solr distribution.
  • Extracts the Solr archive.
  • Installs the Solr service using the installation script.
  • Sets the required file limits.
  • Restarts the Solr service.

To use this playbook, you need to have Ansible installed and configured. Save the playbook to a file (e.g., solr_install.yml) and run it using the ansible-playbook command:

ansible-playbook solr_install.yml -i <inventory_file>

Replace <inventory_file> with the path to your Ansible inventory file, which defines the target servers.

These alternative methods offer different advantages depending on your specific needs and environment. Docker provides a quick and easy way to deploy Solr in an isolated environment, while Ansible allows you to automate the installation process across multiple servers, making it suitable for larger deployments and consistent configurations when you Install Apache Solr on Rocky Linux 9.

Leave a Reply

Your email address will not be published. Required fields are marked *