Apache Solr, also known as Solr, is a powerful search platform built on the Apache Lucene library. It is widely used for building enterprise-grade applications that require high-performance search capabilities. In this comprehensive guide, we will walk you through the process of installing Apache Solr on Rocky Linux, a popular open-source operating system. We will also cover important topics such as setting up limits for open files and max processes, verifying the installation, securing Solr with basic authentication, and creating your first Solr core. So, let’s get started!
Prerequisites
Before we begin, let’s ensure that we have all the necessary prerequisites in place:
- Operating System: Rocky Linux 8.5 (Green Obsidian)
- Memory: 2 GB (for testing purposes)
- CPUs: 2
- Root privileges
Installing Java OpenJDK
To install Solr on Rocky Linux, we need to have Java OpenJDK 1.8 or higher installed. In this example, we will be installing Java OpenJDK 1.11. Follow the steps below to install Java OpenJDK:
- Execute the following command to install Java OpenJDK 1.11:
sudo dnf install java-11-openjdk java-11-openjdk-devel
- Verify the installation by running the following command:
java --version
Congratulations! You have successfully installed Java OpenJDK on your Rocky Linux system.
Installing Solr on Rocky Linux
Next, we will proceed with the installation of Solr on Rocky Linux. Follow the steps below:
- Change your current working directory to
/opt
and download the Solr binary code using the following command:
cd /opt wget https://downloads.apache.org/lucene/solr/8.11.0/solr-8.11.0.tgz
- Extract the installer script from the Solr package:
tar xzf solr-8.11.0.tgz solr-8.11.0/bin/install_solr_service.sh --strip-components=2
- Install Solr using the installer script:
sudo bash ./install_solr_service.sh solr-8.11.0.tgz -i /opt -d /var/solr -u solr -s solr -p 8983
The installer script will install Solr in the specified directories and configure it to run as a system user named ‘solr’. Solr will be running on port ‘8983’.
- Verify that Solr is running correctly by checking the port ‘8983’:
ss -aplnt | grep java
If Solr is installed correctly, you should see the port ‘8983’ being used by the Java application.
- To ensure that Solr starts automatically on system boot, reload the system manager:
sudo systemctl daemon-reload
- Start and enable the Solr service:
sudo systemctl enable --now solr
Verify the status of the Solr service:
sudo systemctl status solr
Congratulations! You have successfully installed and configured Solr on your Rocky Linux system.
Setting up Limits for Open Files and Max Processes
During the Solr installation, you might have encountered warning messages about the open file limit and max processes limit. Solr requires a minimum open files limit and max processes limit of ‘65000’. Follow the steps below to resolve these warning messages:
- Edit the ‘/etc/security/limits.conf’ configuration file:
sudo nano /etc/security/limits.conf
- Add the following lines at the bottom of the file:
solr soft nofile 65000 solr hard nofile 65000 solr soft nproc 65000 solr hard nproc 65000
Save the configuration and exit.
- Verify the limits for open files and max user processes:
sudo -u solr ulimit -a
You should see the open files limit and max user processes limit set to ‘65000’.
- Restart the Solr service to apply the new configuration:
sudo systemctl restart solr
Congratulations! You have successfully set up the limits for open files and max processes for the Solr application.
Verifying the Solr Installation
To verify the Solr installation and access the Solr web application dashboard, follow the steps below:
- Add port ‘8983’ to the firewall:
sudo firewall-cmd --add-port=8983/tcp --permanent sudo firewall-cmd --reload
- Open your web browser and enter the following URL, replacing ‘192.168.1.10’ with your server’s IP address:
http://192.168.1.10:8983/
You should see the Solr dashboard, indicating a successful installation.
Securing Solr with Basic Authentication
By default, Solr installation does not enable authentication and authorization. In this step, we will secure the Solr deployment with basic authentication. Follow the steps below:
- Create a new configuration file named ‘security.json’ in the Solr data directory:
cd /var/solr/data/ sudo -u solr nano security.json
- Add the following configuration to the ‘security.json’ file:
{ "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" } } }
Save the configuration and exit.
- Restart the Solr service to apply the new configuration:
sudo systemctl restart solr
- Verify Solr authentication by accessing the Solr dashboard in your web browser:
http://192.168.1.10:8983/
You will be prompted to enter a username and password. Use the following credentials:
- Username: solr
- Password: SolrRocks
Once authenticated, you will have access to the Solr dashboard.
Congratulations! You have successfully secured your Solr installation with basic authentication.
Creating Your First Solr Core
In Solr, a core refers to a single Lucene index. You can create multiple cores in a single Solr deployment, each with its own configuration and data. Follow the steps below to create your first Solr core:
- Configure the Solr credentials by editing the ‘solr.in.sh’ file:
cd /opt/solr/bin/ sudo nano solr.in.sh
Uncomment the ‘SOLRAUTHTYPE’ option and set the value to ‘basic’:
SOLR_AUTH_TYPE="basic"
Uncomment the ‘SOLRAUTHENTICATIONOPTS’ option and set the value to the Solr username and password:
SOLR_AUTHENTICATION_OPTS="-Dbasicauth=solr:SolrRocks"
Save the configuration and exit.
- Create a new Solr core using the following command:
su - solr -c "/opt/solr/bin/solr create -c new_core -n ConfigName"
Replace ‘new_core’ with the desired name for your core and ‘ConfigName’ with the name of the configuration.
- Verify the Solr core by accessing the Solr administration dashboard:
http://192.168.1.10:8983/
You will see the newly created core listed with its details.
Congratulations! You have successfully created your first Solr core.
Conclusion
In this guide, we have covered the step-by-step process of installing Apache Solr on Rocky Linux. We started by installing Java OpenJDK, followed by the installation and configuration of Solr. We then secured the Solr deployment with basic authentication and created our first Solr core. By following this guide, you now have a fully functional Solr installation on your Rocky Linux system.
Apache Solr is a powerful search platform that can greatly enhance the search capabilities of your applications. With its scalability, fault tolerance, and distributed indexing, Solr is trusted by many large internet sites, including Adobe, Bloomberg, and Netflix.
If you are looking for a reliable cloud hosting platform to deploy your Solr application, Shape.host offers Cloud VPS solutions that are perfect for hosting Solr. With Shape.host, you can enjoy the benefits of a scalable and secure hosting environment, ensuring optimal performance for your Solr deployment. Visit Shape.host today to explore our cloud hosting solutions.