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.

Prerequisites

  • 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:

java -version

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:

wget https://downloads.apache.org/lucene/solr/8.11.1/solr-8.11.1.tgz

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:

./solr-8.11.1/bin/install_solr_service.sh solr-8.11.1.tgz

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[1]: Starting LSB: Controls Apache Solr as a Service...
Jul 25 03:00:09 ubuntu2204 su[4694]: (to solr) root on none
Jul 25 03:00:09 ubuntu2204 su[4694]: pam_unix(su-l:session): session opened for user solr by (uid=0)
Jul 25 03:00:19 ubuntu2204 systemd[1]: 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 "https://www.howtoforge.com/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:

<img alt="Apache Solr" data-ezsrc="https://kirelos.com/wp-content/uploads/2022/05/echo/p1.png627a6ddb60174.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="375" loading="lazy" src="data:image/svg xml,” width=”750″>

In the left sidebar, select newcolletion, you should see the status of your collection on the following screen:

<img alt="Solr Statistics" data-ezsrc="https://kirelos.com/wp-content/uploads/2022/05/echo/p2.png627a6ddb95af9.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="371" loading="lazy" src="data:image/svg xml,” width=”750″>

Conclusion

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/

<img alt="Hitesh Jethva" data-ezsrc="https://kirelos.com/wp-content/uploads/2022/05/echo/hitesh-80.jpg" ezimgfmt="rs rscb5 src ng ngcb5" height="76" src="data:image/svg xml,” width=”80″>

About Hitesh Jethva

Over 8 years of experience as a Linux system administrator. My skills include a depth knowledge of Redhat/Centos, Ubuntu Nginx and Apache, Mysql, Subversion, Linux, Ubuntu, web hosting, web server, Squid proxy, NFS, FTP, DNS, Samba, LDAP, OpenVPN, Haproxy, Amazon web services, WHMCS, OpenStack Cloud, Postfix Mail Server, Security etc.