Apache Solr is a powerful, open-source search platform built on Apache Lucene. It is designed for fast and efficient searching, indexing, and analytics, making it ideal for enterprise applications, websites, and data-driven projects. This guide will walk you through the steps to install Apache Solr 9.8.1 on Ubuntu 24.04 LTS in a simple and detailed way.
Prerequisites
Before you begin, make sure you have the following:
- A computer or server running Ubuntu 24.04 LTS
- Root access or a user with sudo privileges
- Basic familiarity with Linux terminal commands
- An active internet connection to download packages
Step 1: Update Your System
Start by updating your Ubuntu system to ensure all packages are current. This helps avoid compatibility issues during installation.
sudo apt update
sudo apt upgrade -y
The apt update
command refreshes the package list, and apt upgrade -y
installs the latest versions of all installed packages without prompting for confirmation.
Step 2: Install Java
Apache Solr 9.8.1 requires Java to function. Solr 9.8.1 is compatible with Java 17 or later. Let’s check if Java is already installed on your system.
java -version
If Java is installed, you’ll see version information. If not, or if the version is older than Java 17, install OpenJDK 17 using the following command:
sudo apt install openjdk-17-jdk -y
After installation, verify the Java version again to confirm it’s correctly installed:
java -version
You should see output indicating OpenJDK 17 or higher.
Step 3: Download Apache Solr 9.8.1
Download the latest Apache Solr 9.8.1 package from the official Apache website. Use the wget
command to fetch the tarball directly to your system.
wget https://dlcdn.apache.org/solr/solr/9.8.1/solr-9.8.1.tgz
This command downloads the Solr 9.8.1 tarball to your current directory. You can verify the download by listing the files:
ls
You should see solr-9.8.1.tgz
in the output.
Step 4: Extract the Solr Installation Script
The downloaded tarball contains an installation script to simplify setting up Solr. Extract only the installation script using the tar
command.
tar xzf solr-9.8.1.tgz solr-9.8.1/bin/install_solr_service.sh --strip-components=2
This command extracts the install_solr_service.sh
script to your current directory, removing the extra folder structure with --strip-components=2
.
Step 5: Install Apache Solr
Now, use the extracted script to install Solr as a service on your Ubuntu system. Run the following command:
sudo bash ./install_solr_service.sh solr-9.8.1.tgz
This script does the following:
- Extracts the Solr tarball to
/opt/solr
- Creates a dedicated
solr
user to run the service securely - Sets up Solr as a system service for easy management
Once the script finishes, Solr will be installed and ready to configure.
Step 6: Start the Solr Service
Start the Solr service to make it active on your system.
sudo systemctl start solr
To ensure Solr starts automatically on system boot, enable the service:
sudo systemctl enable solr
Step 7: Verify the Installation
To confirm that Solr is running correctly, open a web browser and go to http://your_server_ip:8983/solr/
, replacing your_server_ip
with your server’s actual IP address (e.g., 192.168.1.100
or localhost
if running locally). If you’re on a local machine without a public IP, use http://localhost:8983/solr/
.
You should see the Apache Solr Admin Dashboard, which confirms that Solr is up and running.
Step 8: Create a Solr Collection
A Solr collection is a logical index where you store and search data. Create your first collection named mycol1
with the following command:
sudo su - solr -c "/opt/solr/bin/solr create -c mycol1 -n data_driven_schema_configs"
This command switches to the solr
user and creates a collection called mycol1
using a data-driven schema configuration, which is flexible for most use cases.
After creating the collection, revisit the Solr Admin Dashboard in your browser at http://your_server_ip:8983/solr/
. Select mycol1
from the collection dropdown to explore it.
Step 9: Manage the Solr Service
You can manage the Solr service using the following commands:
- Stop Solr:
sudo systemctl stop solr
- Start Solr:
sudo systemctl start solr
- Check Solr status:
sudo systemctl status solr
This command shows whether Solr is running and provides details about the service.
Step 10: Basic Solr Configuration (Optional)
Solr is now installed and running, but you may want to configure it further for your needs. For example:
- Adjust memory settings: Edit the Solr configuration file at
/etc/default/solr.in.sh
to allocate more memory if needed (e.g., changeSOLR_JAVA_MEM
to-Xms512m -Xmx2048m
for 512 MB minimum and 2 GB maximum heap size). - Secure Solr: By default, Solr’s admin interface is accessible without authentication. For production, set up a firewall (e.g.,
ufw
) and restrict access to port 8983, or configure authentication via Solr’s security plugins.
Conclusion
Congratulations! You have successfully installed Apache Solr 9.8.1 on Ubuntu 24.04 LTS. You can now start indexing data, creating collections, and using Solr for powerful search and analytics tasks. For advanced features like schema customization, security, or clustering, refer to the official Apache Solr documentation.
Disclaimer: This guide is for educational purposes. Always test installations and configurations in a non-production environment before deploying to a live system. Ensure you follow security best practices, such as restricting access to Solr’s admin interface, in production environments.
16 Comments
Could u please tell how to run it in Cloud mode?
I run this code to create core:
sudo su – solr -c “/opt/solr-8.6.2/bin/solr create -c businesses -n data_driven_schema_configs”
It’s working fine but it stopped automatically after sometime, status for solr service is below please advice.
solr.service – LSB: Controls Apache Solr as a Service
Loaded: loaded (/etc/init.d/solr; bad; vendor preset: enabled)
Active: active (exited) since Tue 2020-01-21 16:38:58 UTC; 11h ago
Docs: man:systemd-sysv-generator(8)
Process: 22872 ExecStop=/etc/init.d/solr stop (code=exited, status=1/FAILURE)
Process: 22930 ExecStart=/etc/init.d/solr start (code=exited, status=0/SUCCESS)
Tasks: 0
Memory: 0B
CPU: 0
Jan 21 16:38:49 colab systemd[1]: solr.service: Unit entered failed state.
Jan 21 16:38:49 colab su[22935]: Successful su for solr by root
Jan 21 16:38:49 colab systemd[1]: solr.service: Failed with result ‘exit-code’.
Jan 21 16:38:49 colab su[22935]: + ??? root:solr
Jan 21 16:38:49 colab systemd[1]: Starting LSB: Controls Apache Solr as a Service…
Jan 21 16:38:49 colab su[22935]: pam_unix(su:session): session opened for user solr by (uid=0)
Jan 21 16:38:58 colab solr[22930]: [230B blob data]
Jan 21 16:38:58 colab solr[22930]: Started Solr server on port 8983 (pid=23000). Happy searching!
Jan 21 16:38:58 colab solr[22930]: [14B blob data]
Jan 21 16:38:58 colab systemd[1]: Started LSB: Controls Apache Solr as a Service.
In step 2 you have invalid url, I think you can use this url.
wget https://archive.apache.org/dist/lucene/solr/8.3.1/solr-8.3.1.tgz
Thanks Mykola, Tutorial has been updated
Thanks. I follow your steps and its Working fine
well, I could install it, until that point when I want to use SSL or login for admin as usually for a remote warehouse.. Could you explain that, too on newer Ubuntu and SolR.. 🙂
Great article, used to install solr 8.1.1 on ubuntu 16.04. But I cant open the examples provided.What should I follow?
Nice and clear. Thanks. Works fine with Solr 8.0.0 too.
Thank you for your article 🙂
Simple article but sweeTech at its best.
Thanks and Be blessed by the Divine.
Ganesh
Excellent guide! Thank you
Nice Article .. I have followed it working fine for me. now one doubt is after the creation of core will I have to create a schema.xml file .?? if yes then which location it will place.?? and how schema.xml will configure with solr .
I am very new in Solr if possible please let me know.
great 🙂
Nice article, Thank for the one.
I followed this guide and it worked. However, it didn’t say so directly in the text, but this will install Solr as a service that auto-starts when you (re)boot Ubuntu. I’m just saying, because I had a doubt and actually went and rebooted my Ubuntu server just to test if it would.