Installing Solar (v8.11.0) on Ubuntu (v20.04)
Before being eclipsed by ElasticSearch, Apache Solr was the popular option for creating scalable and fault-tolerant search platforms for large-scale internet sites. It still is used by many major companies and internet sites; it lags in popularity to ElasticSearch, though.
Installation URI
Solar doesn't come through Ubuntu's official APT repositories.Go to the Apache Solr site and obtain download link for tar-ball. As of the time the links https://www.apache.org/dyn/closer.lua/lucene/solr/8.11.0/solr-8.11.0.tgz?action=download
Note: The action=download
is new since v8.5.0. Without it you will get a corrupted tarball.
Installation
First step is to install the Java Runtime.
sudo apt update && sudo apt upgrade
sudo apt install openjdk-11-jdk
Let's check to confirm that Java VM is running.
ziyan@jdeen:~# 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)
Next for convenience I switched to root.
sudo su
Then I moved to /opt
to download the tarball.
cd /opt
wget -o solr-8.11.0.tgz https://www.apache.org/dyn/closer.lua/lucene/solr/8.11.0/solr-8.11.0.tgz?action=download
Now we need to extract the installer script from the tarball.
tar -xzf solr-8.11.0.tgz solr-8.11.0/bin/install_solr_service.sh --strip-components=2
You will have some thing like this:
root@jdeen:~# ls -all /opt/
total 212720
drwxr-xr-x 4 root root 4096 Nov 21 17:43 .
drwxr-xr-x 19 root root 4096 Nov 22 02:42 ..
drwxr-xr-x 4 root root 4096 Oct 28 16:25 digitalocean
-rwxr-xr-x 1 root root 12694 Nov 5 10:18 install_solr_service.sh
-rw-r--r-- 1 root root 217788568 Nov 9 18:44 solr-8.11.0.tgz
Run the installer script which takes tarball as an argument.
./install_solr_service.sh solr-8.11.0.tgz
After a couple minutes you it should be ready and you will be greeted by an output similar to sudo systemctl status solr
.
● solr.service - LSB: Controls Apache Solr as a Service
Loaded: loaded (/etc/init.d/solr; generated)
Active: active (exited) since Mon 2021-11-22 16:46:26 UTC; 27min ago
Docs: man:systemd-sysv-generator(8)
Process: 873 ExecStart=/etc/init.d/solr start (code=exited, status=0/SUCCESS)
Nov 22 16:46:15 vagrant systemd[1]: Starting LSB: Controls Apache Solr as a Service...
Nov 22 16:46:15 vagrant su[875]: (to solr) root on none
Nov 22 16:46:15 vagrant su[875]: pam_unix(su-l:session): session opened for user solr by (uid=0)
Nov 22 16:46:26 vagrant systemd[1]: Started LSB: Controls Apache Solr as a Service.
Quick Start
Here are some helpful quick-start instructions if you are new to Solr.
Tip 1: Service status
sudo systemctl status solr
Tip 2: Start, stop restart the service
sudo systemctl start solr
sudo systemctl stop solr
sudo systemctl restart solr
Tip 3: Creating a collection
I use Solr with the sunspot_rails
gem. It generally has a collection as production
, development
, and test
. But I prefer to add the project name.
production:
solr:
hostname: localhost
port: 8983
log_level: WARNING
path: /solr/jdeen_production
# read_timeout: 2
# open_timeout: 0.5
development:
solr:
hostname: localhost
port: 8982
log_level: INFO
path: /solr/jdeen_development
test:
solr:
hostname: localhost
port: 8981
log_level: WARNING
path: /solr/jdeen_test
To create a collection I follow the following command.
sudo su - solr -c "/opt/solr/bin/solr create -c jdeen_production -n data_driven_schema_configs"
About the Author
Ziyan Junaideen -
Ziyan is an expert Ruby on Rails web developer with 8 years of experience specializing in SaaS applications. He spends his free time he writes blogs, drawing on his iPad, shoots photos.