Today we’re diving deep into the world of Apache Solr, a robust open-source search platform that’s perfect for high-powered search and indexing capabilities. From websites to e-commerce, Solr is a go-to solution for streamlined data retrieval. In this guide, we’ll walk you through an engaging step-by-step process on installing Apache Solr on your Debian 12 server, complete with securing it and creating your first Solr index. Ready to get started? Let’s dive in!

Prerequisites

Before we embark on this installation journey, make sure you’ve got the following squared away:

  • A Debian 12 server with at least 4GB of memory.
  • A non-root user with sudo privileges.

Step 1: Java OpenJDK Installation

Solr runs on Java, so we’ll start by setting up Java OpenJDK 17. Here’s how:

  1. Update your package index:
    sudo apt update
  2. Install Java OpenJDK 17:
    sudo apt install default-jdk
  3. Verify the installation:
    java --version

Upon successful installation, you should see that Java OpenJDK 17 is ready to roll.

Step 2: Downloading and Installing Apache Solr

Now, the fun part! Let’s download and install Apache Solr.

  1. Install some necessary utilities:
    sudo apt install curl lsof bc
  2. Download Solr’s binary package using curl. As of this writing, the latest version is 9.4.0:
    curl -qO https://downloads.apache.org/solr/solr/9.4.0/solr-9.4.0.tgz
  3. Extract and run the installer script:
    tar xzf solr-9.4.0.tgz solr-9.4.0/bin/install_solr_service.sh --strip-components=2
    sudo bash ./install_solr_service.sh solr-9.4.0.tgz
  4. Verify the solr service:
    sudo service solr status

Your Apache Solr should now be running like a charm!

Step 3: Configuring Apache Solr

Next, let’s configure our Debian system and Solr to optimize performance.

Configuring Debian

Adjust kernel parameters and limits:

  1. Update the following kernel parameters:
    sudo echo 4294967295 > /proc/sys/kernel/shmmax
    sudo echo 1536 > /proc/sys/vm/nr_hugepages
  2. Adjust user limits in /etc/security/limits.conf:
    solr soft nofile 65000
    solr hard nofile 65000
    solr soft nproc 65000
    solr hard nproc 65000
  3. Verify the limits:
    sudo -H -u solr bash -c "ulimit -aH"

Configuring Solr

Allocate heap memory and bind to a specific IP:

  1. Open Solr’s configuration:
    sudo nano /etc/default/solr.in.sh
  2. Set your desired heap size (4GB in this example) and specify the server IP:
    SOLR_HEAP="4g"
    SOLR_HOST="192.168.10.15"
    SOLR_JETTY_HOST="192.168.10.15"
  3. Restart Solr to apply the changes:
    sudo service solr restart

Visit your Solr web interface at http://192.168.10.15:8983/.

Step 4: Securing Apache Solr

Protect your Solr instance with BasicAuth. Here’s how:

  1. Create a security.json file:
    sudo nano /var/solr/data/security.json
  2. Add the BasicAuth configuration:
    {
      "authentication":{
        "blockUnknown": true,
        "class":"solr.BasicAuthPlugin",
        "credentials":{"solr":"IV0EHq1OnNrj6gvRCwvFwTrZ1 z1oBbnQdiVC3otuq0= Ndd7LKvVBAaZIF0QAVi1ekCfAJXr1GGfLtRUXhgrF8c="},
        "realm":"My Solr users",
        "forwardCredentials": false
      },
      "authorization":{
        "class":"solr.RuleBasedAuthorizationPlugin",
        "permissions":[{"name":"all", "role":"admin"}],
        "user-role":{"solr":"admin"}
      }
    }
  3. Restart Solr:
    sudo service solr restart

Log back into Solr with your user credentials.

Step 5: Creating Your First Solr Index

Now that Solr is secure, let’s create an index:

  1. Update Solr authentication settings:
    sudo nano /etc/default/solr.in.sh
  2. Add authentication options:
    SOLR_AUTH_TYPE="basic"
    SOLR_AUTHENTICATION_OPTS="-Dbasicauth=solr:SolrRocks"
  3. Restart Solr:
    sudo service solr restart
  4. Create an index:
    su - solr -c "https://vitux.com/opt/solr/bin/solr create -c test_core -n TestCore"

Visit your Solr dashboard, and under the “Core Selector,” choose your newly created test_core.

Apache Solr Installation on Debian 12 Debian linux

Conclusion

Congratulations! You’ve mastered the installation of Apache Solr on Debian 12. From securing your instance to creating an index, you now possess the know-how to leverage Solr’s powerful capabilities. Dive deeper into Solr configurations and consider scaling with Solr clusters for even more exhilarating search power. Go build something amazing! Happy indexing!