Skip to main content

Setup the Solr as a window service

Solr ? 
Solr is highly reliable, scalable and fault tolerant, providing distributed indexing, replication and load-balanced querying, automated failover and recovery, centralized configuration and more. Solr powers the search and navigation features of many of the world's largest internet sites.


1.   Prerequisite Software 
·         JAVA ( install it from https://java.com/en/download/)
·         NSSM 2.24 ( Non Sucking Service manager) https://nssm.cc/release/nssm-2.24.zip

2.   Setup Solr Instance

2.1  Download Solr
·         Download the Solr and extract it in one folder.
         Ex : D:\SolrPOC\Solr\Solr-4.5.1\
·         Make sure Java is installed properly

 Setup Solr as Windows service using NSSM


1. NSSM - Non-Sucking Service Manager
nssm is a service helper which doesn't suck. Other service helper programs suck because they don't handle failure of the application running as a service. If you use such a program, you may see a service listed as started when in fact the application has died. nssm monitors the running service and will restart it if it dies.
Nssm also features a graphical service installation and removal facility.

2. Download nssm and install Solr as a service
·         Download nssm 2.24  from https://nssm.cc/release/nssm-2.24.zip
·         Extract nssm zip into folder  D:\SolrPOC\Solr\nssm 2.24 

·         Run the below command in command prompt. Open cmd in administrator mode.
D:\SolrPOC\Solr\nssm-2.24\win64\nssm.exe install solr-5.4.1

·         It will open NSSM service installation window as GUI
·         Enter : D:\SolrPOC\Solr\Solr-4.5.1\bin\solr.cmd in Path
·         Enter : D:\SolrPOC\Solr\Solr-4.5.1\\bin in Startup Directory
·         Enter : start -f -p 8983 in Arguments  ( Note : You can provide the port based on your requirement, default port is 8983)

·         Same way, click on details tab, enter the other values, and click on “Install service” button.

·         If service installed successfully then below screen will display

                 

3  Verify the Service and Solr UI
·         Verify the service in window services. Run the command (services.msc) to open the window service and verify installed service.



·         Start the service (Right click and start or left top corner).
·         Now open the URL  http://localhost:8983/solr in browser. It will open the Solr GUI.



4  Create cores using Solr UI
·         Click on Core Admin > Add Core
·         In add core window , enter “US_master_index” in field name & instanceDir
·         Click on Add Core button

·         Repeat above steps to add more core
·         You can verify the core in folder : D:\SolrPOC\Solr\Solr-4.5.1\server\solr

·         Similarly add all the below cores for CD environment and verify it.


3.   Troubleshooting
3.1  Solr Service not starting or paused
·         Add / Verify JAVA_HOME System Variable
·         If Solr5.4.1 service is not starting or paused in Services then verify whether JAVA_HOME system variable is added under Environment Variables or not
3.2  How to verify and add JAVA_HOME system variable?
·         Go to Control PanelàClick on System àClick on Advanced System Settings
·         Click on Advanced Tabà Click on Environment Variables



·         Under System Variables, verify JAVA_HOME variable is there or not.
·         If JAVA_HOME variable available then verify latest JRE path is used or not.
·         Goto C:\Program Files (x86)\Java\ and verify JRE folders.
·         Check whether latest JRE folder path is specified for JAVA_HOME or not.
·         If not then enter latest JRE version’s  path.
·         Now try to start Solr5.4.1 service under services.


·         If JAVA_HOME not available then click on New to add new variable.
·         Enter JAVA_HOME as variable name
·         Enter jre path (C:\Program Files (x86)\Java\jre1.8.0_66) as Variable Value.
·         NOTE: If more than one jre folder is available under Java folder then specify latest jre
·         Click OK
·         Now try to start Solr5.4.1 service under services.

3.3    Edit/Uninstall the service using NSSM?
            ·         NSSM Command to uninstall the Solr Service
                  1). Open command prompt in Admin mode
                  2) Type command below command
                      D:\SolrPOC\Solr\nssm-2.24\win64\nssm remove solr5.4.1
                  3) You will receive "service removed successfully" message
                  4) Verify the service (type services.msc)
                  5) If service name still is still displaying then restart the system.
·         NSSM Command to edit Solr Service:
      1). Open command prompt in Admin mode
 2). Type command : D:\SolrPOC\Solr\nssm-2.24\win64\nssm edit solr5.4.1

3.4  How to verify solr service running on which port?
·         Navigate to \solr-5.4.1\bin folder. There .port extension file available which show the running port no.


3.5  How to verify solr service running on which process ID?
·         Navigate folder : \solr-5.4.1\server\solr
·         Open folder hsperfdata_
·         There is one file with numeric no. Note down this number

·         Open task manager and navigate to details tab
·         Search for Java and match the PID with above noted number.


3.6  Solr service is hanged for last 1 hour?
·         Java behave differently on window, when we stop the service then it does not immediately stop. If any backend operation is, happening then it wait to finish that operation.
·         Always stop and start the service for clear visibility.
·         Do not immediately stop and start the service. At least gap should be 30- 60 sec.
·         After waiting for a long time if service is still not responding then verify the above java PID in task manager.
·         Try to kill java process from task manager. If you are unable to kill particular java process then need to restart the system.

Comments

Popular posts from this blog

Sitecore Publishing target and Solr Configuration

Creating a new publishing target is very helpful if your Sitecore environment is setup in multiple content delivery servers. We can publish data from Master database to one or more publishing target databases. Main thing to notice here is Master database contains all versions of any content or assets while publishing target database contains single latest version for each language.      This post aims to provide systematic instructions to set up publishing target. It comprises of a target database (where the content will be published) and publishing target definition item in master database that points to that target database.             Post creation of publishing target need to take care of Solr configuration. This post cove master slave Solr configuration and onPublishEndAsync strategy. We are using 1 Solr Master instance and 6 Slave instance (2-EU, 2-Ap, 2- NA).     1   So...

Setup Sitecore Habitat v9.0 project in simple way

In this article , I would describe how to setup the Sitecore habitat V9.0 project with Sitecore Experience Platform 9.0 rev in very simple way. I used below system configuration to setup this project: 1. Windows 10 (32/64-bit) 2. IIS 10.0 3. .NET Framework 4.6.2 4. Microsoft Visual Studio 2017 5. Microsoft SQL Server 2017 6. Solr 6.6.2 7. Microsoft PowerShell® version 5.0 8. Web Platform Installer 5.0. 9. Web Deploy 3.6 for Hosting Servers 10. Node-v8.9.4-x64 Follow below steps to setup the project. A).   Habitat require Sitecore instance. Setup the clean Sitecore 9.0 instance. Ex : http://demo.local.com , Directory location : C:\inetpub\wwwroot\demo.local.com   For more info visit -   https://dev.sitecore.net/ B). Download the Habitat V9.0 project from Github site :  https://github.com/Sitecore/Habitat/     Note  :  When you download the packages, it is possible that the .ZIP packages are marked as blocke...

Web Deploy setup and configuration with Sitecore

Web Deploy empowers Visual Studio and WebMatrix to help developers streamline the deployment of Web applications to Microsoft IIS Web servers or to Microsoft Azure Websites. In addition, integration with Web Platform Installer allows developers to simply and easily install community webapplications.   This post describe the installation of Web Deploy and Configuration with Sitecore instance.  This post will be very useful if you want to sync your Sitecore media items with all of the CD's environment (Distributed environment) . In one of my previous project, I was keeping all the media items in file system and synchronizing all the files from CM to Cd's server. This solution is tested with 1 CMS and 6 CD's server (2-EU, 2- NA, 2- AP) with more than 5 Lakh files.  1.       Software Pre-requisites           a.       OS – Window 7/ Windows Server 2008 R2 Enterprise       ...