Installing Apache Solr 8.2.0 on Ubuntu 19.04



I’m currently hosting all my Drupal and WordPress sites on Digital Ocean. I am using a droplet running Ubuntu 19.04 and Digital Ocean’s managed database. I want to offload searches to Apache Solr and offer recommended posts on YeahChemistry.com

Check version of Ubuntu

:# lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 19.04
Release:	19.04
Codename:	disco

Check Java version

Solr require Java 8 or higher so check version. It is recommended to use the latest version of Java

:# java -version
Command 'java' not found, but can be installed with:
apt install default-jre              # version 2:1.11-71, or
apt install openjdk-11-jre-headless  # version 11.0.4+11-1ubuntu2~19.04
apt install openjdk-12-jre-headless  # version 12.0.2+9-1~19.04
apt install openjdk-8-jre-headless   # version 8u222-b10-1ubuntu1~19.04.1
apt install openjdk-13-jre-headless  # version 13~13-0ubunt1

Java was not found on my Digital Ocean Droplet so I installed it.

sudo apt install -y default-jdk

Checking Java version again

:# java -version
openjdk version "11.0.4" 2019-07-16
OpenJDK Runtime Environment (build 11.0.4+11-post-Ubuntu-1ubuntu219.04)
OpenJDK 64-Bit Server VM (build 11.0.4+11-post-Ubuntu-1ubuntu219.04, mixed mode, sharing)

Download Solr

Go to your user home directory

#: cd ~
Check Apache Solr site for latest version:
export LATEST_VER=“8.2.0"
curl -O https://www-eu.apache.org/dist/lucene/solr/${LATEST_VER}/solr-${LATEST_VER}.tgz
tar xvf solr-${LATEST_VER}.tgz

Run the script installer inside the extracted Solr directory.

cd solr-${LATEST_VER}/bin/
./install_solr_service.sh ~/solr-${LATEST_VER}.tgz
:~/solr-8.2.0/bin# ./install_solr_service.sh ~/solr-${LATEST_VER}.tgz
id: ‘solr’: no such user
Creating new user: solr
Adding system user `solr' (UID 112) ...
Adding new group `solr' (GID 120) ...
Adding new user `solr' (UID 112) with group `solr' ...
Creating home directory `/var/solr' ...

Extracting /root/solr-8.2.0.tgz to /opt


Installing symlink /opt/solr -> /opt/solr-8.2.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 Sun 2019-10-27 16:09:30 UTC; 5s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 17480 ExecStart=/etc/init.d/solr start (code=exited, status=0/SUCCESS)

: *** [WARN] *** Your open file limit is currently 1024.
Oct 27 16:09:26  solr[17480]:  It should be set to 65000 to avoid operational disruption.
Oct 27 16:09:26  solr[17480]:  If you no longer wish to see this warning, set SOLR_ULIMIT_CHECKS to false in your profile or solr.in.sh
Oct 27 16:09:26  solr[17480]: *** [WARN] ***  Your Max Processes Limit is currently 31786.
Oct 27 16:09:26  solr[17480]:  It should be set to 65000 to avoid operational disruption.
Oct 27 16:09:26  solr[17480]:  If you no longer wish to see this warning, set SOLR_ULIMIT_CHECKS to false in your profile or solr.in.sh
Oct 27 16:09:30  solr[17480]: [146B blob data]
Oct 27 16:09:30  solr[17480]: Started Solr server on port 8983 (pid=17558). Happy searching!
Oct 27 16:09:30  solr[17480]: [14B blob data]
Oct 27 16:09:30  systemd[1]: Started LSB: Controls Apache Solr as a Service.

Check that Solr is running

:~# systemctl status solr.service

Enable Solr to start on boot or reboot

:~# sudo systemctl enable solr solr.service

Access Solr Dashboard

http://<IP|Hostname>:8983

 

Create a Collection

:~# su - solr -c "/opt/solr/bin/solr create -c collection1 -n data_driven_schema_configs"

Created new core 'collection1'

 

Quick Solr Tutorial

Solr ships with sample documents you can index into a collection.

:/opt/solr/example/exampledocs# ls
books.csv   gb18030-example.xml  ipod_other.xml  manufacturers.xml  money.xml    monitor2.xml      mp500.xml  sample.html  solr-word.pdf  test_utf8.sh      vidcard.xml
books.json  hd.xml               ipod_video.xml  mem.xml            monitor.xml  more_books.jsonl  post.jar   sd500.xml    solr.xml       utf8-example.xml

 

The tutorial on the Apache Solr might be a bit confusing relative to this article so here is how you would recreate it.

 

su - solr -c "/opt/solr/bin/solr create -c techproducts"
su - solr -c "/opt/solr/bin/post -c techproducts /opt/solr/example/exampledocs/*"
All documents
curl "http://localhost:8983/solr/techproducts/select?indent=on&q=*:*"
Search for a term
curl "http://localhost:8983/solr/techproducts/select?q=foundation"
Phrase search
curl "http://localhost:8983/solr/techproducts/select?q=\"CAS+latency\""
Combining searches
curl "http://localhost:8983/solr/techproducts/select?q=%2Belectronics%20%2Bmusic"

 

 

Leave a Reply

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