Published: 08 November 2018
If you are a Sitecore developer working mostly on local machine, one of the things you are likely to face is more than one Sitecore instance using Solr. Particularly start with Sitecore 9, you need to move away from the Lucence index provider and use Solr as default.
One option you have is to use the same Solr server for multiple Sitecore instances, which requires you to set up prefix for Solr cores. Then in each solution to apply patch config per Solr core. There is script for this on github.
This blog post will talk about the other option – to have multiple Solr instances in one machine.
Your Sitecore instances might need different versions of Solr, or in my case, they are compatible with the same version of Solr.
But in any cases, the first thing you need is a common JRE with all your Solr instances. Once Java is installed, also double check your JAVA_HOME variable is set.
Then download the right version of Solr zip, in my case, I have Solr 6.6.2. Unzip the content into a directory of your choice.
Because we want to have multiple instances of Solr, so what I do is create folders inside the Solr directory.
Then copy everything inside each folder. Each of the folder should look like this:
To use Solr, I use NSSM to install Solr as a windows service. You can also use Bitnami Apache but I personally found NSSM a very handy tool. Use it in command prompt with the command.
nssm install [serviceName]
It brings up the window below. Set the path to the solr.cmd inside the target instance bin folder. And Startup directory to the bin folder. Use the following command in Arguments field.
start -f -p [port number]
If this is your first instance, start with port number 8983. Then increase the number by 1 for the next instance. So each of the Solr instance can run in a different port.
The next tab – ‘Details’ is where we can fill out descriptive name and description of the service. It is not compulsory for creating the service but it is a good practice to fill out to maintain clean and clear windows service. Click on ‘Install service’ after everything has filled out. It should tell you the service installed successfully.
Do the same for the rest of the instances but point to correct path and directory and make sure to use a different port number.
Verify the services from Windows Service Manager
Then open the browser and make sure each instance is up and running.
The last step is to point Sitecore instances to the correct Solr instances. With recommend practice this should be done in a patch config file.
So now we have multiple Solr instances in a single machine, one pre Sitecore instance so we can turn on and off individually without interfere with each other.
The above steps can easily apply if you need different versions of Solr as well.
Hope this is useful :)