How to install apache Solr on Ubuntu 20.04
How to install apache Solr on Ubuntu 20.04

How To Install Apache Solr 8.9 On Ubuntu 20.04 LTS Step by Step

In this short article, we will guide you through how to install Apache Solr on Ubuntu 20.04 LTS operating system. Apache Solr is widely used for enterprise search and analytics use cases and has an active development community and regular releases. Solr was developed at CNET Networks as an in-house project to add search capability for the company website. The major features of Apache Solr including : full-text search, hit highlighting, faceted search, real-time indexing, dynamic clustering, database integration, NoSQL features and rich document handling.

Apache Solr is written in Java. Solr is designed for scalability and fault tolerance. On this article we will learn how to install Apache Solr 8.9 on Ubuntu 20.04 LTS.

Apache Solr 8.9.0 Installation on Ubuntu 20.04

Prerequisite

Before we are going to install Apache Sorl version 8.9 on Ubuntu 20.04 LTS operating system, there are prerequisites that must be met, as mention below :

  • Ubuntu 20.04 LTS system
  • User account with sudo privillege
  • Sufficient disk space and good network to access Apache Solr source

The Apache Solr installation process will be divided into several steps, as follow :

  1. Installing Java
  2. Installing Solr 8.9.0 on Ubuntu
  3. Managing Solr Service
  4. Create Collection in Solr

The details explanation will be shown below.

1. Installing Java

Apache Solr requires Java to run smoothly on the system, then we will verify if Java has already installed or not. If it was not already installed, then we will install java first. In this tutorial we will use OpenJDK 11 to be installed on the system. To install OpenJDK 11 we will do the following command line :

$ sudo apt install openjdk-11-jre-headless

Output :

ramansah@app01:~$ sudo apt install openjdk-11-jre-headless
Reading package lists... Done
Building dependency tree 
Reading state information... Done
The following packages were automatically installed and are no longer required:
dbconfig-common gsfonts imagemagick-6-common libaio1 libcgi-fast-perl libcgi-pm-perl libdbi-perl
libfcgi-perl libfftw3-double3 libfprint-2-tod1 libhtml-template-perl libjs-chart.js
libjs-jquery-ui libjs-raphael liblqr-1-0 libmagickcore-6.q16-6 libreadline5 libterm-readkey-perl
ruby-actioncable ruby-actionmailer ruby-actionpack ruby-actionpack-action-caching
ruby-actionpack-xml-parser ruby-actionview ruby-activejob ruby-activemodel ruby-activerecord
ruby-activestorage ruby-activesupport ruby-addressable ruby-arel ruby-atomic ruby-builder
ruby-bundler ruby-coderay ruby-concurrent ruby-crass ruby-css-parser ruby-erubi
ruby-eventmachine ruby-globalid ruby-hike ruby-htmlentities ruby-i18n ruby-jquery-rails
ruby-loofah ruby-mail ruby-marcel ruby-method-source ruby-mime-types ruby-mime-types-data
ruby-mimemagic ruby-mini-mime ruby-molinillo ruby-multi-json ruby-mysql2
ruby-net-http-persistent ruby-net-ldap ruby-nio4r ruby-nokogiri ruby-oj ruby-pkg-config
ruby-public-suffix ruby-rack-test ruby-rails ruby-rails-deprecated-sanitizer
ruby-rails-dom-testing ruby-rails-html-sanitizer ruby-rails-observers ruby-railties ruby-rbpdf
ruby-rbpdf-font ruby-redcarpet ruby-request-store ruby-rmagick ruby-roadie ruby-roadie-rails
ruby-rouge ruby-sprockets ruby-sprockets-rails ruby-thor ruby-thread-safe ruby-tilt ruby-tzinfo
ruby-websocket-driver ruby-websocket-extensions socat
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
ca-certificates-java java-common
Suggested packages:
default-jre fonts-dejavu-extra fonts-ipafont-gothic fonts-ipafont-mincho fonts-wqy-microhei
| fonts-wqy-zenhei
The following NEW packages will be installed:
ca-certificates-java java-common openjdk-11-jre-headless
0 upgraded, 3 newly installed, 0 to remove and 140 not upgraded.
Need to get 37.3 MB of archives.
After this operation, 171 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://us.archive.ubuntu.com/ubuntu focal/main amd64 java-common all 0.72 [6,816 B]
Get:2 http://us.archive.ubuntu.com/ubuntu focal-updates/main amd64 openjdk-11-jre-headless amd64 11.0.11+9-0ubuntu2~20.04 [37.2 MB]
...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for ca-certificates (20210119~20.04.1) ...
Updating certificates in /etc/ssl/certs...
0 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...

done.

Then we verify Java on our system by querying its version, by submitting command line : java –version as shown below :

ramansah@app01:~$ java -version
openjdk version "11.0.11" 2021-04-20
OpenJDK Runtime Environment (build 11.0.11+9-Ubuntu-0ubuntu2.20.04)
OpenJDK 64-Bit Server VM (build 11.0.11+9-Ubuntu-0ubuntu2.20.04, mixed mode, sharing)

2. Installing Solr 8.9.0

2.1. Download Apache Solr Source File

To install Apache Solr, we will use Apache Solr source file which as provided at Apache Solr official web site. For this task, we will use wget command line.

$ sudo wget https://downloads.apache.org/lucene/solr/8.9.0/solr-8.9.0.tgz

Output :

ramansah@app01:/opt$ sudo wget https://downloads.apache.org/lucene/solr/8.9.0/solr-8.9.0.tgz
--2021-08-31 11:53:59-- https://downloads.apache.org/lucene/solr/8.9.0/solr-8.9.0.tgz
Resolving downloads.apache.org (downloads.apache.org)... 88.99.95.219, 135.181.214.104, 135.181.209.10, ...
Connecting to downloads.apache.org (downloads.apache.org)|88.99.95.219|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 202942547 (194M) [application/x-gzip]
Saving to: ‘solr-8.9.0.tgz’

solr-8.9.0.tgz 100%[========================================>] 193.54M 834KB/s in 4m 4s

2021-08-31 11:58:04 (811 KB/s) - ‘solr-8.9.0.tgz’ saved [202942547/202942547]

2.2. Extract Apache Solr Archive

On this stage, we will extract Apache Solr source file by using tar command line. To do this task, we will submit the command line :

$ sudo tar xzf solr-8.9.0.tgz solr-8.9.0/bin/install_solr_service.sh --strip-components=2
$ ls -ltr

The output will be :

ramansah@app01:/opt$ sudo tar xzf solr-8.9.0.tgz solr-8.9.0/bin/install_solr_service.sh --strip-components=2 
ramansah@app01:/opt$ ls -ltr
total 198212
drwxr-xr-x 6 root root 4096 Feb 23 2021 wine-stable
-rwxr-xr-x 1 root root 12694 Jun 10 13:23 install_solr_service.sh
-rw-r--r-- 1 root root 202942547 Jun 10 18:16 solr-8.9.0.tgz

2.3. Install Apache Solr 8.9

We will have a shell script file and a tgz file on current directory. To install Apache Solr we just submit the command line :

$ sudo bash solr-8.8.1/bin/install_solr_service.sh solr-8.9.0.tgz

Output :

ramansah@app01:/opt$ sudo bash ./install_solr_service.sh solr-8.9.0.tgz 
id: ‘solr’: no such user
Creating new user: solr
Adding system user `solr' (UID 127) ...
Adding new group `solr' (GID 134) ...
Adding new user `solr' (UID 127) with group `solr' ...
Creating home directory `/var/solr' ...

Extracting solr-8.9.0.tgz to /opt
Installing symlink /opt/solr -> /opt/solr-8.9.0 ...
Installing /etc/init.d/solr script ...
Installing /etc/default/solr.in.sh ...

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 Tue 2021-08-31 12:05:23 PDT; 5s ago
Docs: man:systemd-sysv-generator(8)
Process: 6980 ExecStart=/etc/init.d/solr start (code=exited, status=0/SUCCESS)

Aug 31 12:05:18 app01.otodiginet.com systemd[1]: Starting LSB: Controls Apache Solr as a Service...
Aug 31 12:05:18 app01.otodiginet.com su[6982]: (to solr) root on none
Aug 31 12:05:18 app01.otodiginet.com su[6982]: pam_unix(su-l:session): session opened for user solr by (uid=0)
Aug 31 12:05:23 app01.otodiginet.com solr[7097]: Started Solr server on port 8983 (pid=7091). Happy searching!
Aug 31 12:05:23 app01.otodiginet.com systemd[1]: Started LSB: Controls Apache Solr as a Service.
ramansah@app01:/opt$ sudo systemctl status solr
● solr.service - LSB: Controls Apache Solr as a Service
Loaded: loaded (/etc/init.d/solr; generated)
Active: active (exited) since Tue 2021-08-31 12:05:23 PDT; 42s ago
Docs: man:systemd-sysv-generator(8)
Process: 6980 ExecStart=/etc/init.d/solr start (code=exited, status=0/SUCCESS)

Aug 31 12:05:18 app01.otodiginet.com systemd[1]: Starting LSB: Controls Apache Solr as a Service...
Aug 31 12:05:18 app01.otodiginet.com su[6982]: (to solr) root on none
Aug 31 12:05:18 app01.otodiginet.com su[6982]: pam_unix(su-l:session): session opened for user solr by (uid=0)
Aug 31 12:05:23 app01.otodiginet.com solr[7097]: Started Solr server on port 8983 (pid=7091). Happy searching!
Aug 31 12:05:23 app01.otodiginet.com systemd[1]: Started LSB: Controls Apache Solr as a Service.

3. Managing Solr Service

To manage Apache Solr service, we will have the privilege to start, stop, enable Solr service. To execute this task, we will have the following command line:

$ sudo systemctl stop solr
$ sudo systemctl start solr
$ sudo systemctl status solr

4. Create Collection in Solr

On this stage we will try to create a new Solr collection. For this use case, we will create a new Solr collection called as : otodigicollection. For this task we will execute teh command line :

$ sudo su - solr -c "/opt/solr/bin/solr create -c otodigicollection -n

The output will be shown below :

ramansah@app01:/opt$ sudo su - solr -c "/opt/solr/bin/solr create -c otodigicollection -n data_driven_schema_configs"

The term ‘collection‘ on Apache Solr is the group of cores that together form a single logical index. A collection has a different set of configuration files and schema definitions than other collections. On our article, we will create a collection and named it as ‘otodigicollection‘. For this purpose we will submit the command line : sudo su - solr -c "/opt/solr/bin/solr create -c otodigicollection -n data_driven_schema_configs.

Created new core 'otodigicollection'

It can be seen above that the Solr collection has been formed successfully.

Conclusion

On this short tutorial, we have learnt how to install Apache Solr 8.9 on Ubuntu 20.04 server. I hope it will be helpful for anyone who needed.

(Visited 315 times, 1 visits today)

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *