Apache Solr is a scalable, reliable and error-tolerant NoSQL search tool written in Java and released under an OpenSource license. It is used to store data and query them in near real time. It is the most popular search engine that provides distributed indexing, replication, load balancing with automated failover and recovery. It supports database queries through REST APIs such as Elasticsearch.
In this tutorial we will show you how to install Apache Solr 8.6 on Ubuntu 20.04.
- A server running Ubuntu 20.04.
- A root password is configured on the server.
Before you begin, it is a good idea to update your system with the latest version. You can update your system with the following command:
apt-get update -y
apt-get upgrade -y
After updating the system, restart it to make the changes.
Apache Solr is written in Java language. So Java needs to be installed in your system. If not installed, you can install it by running the following command:
apt-get install default-jdk -y
After installing Java, you can verify the Java installation with the following command:
You should see the installed version of Java in the following output:
openjdk version "11.0.7" 2020-04-14 OpenJDK Runtime Environment (build 11.0.7+10-post-Ubuntu-3ubuntu1) OpenJDK 64-Bit Server VM (build 11.0.7+10-post-Ubuntu-3ubuntu1, mixed mode, sharing)
Install Apache Solr
First, you need to download the latest version of Apache Solr from the Apache website. At the time of writing this article, the latest version of Apache Solr is 8.6.0. You can download it with the following command:
Once downloaded, extract the downloaded file with the following command:
tar xzf solr-8.6.0.tgz
Then install Apache Solr by running the Solr installation script:
bash solr-8.6.0/bin/install_solr_service.sh solr-8.6.0.tgz
When the installation is complete, 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 2020-07-25 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 ubuntu2004 systemd: Starting LSB: Controls Apache Solr as a Service... Jul 25 03:00:09 ubuntu2004 su: (to solr) root on none Jul 25 03:00:09 ubuntu2004 su: pam_unix(su-l:session): session opened for user solr by (uid=0) Jul 25 03:00:19 ubuntu2004 systemd: Started LSB: Controls Apache Solr as a Service.
Apache Solr is currently installed and listening on port 8983. You can verify this with the following command:
netstat -tunelp | grep 8983
You should get the following output:
tcp6 0 0 :::8983 :::* LISTEN 108 24019 4756/java
Manage Solr Service
Apache Solr runs as a Systemd service. So you can handle it easily with systemd.
Run the following command to start and stop the Apache Solr service:
systemctl stop solr
systemctl start solr
Run the following command to check the Apache Solr service:
systemctl status solr
To enable the Apache Solr service at system startup, run the following command:
systemctl enable solr
Create Solr collection
Collection is a logical index spread across several servers. The kernel is the part of the server that runs a collection.
To create a new collection in Apache Solr, run the following command:
su - solr -c "/opt/solr/bin/solr create -c mytestcollection -n data_driven_schema_configs"
You should get the following output:
Created new core 'mytestcollection'
Get access to Apache Solr
You can access the Apache Solr web interface with the URL http: // your-server-IP: 8983 / Solr. The Apache Solr web interface should appear on the following screen:
In the left sidebar, select mytestcollection, you should see the status of your collection on the following screen:
In this guide, we learned how to install Apache Solr on an Ubuntu 20.04 server. You can use this tool to use the full potential of a vertical search. For more information, see the official documentation for Apache Solr.
About Hitesh Jethva
Over 8 years of experience as a Linux system administrator. My knowledge includes in-depth knowledge of Redhat / Centos, Ubuntu Nginx and Apache, Mysql, Subversion, Linux, Ubuntu, web hosting, web server, octopus proxy, NFS, FTP, DNS, Samba, LDAP, OpenVPN, Haproxy, Amazon web services, WHMCS, OpenStack Cloud , Postfix Mail Server, Security etc.