Install Latest Apache Solr on Debian 12 Bookworm: Free Enterprise-search Platform

Posted on

Install Latest Apache Solr on Debian 12 Bookworm: Free Enterprise-search Platform

Install Latest Apache Solr on Debian 12 Bookworm: Free Enterprise-search Platform

In this guide, we’ll walk you through the process to Install Latest Apache Solr on Debian 12 Bookworm. Apache Solr is a powerful, free, and open-source search engine built upon the Apache Lucene library. Beyond its search capabilities, it can also function as a document-based NoSQL database with transactional support, suitable for storage purposes, and even as a key-value store. Let’s get started with Install Latest Apache Solr on Debian 12 Bookworm.

To successfully Install Latest Apache Solr on Debian 12 Bookworm, you’ll need a few prerequisites:

  1. Server Access: You must have access to your Debian 12 server as a non-root user with sudo privileges. If you haven’t already set this up, refer to this guide on Initial Server Setup with Debian 12 Bookworm.

  2. Java JDK: You need to have Java JDK installed on your server. Instructions for this can be found in this guide: How To Install Java with Apt on Debian 12 Bookworm.

Once these prerequisites are met, you can proceed with the following steps to Install Latest Apache Solr on Debian 12 Bookworm.

Step 1 – Verify Java Installation For Apache Solr

We’re assuming you’ve already installed the JDK. To confirm, check the Java version using the following command:

java -version

Debian 12 typically includes Java 17 by default:

**Output**
openjdk version "17.0.7" 2023-04-18
OpenJDK Runtime Environment (build 17.0.7+7-Debian-1deb12u1)
OpenJDK 64-Bit Server VM (build 17.0.7+7-Debian-1deb12u1, mixed mode, sharing)

Step 2 – Download and Extract Solr Binary Package on Debian 12

Visit the Solr Downloads page and use the wget command to download the latest binary package.

The latest release of Apache Solr at the current time is Solr 9.2.1.

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

Extract the downloaded file:

sudo tar xzf solr-9.2.1.tgz

Step 3 – Install Solr on Debian 12 Bookworm

Start the Apache Solr installation by running the following command:

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

Upon completion, you should see output similar to this:

**Output**
Service solr installed.
Customize Solr startup configuration in /etc/default/solr.in.sh
● solr.service - LSB: Controls Apache Solr as a Service
     Loaded: loaded (/etc/init.d/solr; generated)
     Active: **active** (**exited**) since Tue 2023-07-18 08:29:35 EDT; 5s ago
       Docs: man:systemd-sysv-generator(8)
    Process: 9580 ExecStart=/etc/init.d/solr start (code=exited, status=0/SUCCESS)
        CPU: 18ms
...

Step 4 – How To Manage Apache Solr Service?

Start the Solr service:

sudo systemctl start solr

Enable Solr to start at boot:

/lib/systemd/systemd-sysv-install enable solr

Check the Solr service status:

sudo systemctl status solr

Step 5 – Create a New Solr Collection

Create a new Solr collection to test the functionality:

su - solr -c "/opt/solr/bin/solr create -c newcollection -n data_driven_schema_configs"

You should see this output:

**Output**
Created new core 'newcollection'

Step 6 – Configure Apache Solr on Debian 12

By default, Apache Solr runs on localhost only. To allow public access over networks, edit the /etc/default/solr.in.sh configuration file.

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

Search for the SOLR_JETTY_HOST variable, uncomment it, and set its value to "0.0.0.0":

SOLR_JETTY_HOST="0.0.0.0"

Save and close the file. Restart the Solr service to apply the changes:

sudo systemctl restart solr

Check the Apache Solr listening host address:

sudo ss -tupln  | grep 8983
**Output**
tcp LISTEN 0 50 *:8983 *:* users:(("java",pid=7009,fd=136))

Step 7 – How To Access Apache Solr Web Interface?

You have successfully learned to Install Latest Apache Solr on Debian 12 Bookworm. Access the Solr web interface by typing your server’s IP address in your web browser followed by :8983:

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

You will see the Apache Solr dashboard screen:

[Image of Solr dashboard]

From the core selector on the left side, you can choose your collection to view the statistics of your collection created in the previous step.

Alternative Installation Methods

While the provided method using the official Solr installation script is a straightforward approach, there are alternative ways to achieve the same result. Here are two options:

Alternative 1: Manual Installation and Configuration

Instead of relying on the install_solr_service.sh script, you can manually configure Solr as a systemd service. This approach provides more control over the installation process and allows for greater customization.

  1. Download and Extract: Follow steps 1 and 2 of the original guide to download and extract the Solr binary package.

  2. Create a Solr User: Create a dedicated user for running Solr.

    sudo adduser --system solr
  3. Move Solr Files: Move the extracted Solr directory to /opt/solr:

    sudo mv solr-9.2.1 /opt/solr
    sudo chown -R solr:solr /opt/solr
  4. Create a Systemd Service File: Create a systemd service file at /etc/systemd/system/solr.service with the following content. Adjust paths accordingly if you chose a different installation location.

    [Unit]
    Description=Apache Solr
    After=network.target
    
    [Service]
    User=solr
    Group=solr
    Type=forking
    ExecStart=/opt/solr/bin/solr start -f
    ExecStop=/opt/solr/bin/solr stop
    Restart=on-failure
    KillMode=process
    
    [Install]
    WantedBy=multi-user.target
  5. Reload Systemd and Enable the Service:

    sudo systemctl daemon-reload
    sudo systemctl enable solr
    sudo systemctl start solr
  6. Configure Solr: As with the original method, you’ll need to configure /etc/default/solr.in.sh to set the host and other settings.

Alternative 2: Using Docker

Docker provides a containerized environment for running applications, including Solr. This method simplifies deployment and ensures consistency across different environments.

  1. Install Docker: If you don’t have Docker installed, install it:

    sudo apt update
    sudo apt install docker.io
    sudo systemctl start docker
    sudo systemctl enable docker
  2. Pull the Solr Docker Image: Pull the official Solr Docker image from Docker Hub:

    docker pull solr
  3. Run the Solr Container: Run a Solr container with the desired configuration. This example exposes port 8983 and mounts a volume for persistent data storage:

    docker run -d -p 8983:8983 -v /opt/solr/data:/opt/solr/server/solr/mycores solr solr-create -c mycollection -n data_driven_schema_configs
    • -d: Runs the container in detached mode (background).
    • -p 8983:8983: Maps port 8983 on the host to port 8983 in the container.
    • -v /opt/solr/data:/opt/solr/server/solr/mycores: Mounts a volume to persist data. Replace /opt/solr/data with your desired host directory. The solr-create command creates a new core named mycollection with the data_driven_schema_configs.
  4. Access the Solr Web Interface: Access the Solr web interface using your server’s IP address and port 8983, similar to the original method.

These alternative approaches offer different levels of control and complexity. The manual installation method provides granular control over the configuration, while Docker simplifies deployment and ensures consistency. Choose the method that best suits your needs and technical expertise.

Conclusion

You have successfully learned to Install Latest Apache Solr on Debian 12 Bookworm and Access it via Web Interface. Hope you enjoy it. Remember to choose the installation method that best suits your specific needs and expertise. With Solr up and running, you can now leverage its powerful search and data management capabilities for your applications.

You may also be interested in these articles:

Install and Use Podman on Debian 12 Bookworm

4 Ways to Find Which Process Listening on a Port on Debian 11

Leave a Reply

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