I've recently had the good fortune to use the Solr search platform for a project. One thing, though, that is not straight forward is how to install Solr as a Windows service. There are several articles on the internet, but I couldn't find any that worked with Solr 4.5. So I gathered information from a number of out-dated articles and came up with the following approach, which has worked fine for me:
- Download Solr 4.5 (http://lucene.apache.org/solr/)
- Download the Non-Sucking Service Manager NSSM (http://nssm.cc/)
- Create a folder to be used for the Solr service (e.g. D:\solr). From now on this will be called <solrdir>
- From the example folder of the Solr package copy the following files and folders to <solrdir>:
- etc
- lib
- logs
- solr
- webapps
- start.jar
- In a command prompt go to <solrdir> and run the command
java -jar start.jar
to check that the Solr installation works. If it works then just stop it again. - From the NSSM package copy nssm.exe to <solrdir>
- In a command prompt go to <solrdir> and run the command below. Note: it may be necessary to replace back-slashes in <solrdir> with forward-slashes.
nssm.exe install Solr C:\Windows\System32\java.exe "-Dsolr.solr.home=<solrdir>/solr -Djetty.home=<solrdir>/ -Djetty.logs=<solrdir>/logs/ -cp <solrdir>/lib/*.jar;<solrdir>/start.jar -jar <solrdir>/start.jar"
nssm.exe remove Solr
For convenience I've created the following batch script, which performs the nssm.exe install part. The script should be placed in <solrdir>.
@echo off
set currentdir=%~dp0
set parameters=-Dsolr.solr.home=""%currentdir%solr"" -Djetty.home=""%currentdir%"" -Djetty.logs=""%currentdir%logs/"" -cp ""%currentdir%lib/*.jar;%currentdir%start.jar"" -jar ""%currentdir%start.jar""
REM replace back-slashes with forward-slashes
set javaWeirdnessParameters=%parameters:\=/%
nssm.exe install Solr C:\Windows\System32\java.exe "%javaWeirdnessParameters%"
0 comments:
Post a Comment