About Features Downloads Getting Started Documentation Events Support GitHub

Love VuFind®? Consider becoming a financial supporter. Your support helps build a better VuFind®!

Site Tools


Warning: This page has not been updated in over over a year and may be outdated or deprecated.
administration:starting_and_stopping_solr

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
administration:starting_and_stopping_solr [2020/08/18 13:08] – [Linux (systemd) Method] demiankatzadministration:starting_and_stopping_solr [2023/10/24 13:47] (current) – Removed notes about releases prior to 3.0. demiankatz
Line 1: Line 1:
 ====== Starting and Stopping Solr ====== ====== Starting and Stopping Solr ======
  
-Once VuFind is installed, it will only respond to search requests if its Solr back-end is active (unless, of course, you are relying on a third-party discovery service instead of a local index, in which case you can disregard this page entirely).  This page explains how to turn Solr on and off and how to automate the process if you wish.+:!: This page applies to VuFind® versions 3.0 and newer; if you are using a very old release, see the "Old revisions" button below to find earlier versions of the documentation. 
 + 
 +Once VuFind® is installed, it will only respond to search requests if its Solr back-end is active (unless, of course, you are relying on a third-party discovery service instead of a local index, in which case you can disregard this page entirely).  This page explains how to turn Solr on and off and how to automate the process if you wish.
  
 ===== Starting Solr Manually ===== ===== Starting Solr Manually =====
- 
- 
  
 ==== Linux Method ==== ==== Linux Method ====
  
-To start Solr under Linux, just switch to the directory where you installed VuFind (i.e. $VUFIND_HOME) and run this command:+To start Solr under Linux, just switch to the directory where you installed VuFind® (i.e. $VUFIND_HOME) and run this command:
  
     ./solr.sh start     ./solr.sh start
Line 16: Line 16:
  
     chmod +x solr.sh     chmod +x solr.sh
- 
-:!: Prior to VuFind 3.0, solr.sh was named vufind.sh; be sure to use the command appropriate for your version. 
  
 Note:  If you previously rebooted your system without manually stopping Solr, the script may mistakenly believe that it is still running.  In this case, a [[starting_and_stopping_solr#restarting_solr_manually|manual restart]] should solve the problem. Note:  If you previously rebooted your system without manually stopping Solr, the script may mistakenly believe that it is still running.  In this case, a [[starting_and_stopping_solr#restarting_solr_manually|manual restart]] should solve the problem.
Line 34: Line 32:
 </code> </code>
  
-This is warning of some default settings that could impact the performance of your Solr instance. On some Linux platforms, this can be addressed by editing the /etc/security/limits.conf file and adding these lines:+This is warning of some default settings that could impact the performance of your Solr instance. They are unlikely to cause problems if you are only using Solr for testing/development, but they should be addressed in production environments. 
 + 
 +The best way to address the errors on Linux platforms using systemd is to start Solr through systemd and ensure that your [[#linux_systemd_method|systemd configuration]] contains appropriate limit values. The [[#linux_systemd_method|systemd example below]] includes appropriate settings to prevent limit warnings. 
 + 
 +On some Linux platforms, if systemd is not available, the problem can be addressed by editing the /etc/security/limits.conf file and adding these lines:
  
 <code> <code>
Line 47: Line 49:
 It may be necessary to log out of your terminal session and log back in for these settings to take effect. It may be necessary to log out of your terminal session and log back in for these settings to take effect.
  
-On Linux platforms using systemd, you may be able to work around the problem with a systemd file like this example (in a file like /etc/systemd/system/vufind.service): 
- 
-<code> 
-Description=VuFind Starter 
-After=network.target 
- 
-[Service] 
-Type=forking 
-ExecStart=/bin/sh -l -c '/usr/local/vufind/solr.sh start' -x 
-PIDFile=/usr/local/vufind/solr/vendor/bin/solr-8983.pid 
-User=vufind-user 
-ExecStop=/bin/sh -l -c "/usr/local/vufind/solr.sh stop" -x 
-SuccessExitStatus=0 
-LimitNOFILE=65000 
-LimitNPROC=65000 
- 
-[Install] 
-WantedBy=multi-user.target 
-</code> 
- 
-(Obviously the /usr/local/vufind path and the vufind-user username should be customized to reflect your local needs). 
- 
-Once this is in place, you can use "sudo service vufind start" and "sudo service vufind stop" to start and stop the process, and appropriate limits will be applied. 
 ==== Windows Method ==== ==== Windows Method ====
  
-VuFind includes a Windows batch file to run Solr.  Just follow these steps:+VuFind® includes a Windows batch file to run Solr.  Just follow these steps:
  
-  * At a command prompt, switch to your VuFind directory.+  * At a command prompt, switch to your VuFind® directory.
   * Type:  solr start   * Type:  solr start
  
-Note that some of the scripting for this command is created automatically as part of the install.bat setup process.  If you did not install VuFind using install.bat, the command may not work.  You can re-run the install process to solve the problem+Note that some of the scripting for this command is created automatically as part of the install.php setup process.  If you did not run install.php while setting up the software, the command may not work.  You can re-run the install process to solve the problem.
- +
-:!: Prior to VuFind 3.0, solr.bat was named vufind.bat; be sure to use the command appropriate for your version. Prior to VuFind 1.0RC2, Windows support was not included.+
  
 ===== Stopping Solr Manually ===== ===== Stopping Solr Manually =====
Line 85: Line 62:
 ==== Linux Method ==== ==== Linux Method ====
  
-To take the server offline, switch to the VuFind directory and type:+To take the server offline, switch to the VuFind® directory and type:
  
     ./solr.sh stop     ./solr.sh stop
- 
-:!: Prior to VuFind 3.0, solr.sh was named vufind.sh; be sure to use the command appropriate for your version. 
  
 ==== Windows Method ==== ==== Windows Method ====
  
-When using VuFind 3.0 or newer, you can stop Solr from the command line in Windows:+You can stop Solr from the command line in Windows:
  
-  * At a command prompt, switch to your VuFind directory.+  * At a command prompt, switch to your VuFind® directory.
   * Type:  solr stop   * Type:  solr stop
- 
-In VuFind 2.x or earlier, to stop a manually-started Solr instance under Windows, open the command prompt window where the server is running and hit Ctrl-C.  This will cause the process to shut down. 
  
 ===== Restarting Solr Manually ===== ===== Restarting Solr Manually =====
Line 104: Line 77:
 ==== Linux Method ==== ==== Linux Method ====
  
-Restarting Solr under Linux is much the same as starting it.  Just switch to the VuFind directory and type:+Restarting Solr under Linux is much the same as starting it.  Just switch to the VuFind® directory and type:
  
     ./solr.sh restart     ./solr.sh restart
- 
-:!: Prior to VuFind 3.0, solr.sh was named vufind.sh; be sure to use the command appropriate for your version. 
  
 ==== Windows Method ==== ==== Windows Method ====
  
-When using VuFind 3.0 or newer, you can restart Solr from the command line in Windows:+You can restart Solr from the command line in Windows:
  
-  * At a command prompt, switch to your VuFind directory.+  * At a command prompt, switch to your VuFind® directory.
   * Type:  solr restart   * Type:  solr restart
- 
-In VuFind 2.x and earlier, there is no graceful way to restart a manually-started Solr instance under Windows.  Just follow the manual "stop" and "start" procedures described above. 
  
 ===== Killing an Unresponsive Solr Process ===== ===== Killing an Unresponsive Solr Process =====
Line 154: Line 123:
  
 If you don't want to have to manually start and stop Solr every time you turn on or shut down your server, you can set it up to run automatically. If you don't want to have to manually start and stop Solr every time you turn on or shut down your server, you can set it up to run automatically.
- 
- 
- 
- 
- 
-==== Linux (init.d) Method ==== 
- 
-You can set up Solr to run as a daemon. To do so, create a wrapper script in /etc/init.d/vufind: 
- 
-:!: Important: These instructions were written for VuFind 3.0 or later, when the Solr script was changed to solr.sh instead of vufind.sh; if running VuFind 2.x or earlier, you should replace "solr.sh" with "vufind.sh" in these examples. 
- 
-:!: If you need to run VuFind with non-default settings, you may wish to add some lines to export environment variables in this script, or else source a script containing all of your environment settings prior to running "solr.sh". In many newer installations of VuFind, such a script is already set up as /etc/profile.d/vufind.sh. 
- 
-:!: Newer versions of Solr do not like to be run by the root user; you may need to either add "export SOLR_ADDITIONAL_START_OPTIONS=-force" to your script to force root permissions, or (preferably) set up your script to run Solr as a dedicated user (which can be done by wrapping the solr.sh command with "/bin/su - username -c ...").  
- 
-<code> 
-#!/bin/sh 
-### BEGIN INIT INFO 
-# Provides: vufind 
-# Required-Start: 
-# Required-Stop: 
-# Default-Start: 2 3 4 5 
-# Default-Stop: 0 1 6 
-# Description: VuFind init script 
-### END INIT INFO 
-cd /usr/local/vufind 
-./solr.sh $* 
-</code> 
- 
-// Note: The information in the INIT INFO block is only required for RedHat-style systems that use the chkconfig utility.  You may need to adjust the start and stop runlevels depending on your system configuration. // 
- 
-// Note: If your VuFind instance is installed somewhere other than /usr/local/vufind, be sure to adjust the cd line in the script accordingly. // 
- 
-Make sure that the script is executable (sudo may be needed on the command for some platforms): 
- 
-<code> 
-chmod +x /etc/init.d/vufind 
-</code> 
- 
-You will then need to add the script to your runlevel configuration (generally found under /etc/rc.d).  The exact setup varies from flavor to flavor of Linux, but a bit of online research should help, as should these tools: 
- 
-  On RedHat (including Fedora): chkconfig --add vufind 
-  On Debian (including Ubuntu): update-rc.d vufind defaults        
- 
-If this doesn't seem to work, be sure that VUFIND_HOME and JAVA_HOME are set in the profile of the user running the startup script. 
- 
-=== Interacting with Solr After Automation === 
- 
-On some platforms, the "service" command is available to make use of startup scripts.  In this case, you will be able to use it for Solr after completing configuration: 
- 
-<code> 
-service vufind start 
-service vufind stop 
-service vufind restart 
-service vufind check 
-</code> 
- 
-//("sudo" may need to be prefixed to these commands depending on your Linux flavor and security configuration)// 
- 
-If service is available, it is the preferred way of starting and stopping Solr after automation. 
  
 ==== Linux (systemd) Method ==== ==== Linux (systemd) Method ====
Line 219: Line 128:
 // Thanks to [[https://github.com/jriedl|jriedl]] for investigating this issue. // // Thanks to [[https://github.com/jriedl|jriedl]] for investigating this issue. //
  
-Some newer flavors of Linux (such as CentOS 7) use [[https://en.wikipedia.org/wiki/Systemd|systemd]] instead of the traditional init.d approach.+Most modern flavors of Linux (such as CentOS 7 and newer) use [[https://en.wikipedia.org/wiki/Systemd|systemd]] instead of the earlier [[administration:starting_and_stopping_solr:init.d]] approach. Instructions on the older approach have been moved to [[administration:starting_and_stopping_solr:init.d|a separate init.d page]].
  
 To automate Solr with systemd: To automate Solr with systemd:
-  * create the user "solr", because Solr should not be run under root user+  * [[administration:security#creating_a_dedicated_solr_user|create the user "solr"]], because Solr should not be run under the root account for security reasons
-  * add permission for the solr directory to this user: +  * add permission for the solr directory to this user if you have not already
  
 <code>chown -R solr:solr /usr/local/vufind/solr</code> <code>chown -R solr:solr /usr/local/vufind/solr</code>
  
   * create new file called /etc/systemd/system/vufind.service, with this code:   * create new file called /etc/systemd/system/vufind.service, with this code:
- 
-In VuFind 2.x, the contents of the file should be as follows: 
  
 <code> <code>
 [Unit] [Unit]
-Description=VuFind Starter +After=network.target
-After=network.target httpd.service mariadb.service +
- +
-[Service] +
-Type=forking +
-ExecStart=/bin/sh --login -c '/usr/local/vufind2/vufind.sh start' +
-PIDFile=/var/run/vufind.pid +
-User=solr +
-ExecStop=/bin/sh --login -c "/usr/local/vufind2/vufind.sh stop" +
- +
-# Java responds to a SIGTERM by returning with exit code 143 which leads to "failed" exit in the systemd-Logs +
-SuccessExitStatus=143 +
- +
-[Install] +
-WantedBy=multi-user.target +
-</code> +
- +
-In VuFind 7.0 and later, the contents of the file should be as follows. It will work with the official VuFind 3 deb package (tested on Ubuntu 16.04). For compatibility with VuFind 3.0 through 6.0, simply change "solr-8983.pid" to "solr-8080.pid" to reflect a different default port number. +
- +
-<code> +
-[Unit] +
-After=network.target httpd.service mariadb.service+
  
 [Service] [Service]
Line 263: Line 149:
 ExecStop=/bin/sh -l -c "/usr/local/vufind/solr.sh stop" -x ExecStop=/bin/sh -l -c "/usr/local/vufind/solr.sh stop" -x
 SuccessExitStatus=0 SuccessExitStatus=0
 +LimitNOFILE=65000
 +LimitNPROC=65000
  
 [Install] [Install]
 WantedBy=multi-user.target WantedBy=multi-user.target
 </code> </code>
 +
 +The above example should work for VuFind® 7.0 and later using the official VuFind® deb package (this has been tested on Ubuntu). For compatibility with VuFind® 3.0 through 6.0, simply change "solr-8983.pid" to "solr-8080.pid" to reflect a different default Solr port number. For older versions of VuFind®, a different script is needed; click the "Old revisions" link below to find historical documentation.
  
 Be sure to adjust paths in the code above to match your local system. Be sure to adjust paths in the code above to match your local system.
Line 290: Line 180:
 ==== Windows Method ==== ==== Windows Method ====
  
-As of VuFind 3.0, Solr can be started as a background process from the command line, so it should be possible manage it from within Windows; however, detailed instructions and best practices have not been developed as of this writing. Please feel free to contribute your own recommendations!+Solr can be started as a background process from the command line, so it should be possible manage it from within Windows; however, detailed instructions and best practices have not been developed as of this writing. Please feel free to contribute your own recommendations!
  
 ===== Taking the User Interface Offline ===== ===== Taking the User Interface Offline =====
  
-If you simply stop the Solr server, users attempting to access your VuFind site will encounter error messages.  If you are planning an outage, you can take the site more gracefully offline by adjusting the "available" setting in the "[System]" section of your [[configuration:files:config.ini]] file.+If you simply stop the Solr server, users attempting to access your VuFind® site will encounter error messages.  If you are planning an outage, you can take the site more gracefully offline by adjusting the "available" setting in the "[System]" section of your [[configuration:files:config.ini]] file.
 ---- struct data ---- ---- struct data ----
 +properties.Page Owner : 
 ---- ----
  
administration/starting_and_stopping_solr.1597756085.txt.gz · Last modified: 2020/08/18 13:08 by demiankatz