Install Nextant on Nextcloud 13

Nextant is an open source full-text search engine for Nextcloud. It is a gateway between your Nextcloud server and an Apache Solr servlet.

This installation guide is tested with Nextcloud 11, 12 and 13. Note that Nextant will be discontinued in Nextcloud version 14.

Nextant performs fast and concise full-text search within

  • your own files
  • shared files
  • external storage
  • bookmarks

Recognized file formats

  • plain text
  • rtf
  • pdf
  • epub
  • html
  • openoffice
  • microsoft office
  • image PNG, JPEG, TIFF

In this installation instruction we use an Ubuntu 16.04 x64 server as operating system.

Install Java

java -version
java version "1.8.0_111"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)

Download Apache Solr

cd
wget http://archive.apache.org/dist/lucene/solr/6.3.0/solr-6.3.0.tgz
tar -xzvf solr-6.3.0.tgz

Install Apache Solr as Service

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

./solr-6.3.0/bin/install_solr_service.sh solr-6.3.0.tgz
id: »solr“: Einen solchen Benutzer gibt es nicht
Creating new user: solr
Lege Systembenutzer »solr« (UID 126) an ...
Lege neue Gruppe »solr« (GID 135) an ...
Lege neuen Benutzer »solr« (UID 126) mit Gruppe »solr« an ...
Erstelle Home-Verzeichnis »/var/solr« ...
Extracting solr-6.3.0.tgz to /opt
Installing symlink /opt/solr -> /opt/solr-6.3.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 Mon 2017-01-01 00:00:05 CET; 5s ago
 Docs: man:systemd-sysv-generator(8)
 Process: 8143 ExecStart=/etc/init.d/solr start (code=exited, status=0/SUCCESS)

systemd[1]: Starting LSB: Controls Apache Solr as a Service...
su[8148]: Successful su for solr by root
su[8148]: + ??? root:solr
su[8148]: pam_unix(su:session): session opened for user solr by (uid=0)
solr[8143]: [182B blob data]
solr[8143]: Started Solr server on port 8983 (pid=8245). Happy searching!
solr[8143]: [14B blob data]
systemd[1]: Started LSB: Controls Apache Solr as a Service.

Solr is now running.

Update Solr

cd
wget http://archive.apache.org/dist/lucene/solr/7.3.0/solr-7.3.0.tgz
tar -xzvf solr-7.3.0.tgz
./solr-7.3.0/bin/install_solr_service.sh solr-7.3.0.tgz -f
Stopping Solr instance if exists ...
Extracting solr-7.3.0.tgz to /opt
Removing old symlink /opt/solr ...
Installing symlink /opt/solr -> /opt/solr-7.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

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

Generate the core that will be used by Nextant

sudo -u solr /opt/solr/bin/solr create -c nextant
Copying configuration to new core instance directory:
/var/solr/data/nextant

Creating new core 'nextant' using command:
http://localhost:8983/solr/admin/cores?action=CREATE&name=nextant&instanceDir=nextant

{
  "responseHeader":{
    "status":0,
    "QTime":16757},
  "core":"nextant"}

Webadmin remote acees

The webadmin interface of Solr is usually at http://localhost:8983/solr/

htpasswd -c /etc/apache2/htpasswd-solr admin
ProxyPass        /solr/ http://localhost:8983/solr/
ProxyPassReverse /solr/ http://localhost:8983/solr/

<Location /solr>
  AuthType Basic
  AuthName "solr"
  AuthUserFile /etc/apache2/htpasswd-solr
  Require valid-user
</Location>

Now you are ready to install Nextant from the Nextcloud admin console.

Go then to the admin panel of your Nextcloud installation and configure Nextant

Initiate the first indexing of your files

sudo -u www-data php occ nextant:index --debug --force
Time spent: 00:00:24
Your index now contains 2 segment

Congratulations! Your Nextcloud full-text search engine is now configured and running.

Check Solr scheme fields

sudo -u www-data php occ nextant:check

Fix errors

sudo -u www-data php occ nextant:check --fix

if it is not full green, try multiple time. Reindex after it.

Change Nextant data folder

su - solr
cd data/nextant
mv data /Nextant
ln -s /Nextant/data
exit

ls -al /Nextant/
total 28
drwxr-xr-x 4 root root 4096 May 4 21:03 .
drwxr-xr-x 25 root root 4096 May 4 20:53 ..
drwxrwxr-x 5 solr solr 4096 Jan 3 2017 data
drwx------ 2 root root 16384 May 4 20:57 lost+found

See also