How to Install Apache Solr on Ubuntu 22.04
This tutorial exists for these OS versions
- Ubuntu 22.04 (Jammy Jellyfish)
- Ubuntu 20.04 (Focal Fossa)
- Ubuntu 16.04 (Xenial Xerus)
- Ubuntu 14.04 LTS (Trusty Tahr)
On this page
Solr is a free, open-source, and very popular tool used for search and real-time indexing. It is very highly scalable, fault-tolerant, and optimized for a high volume of internet traffic. It has its own set of plugins that are used for search as well as for indexing. It is written in Java that provides distributed indexing, replication, and load balancing with automated failover and recovery.
In this tutorial, you will learn how to install Apache Solr search system on Ubuntu 22.04.
- A server running Ubuntu 22.04.
- A root password is configured on the server.
Install Java JDK
Apache Solr is based on Java. So Java must be installed on your server. If Java is not installed, you can install it using the following command:
apt-get install default-jdk -y
Once Java is installed, you can verify the Java version with the following command:
You will get the Java version in the following output:
openjdk version "11.0.15" 2022-04-19 OpenJDK Runtime Environment (build 11.0.15+10-Ubuntu-0ubuntu0.22.04.1) OpenJDK 64-Bit Server VM (build 11.0.15+10-Ubuntu-0ubuntu0.22.04.1, mixed mode, sharing)
Install Apache Solr on Ubuntu 22.04
First, download the latest version of Apache Solr using the following command:
Once the download is completed, extract the downloaded file using the following command:
tar -xvzf solr-8.11.1.tgz
Next, install the Apache Solr by executing the Solr installation script:
Once the installation has been completed, you should get the following 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 Sat 2022-05-06 03:00:19 UTC; 5s ago Docs: man:systemd-sysv-generator(8) Process: 4692 ExecStart=/etc/init.d/solr start (code=exited, status=0/SUCCESS) Jul 25 03:00:09 ubuntu2204 systemd: Starting LSB: Controls Apache Solr as a Service... Jul 25 03:00:09 ubuntu2204 su: (to solr) root on none Jul 25 03:00:09 ubuntu2204 su: pam_unix(su-l:session): session opened for user solr by (uid=0) Jul 25 03:00:19 ubuntu2204 systemd: Started LSB: Controls Apache Solr as a Service.
At this point, Apache Solr is installed and listening on port 8983. You can verify it with the following command:
ss -altnp | grep 8983
You will get the following output:
tcp6 0 0 :::8983 :::* LISTEN 108 23034 4236/java
Manage Solr Service
Apache Solr service is managed by systemd. To start the Solr service, run the following command:
systemctl start solr
To stop the Solr service, run the following command:
systemctl stop solr
To check the status of the Solr service, run the following command:
systemctl status solr
Create Solr Collection
The collection is a logical index spread across multiple servers. The core is that part of the server which runs one collection.
To create a new collection in Apache Solr, run the following command:
su - solr -c "/opt/solr/bin/solr create -c newcollection -n data_driven_schema_configs"
You should get the following output:
Created new core 'newcollection'
Access Apache Solr Web Interface
You can access the Apache Solr web interface using the URL http://your-server-ip:8983/solr. You should see the Apache Solr web interface on the following screen:
In the left sidebar, select newcolletion, you should see the status of your collection on the following screen:
Congratulations! you have successfully installed Apache Solr on Ubuntu 22.04. You can now use this tool to use the full potential of a vertical search. For more information, visit the Apache Solr official documentation. https://lucene.apache.org/solr/