Install Apache Solr as Windows Service using NSSM

1 minute read

Today I wanted to install Apache Solr index in Windows 7, Windows Server 2008R2 and Windows Server 2012 machines. So I achieved that , using the following steps:

  1. Download Apache Solr
  2. Download NSSM - the Non-Sucking Service Manager
  3. Create a .bat init file for Solr
  4. Create Windows service using NSSM
  5. Test Solr service

In detail:

1. Download Apache Solr

Download Apache Solr .zip file from Apache Solr website. I am currently using version 4.6.0.

2. Download NSSM - the Non-Sucking Service Manager

After a lot of searching for a stable solution in creating Windows services I stumbled upon NSSM - the Non-Sucking Service Manager. Download it and place the nssm.exe executable in a directory that can be seen by $PATH.

3. Create a .bat init file for Solr

  1. Unzip Apache Solr zip file to

    C:\Program Files\apache-solr-4.6.0\
    
  2. Create C:\Program Files\apache-solr-4.6.0\example\solrstart.bat file containing the following:

    @echo off
    cd "C:\Program Files\apache-solr-4.6.0\example\"
    java -Xms64M -Xmx256M  -Djava.util.logging.config.file=etc/logging.properties -jar start.jar
    

4. Create Windows service using NSSM

  1. Open a command line prompt (WinKey + R and type “cmd”) and type the following
    nssm install Solr4.6.0 "C:\Program Files\apache-solr-4.6.0\example\solrstart.bat"
    

    If the procedure succeeds you should see a message like this:Service “Solr4.6.0” installed successfully!

  2. If you want to uninstall the service open again a command line prompt and type the following:
    nssm remove Solr4.6.0 confirm
    

    If the procedure succeeds you should see a message like this: Service “Solr4.6.0” removed successfully!

5. Test Solr service

  1. Open a command line prompt (WinKey + R and type “cmd”) and type the following
    net start Solr4.6.0
    
  2. If the service was started successfully, open a web browser and access admin page: http://localhost:8983

That is all about it folks! May the Solr be with you!

Comments