1080*80 ad

Installing Apache Solr on Ubuntu 20.04: A Guide to the Latest Version

How to Install Apache Solr on Ubuntu 20.04: A Step-by-Step Guide

Apache Solr is a powerful, open-source enterprise search platform built on Java. It enables you to build sophisticated search applications with features like full-text search, hit highlighting, faceted search, and real-time indexing. If you need to add robust search capabilities to your application, Solr is an excellent choice.

This comprehensive guide will walk you through installing and configuring the latest version of Apache Solr on an Ubuntu 20.04 server, ensuring a stable and secure setup.

Prerequisites

Before we begin, ensure you have the following:

  • An Ubuntu 20.04 server.
  • A non-root user with sudo privileges.

Step 1: Update System and Install Java

Solr is a Java application, so the Java Runtime Environment (JRE) is a mandatory dependency. We will install the recommended version from Ubuntu’s default repositories.

First, update your server’s package index to ensure you have access to the latest software versions.

sudo apt update
sudo apt upgrade

Next, install the OpenJDK package, which is the open-source implementation of the Java Platform.

sudo apt install default-jdk -y

Once the installation is complete, you can verify that Java is correctly installed by checking its version.

java -version

You should see output confirming the OpenJDK version, indicating that your system is ready for Solr.

Step 2: Download and Verify Apache Solr

It is always best practice to download the latest stable version of Solr directly from the official Apache project website.

Navigate to your home directory and use wget to download the Solr installation package. You can find the latest version number on the Apache Solr Downloads page.

cd ~
wget https://www.apache.org/dyn/closer.lua/solr/solr/9.6.1/solr-9.6.1.tgz

(Note: Replace 9.6.1 with the current latest version if a newer one is available.)

For security, it is crucial to verify the integrity of the downloaded file. Download the corresponding ASC signature file from the Apache distribution directory.

wget https://downloads.apache.org/solr/solr/9.6.1/solr-9.6.1.tgz.asc

Next, download the KEYS file containing the public keys used by Apache Solr developers.

wget https://downloads.apache.org/solr/KEYS

Import the keys into your GPG keyring and then verify the downloaded archive.

gpg --import KEYS
gpg --verify solr-9.6.1.tgz.asc solr-9.6.1.tgz

You should see a “Good signature” message in the output. This confirms the file is authentic and has not been tampered with.

Step 3: Run the Solr Installation Script

The downloaded Solr package includes a convenient installation script that handles all the necessary setup tasks, including creating a dedicated solr user and configuring Solr to run as a systemd service.

First, extract the contents of the downloaded .tgz archive.

tar xzf solr-9.6.1.tgz

Now, navigate into the extracted directory’s bin folder and run the installation script.

cd solr-9.6.1/bin/
sudo ./install_solr_service.sh ../../solr-9.6.1.tgz

The script will automatically:

  • Create a solr user and group.
  • Install Solr to the /opt/solr directory.
  • Create a data directory at /var/solr.
  • Set up a systemd service file to manage the Solr process.

Step 4: Enable and Start the Solr Service

With the installation complete, you can now manage Solr using systemctl commands.

Start the Solr service:

sudo systemctl start solr

To ensure Solr automatically starts whenever the server reboots, enable the service:

sudo systemctl enable solr

Finally, check the status of the service to confirm it is running without any errors.

sudo systemctl status solr

You should see an “active (running)” status, confirming that your Solr instance is live. By default, Solr listens on port 8983.

Step 5: Open the Firewall Port

If you are running the UFW firewall on your server, you must open the port Solr uses to allow external connections.

sudo ufw allow 8983

This command opens port 8983, allowing you to access the Solr web administration dashboard from your browser.

Step 6: Create Your First Solr Core

A Solr “core” (or “collection” in SolrCloud mode) is a single running index with its own configuration files. To make Solr functional, you need to create at least one core.

You can easily create a new core using the solr command-line tool. It is best practice to perform this action as the solr user.

sudo -u solr /opt/solr/bin/solr create -c my_first_core -n data_driven_schema_configs

This command creates a new core named my_first_core using a data-driven schema configuration, which is a flexible starting point.

You have now successfully installed and configured a running instance of Apache Solr! You can access the powerful web-based admin UI by navigating to http://your_server_ip:8983 in your web browser. From the dashboard, select your newly created core from the “Core Selector” dropdown to begin indexing and querying data.

Important Security Considerations

Your new Solr installation is open to the public by default. For any production environment, it is critical to implement security measures:

  • Enable Authentication: Use Solr’s built-in Basic Authentication or integrate with LDAP/Kerberos to protect your admin UI and APIs.
  • Use a Reverse Proxy: Place a web server like Nginx or Apache in front of Solr to handle SSL/TLS encryption, access control, and request routing.
  • Firewall Rules: If possible, restrict access to port 8983 to only trusted IP addresses.
  • Keep Solr Updated: Regularly check for and apply security patches and updates to protect against known vulnerabilities.

Source: https://kifarunix.com/install-latest-apache-solr-on-ubuntu-20-04/

900*80 ad

      1080*80 ad