Projecte

General

Perfil

Accions

Solr installation notes

How to install a single Solr for different Muscat and Blacklight services

Goal

Install a single Solr server for 6 services, 3 Muscat (DDD, Traces and IFMuC) and 3 Blacklight (DDD, Traces and IFMuC).

Single Solr instance can host different cores (=databases), and in fact it is the recommended way, so no resources are duplicated.

We'll minimize adaptations as much as possible; especially the Solr ones, so tha they are almost the same then the official ones. In the case of services, we will change only the names (paths) of the cores, as the official instructions foresee a dedicated Solr server, and with a fixed name.

Core names will be:

  • ddd-muscat, ddd-blacklight
  • traces-muscat, traces-blacklight
  • ifmuc-muscat, ifmuc-blacklight

Prerequisites

Before installing anytging, we will configure several values for the future solr user, so when the service (and thus the user) gets created, those values will already exist and we will avoid warning messages about changing those values.

The Linux server has to be configured with the values explained in this document:

https://solr.apache.org/guide/solr/latest/deployment-guide/taking-solr-to-production.html#ulimit-settings-nix-operating-systems

These four settings in particular are important to have set very high, unlimited if possible.

  • max processes (ulimit -u): 65,000 is the recommended minimum.
  • file handles (ulimit -n): 65,000 is the recommended minimum. All the files used by all replicas have their file handles open at once so this can grow quite large.
  • virtual memory (ulimit -v): Set to unlimited. This is used to by MMapping the indexes.
  • max memory size (ulimit -m): Also used by MMap, set to unlimited.
  • If your system supports it, sysctl vm.max_map_count, should be set to unlimited as well.

Some of them are already provided by Debian by default; we can check it this way:

$ ulimit -a
real-time non-blocking time  (microseconds, -R) unlimited
core file size              (blocks, -c) 0
data seg size               (kbytes, -d) unlimited
scheduling priority                 (-e) 0
file size                   (blocks, -f) unlimited
pending signals                     (-i) 31332
max locked memory           (kbytes, -l) 64
max memory size             (kbytes, -m) unlimited
open files                          (-n) 1024
pipe size                (512 bytes, -p) 8
POSIX message queues         (bytes, -q) 819200
real-time priority                  (-r) 0
stack size                  (kbytes, -s) 8192
cpu time                   (seconds, -t) unlimited
max user processes                  (-u) 31332
virtual memory              (kbytes, -v) unlimited
file locks                          (-x) unlimited

The ones we have to change are specific for solr user. As root user, edit /etc/security/limits.conf file and add those entries (the last two ones are uncertain):

solr            hard    nproc           unlimited
solr            soft    nproc           unlimited
solr            hard    nofile          unlimited
solr            soft    nofile          unlimited
#? solr         hard    memlock         unlimited
#? solr         soft    memlock         unlimited

More readings:

Installation

Download the package into a "normal" account:

$ cd ~/download/solr
$ wget https://dlcdn.apache.org/lucene/solr/8.10.1/solr-8.10.1.tgz

Now, we'll install it in the standard Solr distribution locations: software into /opt/solr and data into /var/solr, and create the new solr user and solr service. This is done by install_solr_service.sh, part of the tgz package that we have just downloaded. First, we'll extract only the shell script:

$ tar xfz solr-X.Y.Z.tgz solr-X.Y.Z/solr/bin/install_solr_service.sh --strip-components=2

And, ad root, we'll execute it:

# ./install_solr_service.sh solr-X.Y.Z.tgz [-f]

If necessary, we'll add a -f to force to update a previous installation.

This way software gets installed in /opt this way:

$ ls -ld /opt/solr*
lrwxrwxrwx 1 root root   16 Nov  5 13:10 /opt/solr -> /opt/solr-8.10.1/
drwxr-xr-x 9 root root 4096 Nov  5 13:10 /opt/solr-8.10.1/

And indices into /var/solr/:

$ ls -l /var/solr/
total 16
drwxr-x--- 6 solr solr 4096 Oct 22 11:02 data/
-rw-r----- 1 solr solr 3497 Oct 21 13:36 log4j2.xml
drwxr-x--- 2 solr solr 4096 Nov  5 14:07 logs/
-rw-r--r-- 1 solr solr    7 Nov  5 14:07 solr-8983.pid

We'll add a symlink to de Solr binary into /usr/local/bin/, so we'll always have into the execution $PATH.

# cd /usr/local/bin/
# ln -s /opt/solr/bin/solr .

Then as root user, we can start the service:

# service solr start
# service solr status

Configuration for Muscat

This service only starts and stop solr, but it does not allow to administrer it (add or remove cores, etc). This has to be done as solr user.

Our cores will be created with the binary /opt/solr/bin/solr (it its symlink /usr/local/bin/solr), but we need that the user has been started and write premissions into /var/solr/. So, as they belong to solr user, we'll chave to change to solr user:

# su - solr
$ /opt/solr/bin/solr
Usage[...]
$ /opt/solr/bin/solr create_core -c ddd-muscat

Le'ts confirm it:

$ curl "http://localhost:8983/solr/admin/cores?action=STATUS&core=ddd-muscat" 

Or:

$ curl http://localhost:8983/solr/admin/cores
{
  "responseHeader":{
    "status":0,
    "QTime":1},
  "initFailures":{},
  "status":{
    "ddd-muscat":{
      "name":"ddd-muscat",
      "instanceDir":"/var/solr/data/ddd-muscat",
      "dataDir":"/var/solr/data/ddd-muscat/data/",
      "config":"solrconfig.xml",
      "schema":"schema.xml",
      "startTime":"2021-11-05T12:40:02.294Z",
[...]

This way we can confirm that the data and configuration directirues are in /var/solr/data/ (and logs in /var/solr/logs/).

Those paths correspond to Muscat:

~/muscat/muscat-7.1.3/config/sunspot.yml
 path: /solr/ddd-muscat

~/muscat/muscat-7.1.3/config/blacklight.yml
 http://127.0.0.1:8983/solr/ddd-muscat

Then we'll have to change the default Solr configuration files with our Muscat applications. But it is better than they are owned but he application owner; so we'll create a symlink:

$ cd /var/solr/data/ddd-muscat/
$ mv -iv conf/ conf.0/
$ ln -s ~ddd_muscat/etc/solr/ddd-muscat conf
# $ cp -nav ~ddd_muscat/muscat/muscat-X.Y.Z/solr-configuration/muscat conf

Configuration for Blacklight

Blacklight, instead, is using Solr as managed schema, that is, fields are created dynamically at indexing time. So they have to be left as Solr owner.

However, the best default Solr configuration files for Blacklight are the ones that come with the demo (https://github.com/projectblacklight/demo.projectblacklight.org/tree/main/solr/conf). So, as Solr user, rename the conf file to conf.0 and copy the contents of the demo project to the conf directory.

solr@taltabull:~/data/ifmuc-blacklight$ mv -iv conf conf.0
solr@taltabull:~/data/ifmuc-blacklight$ rsync -av /home/ddd_muscat/github/blacklight/demo.projectblacklight.org/solr/conf .

And restart Solr:

solr@taltabull:~/data/traces-blacklight$ solr restart
*** [WARN] *** Your open file limit is currently 1024.  
 It should be set to 65000 to avoid operational disruption. 
 If you no longer wish to see this warning, set SOLR_ULIMIT_CHECKS to false in your profile or solr.in.sh
Sending stop command to Solr running on port 8983 ... waiting up to 180 seconds to allow Jetty process 28759 to stop gracefully.
Waiting up to 180 seconds to see Solr running on port 8983 [\]  
Started Solr server on port 8983 (pid=11005). Happy searching!

We'll do a symlink just to have an easy reading permission. First, we have to give a directory read permission as root (I may have forgotten some other):

# chmod o+rx /var/solr/

And then, create the symlink:

$ cd ~/etc/solr/
$ ln -s /var/solr/data/ddd-blacklight/conf/ ddd-blacklight

How to delete or cleanup a Solr core

To delete the contents of the index (core), without removing the core itself, from the shell:

$ curl http://localhost:8983/solr/my-core-name/update?commit=true -H 'Content-Type: text/xml' --data-binary '<delete><query>*:*</query></delete>'
<?xml version="1.0" encoding="UTF-8"?>
<response>
<lst name="responseHeader">
  <int name="status">0</int>
  <int name="QTime">284</int>
</lst>
</response>
$ curl "http://localhost:8983/solr/admin/cores?action=STATUS&core=my-core-name" 
  "responseHeader":{
    "status":0,
    "QTime":2},
  "initFailures":{},
  "status":{
    "ifmuc-muscat":{
      "name":"ifmuc-muscat",
      "instanceDir":"/var/solr/data/ifmuc-muscat",
      "dataDir":"/var/solr/data/ifmuc-muscat/data/",
      "config":"solrconfig.xml",
      "schema":"schema.xml",
      "startTime":"2022-11-29T12:45:16.708Z",
      "uptime":9462011,
      "index":{
        "numDocs":0,
[...] 

Those steps are to forget and cleanup a Solr core is to remove and re-create it (including configuration files!), as Solr user, this way:

solr@taltabull:~$ solr delete -c ddd-blacklight

Deleting core 'ddd-blacklight' using command:
http://localhost:8983/solr/admin/cores?action=UNLOAD&core=ddd-blacklight&deleteIndex=true&deleteDataDir=true&deleteInstanceDir=true

solr@taltabull:~$ solr create_core -c ddd-blacklight
WARNING: Using _default configset with data driven schema functionality. NOT RECOMMENDED for production use.
         To turn off: bin/solr config -c ddd-blacklight -p 8983 -action set-user-property -property update.autoCreateFields -value false

Created new core 'ddd-blacklight'

Muscat Solr administrator notes

The core.properties file in ~/etc/solr/ddd-muscat/ has to be deleted, as its name points to the muscat original name, not our ddd-muscat one, as we have in /var/solr/data/ddd-muscat/core.properties.

Add a line into solrconfig.xml:

$ diff -u solrconfig.xml.0 solrconfig.xml
--- solrconfig.xml.0    2021-10-06 13:19:17.000000000 +0200
+++ solrconfig.xml      2021-11-15 10:16:40.308205855 +0100
@@ -5,6 +5,7 @@
     <lib dir="${solr.install.dir:../../../..}/contrib/analysis-extras/lib" regex="icu4j-\d.*\.jar"/>
     <lib dir="${solr.install.dir:../../../..}/contrib/analysis-extras/lucene-libs" 
          regex="lucene-analyzers-icu-\d.*\.jar"/>
+    <lib dir="${solr.install.dir:../../../..}/contrib/themax" regex=".*\.jar"/>

     <dataDir>${solr.data.dir:}</dataDir>

Actualitzat per Ferran Jorba fa 11 mesos · 22 revisions