Do a quick local SolrCloud for Sitecore

Why?

Since configuration Solr single instances (that are mostly used on DEV environments and developer workboxes) and SolrCloud instances are different in terms of collection and configuration deployment, it makes sense to have SolrCloud instances used everywhere across the project.
That means developers should have SolrCloud instances on their workboxes.

How?

Well, of course, I don't want to insist here that every developer should have 2-3 VMs with Solr nodes and Zookeeper ensemble deployed and configured properly. That is complicated and can be expensive.
However, there is a way to get SolrCloud deployed locally on dev workbox, without having any significant effort. The keyword here is SolrCloud Interactive Setup and embedded Zookeeper.

Steps to deploy such SolrCloud

Step 1. Prerequisites for running Solr

Make sure you have JRE installed.
You can also use Open JDK, for example, this one can be used in form of a Windows installer that will take care of PATH registration and JAVA_HOME variable.
Make sure that the following command works in CMD:

Step 2. Download and unpack Solr binaries

Get the appropriate Solr version (depending on which Sitecore version you are using) and unpack it.

Step 3. Think about Solr HTTPS configuration

I assume you need to turn on SSL on Solr. In that case, prepare a certificate and configure SSL properties for Solr as you would configure them for Solr standalone instance.

Step 4. Start CMD wizard

Follow the steps described in the documentation.
Run command:

bin/solr -e cloud

You need to select how many nodes you would like to have in SolrCloudand then note the command for each of them. So that you will be able to run it again:


Pay attention to the port where integrated Zookeeper is running on. In my example (see image above), it is 9988.

The wizard will ask you to provide the name for the first collection to create as well as a count of shards and replicas. However, the creation of this collection may fail because of the reason described in the next step.

Go to the https://localhost:<portname> to visit your SolrCloud web UI (you may use the port of any SolrCloud node)

Step 5.

Although SolrCloud UI works, you get an error when trying to create a new collection. The reason for that is the fact that Zookeeper doesn't really know that your Solr instances are using HTTPS.
Run the following command to set the appropriate Zookeeper cluster property:

zkcli -zkhost "localhost:9988" -cmd clusterprop -name urlScheme -val https

The Zookeeper port (in my example 9988) can be found either in the initial CMD window where you did SolrCloud configuration or on SolrCloud UI:



zkcli command can be found within Solr folder: "\server\scripts\cloud-scripts"
The right output of this command will be the following:

After running of this command that property can be seen in the SolrCloud Web UI:



Conclusion

During the running of the SolrCloud wizard in CMD, you may notice the commands needed to start each instance. You can write them down and e.g. create PowerShell script on startup that will be running them on VM startup or alternatively - create Windows Services.

UPD:

There is "containerized" way to get simplest SolrCloud. Check out my blog post.


Comments