Apache Solr Tutorial - Ubuntu 16.04

Revision as of 02:59, 13 October 2019 by Ardaut (talk | changes) (Created page with "Solr is a full text search that can be used with Nextcloud fulltextsearch plugin (do not use nextant, because it has end) <br> This tutorial will show how to install and confi...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Solr is a full text search that can be used with Nextcloud fulltextsearch plugin (do not use nextant, because it has end)
This tutorial will show how to install and configure Apache Solr.


Requirement: Install Java 8

apt-get install openjdk-8-jdk openjdk-8-jre 

Download the software Apache Solr

cd /home
wget "wget http://mirror.klaus-uwe.me/apache/lucene/solr/8.2.0/solr-8.2.0.tgz"
tar -xzvf solr-8.2.0.tgz

Install Apache Solr as Service

If Solr is already installed continue with “Update Solr”.

./solr-8.2.0/bin/install_solr_service.sh solr-8.2.0.tgz
id: ‘solr’: no such user
Creating new user: solr
Adding system user `solr' (UID 124) ...
Adding new group `solr' (GID 131) ...
Adding new user `solr' (UID 124) with group `solr' ...
Creating home directory `/var/solr' ...

Extracting /home/ardalphacloud_index/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; bad; vendor preset: enabled)
   Active: active (exited) since Sun 2019-10-13 02:41:10 CEST; 5s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 15868 ExecStart=/etc/init.d/solr start (code=exited, status=0/SUCCESS)

Good :) - Solr is now running.

Update Solr

cd
wget http://archive.apache.org/dist/lucene/solr/8.3.0/solr-8.3.0.tgz
tar -xzvf solr-8.3.0.tgz
./solr-8.3.0/bin/install_solr_service.sh solr-8.3.0.tgz -f
Stopping Solr instance if exists ...
Extracting solr-8.3.0.tgz to /opt
Removing old symlink /opt/solr ...
Installing symlink /opt/solr -> /opt/solr-8.3.0 ...
Installing /etc/init.d/solr script ...
/etc/default/solr.in.sh already exist. Skipping install ...
/var/solr/data/solr.xml already exists. Skipping install ...
/var/solr/log4j.properties already exists. Skipping install ...
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; bad; vendor preset: enabled)
 Active: active (exited) since Tue 2018-05-01 16:30:20 CEST; 5s ago
 Docs: man:systemd-sysv-generator(8)
 Process: 6888 ExecStart=/etc/init.d/solr start (code=exited, status=0/SUCCESS)

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

Increase number of open files and processes

vi /etc/security/limits.conf
solr hard nofile 65000
solr hard nproc 65000
su - solr
vi .bash_profile
ulimit -n 65000
ulimit -u 65000
exit
tail -f /var/log/syslog | grep solr
service solr restart
systemd[1]: Started Session c5 of user solr.
solr[4451]: Sending stop command to Solr running on port 8983 ... waiting up to 180 seconds to allow Jetty process 2178 to stop gracefully.
solr[4451]: [|] #010#010#010#010#010#010 [/] #010#010#010#010#010#010 [-] #010#010#010#010#010#010 [\] #010#010#010#010#010#010 #010#010#010#010
systemd[1]: Removed slice User Slice of solr.
systemd[1]: Created slice User Slice of solr.
systemd[1]: Started Session c6 of user solr.
solr[4558]: Waiting up to 180 seconds to see Solr running on port 8983 [|] #010#010#010#010#010#010 [/] #010#010#010#010#010#010 [-] #010#010#010#010#010#010 [\] #010#010#010#010#010#010 [|] #010#010#010#010#010#010 [/] #010#010#010#010#010#010 [-] #010#010#010#010#010#010 [\]
solr[4558]: Started Solr server on port 8983 (pid=4661). Happy searching!
solr[4558]: #010#010#010#010#010#010 #010#010#010#010

Increase memory for JVM

vi /etc/init.d/solr
MEMRAM="-m 2048m"           ←  ⎯⎯⎯⎯⎯⎯⎯⎯ Add ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
if [ -n "$RUNAS" ]; then                                                     ↓
 su -c "SOLR_INCLUDE=\"$SOLR_ENV\" \"$SOLR_INSTALL_DIR/bin/solr\" $SOLR_CMD $MEMRAM" - "$RUNAS"
else
 SOLR_INCLUDE="$SOLR_ENV" "$SOLR_INSTALL_DIR/bin/solr" "$SOLR_CMD"
fi

968x580px

Add Solr port to services

vi /etc/services
solr        8983/tcp
netstat -pat | grep java
tcp6   0  0  localhost:7983      [::]:*       LISTEN      8245/java       
tcp6   0  0  [::]:solr           [::]:*       LISTEN      8245/java

Bind Solr to localhost only

vi /opt/solr/server/etc/jetty-http.xml

<Set name="host"><Property name="jetty.host" /></Set>
<Set name="host"><Property name="jetty.host" default="127.0.0.1" /></Set>
service solr restart
netstat -pat|grep solr
tcp6       0      0 localhost:solr          [::]:*                  LISTEN      10091/j