I recently went through the process of installing and configuring a SolrCloud cluster but had some problems finding some instructions that were up to date. This post will hopefully bridge that gap some. Below I've included steps to configure SolrCloud with three instances of Solr and three instances of ZooKeeper on a single server (for testing.) If you are doing this for any environment besides your local, you would want these instances on separate servers.

Just for reference, I wrote these instructions against Solr 7.2.1 but have performed the same steps on Solr 6.6.3.

Preparation

We'll need the following downloads to complete this installation, download them and place all the ZIP's in a central location. Or just keep them in your downloads folder, it's your life.

Install ZooKeeper

In this section, we'll create three folders that will be home to our ZooKeeper instances

First ZooKeeper Instance

  • Create C:\ZooKeeper
  • Create C:\ZooKeeper\1
  • Copy contents of downloaded ZooKeeper zip into C:\ZooKeeper\1
  • Create C:\ZooKeeper\1\data
  • Create C:\ZooKeeper\1\data\myid, set contants of the file to 1
  • Navigate C:\ZooKeeper\1\conf, create a copy of zoo_sample.cfg, name zoo.cfg
  • Set contents of the C:\ZooKeeper\1\conf\zoo.cfg to:
tickTime=2000
initLimit=5
syncLimit=2
dataDir=../data
clientPort=2181
server.1=127.0.0.1:2888:3888
server.2=127.0.0.1:2889:3889
server.3=127.0.0.1:2890:3890

Second ZooKeeper Instance

  • Copy C:\ZooKeeper\1 to C:\ZooKeeper\2
  • Update C:\ZooKeeper\2\conf\zoo.cfg, set clientPort to 2182
  • Update C:\ZooKeeper\2\data\myid, set contents of file to 2

Third ZooKeeper Instance

  • Copy C:\ZooKeeper\1 to C:\ZooKeeper\3
  • Update C:\ZooKeeper\3\conf\zoo.cfg, set clientPort to 2183
  • Update C:\ZooKeeper\3\data\myid, set contents of file to 3

Testing

  • To test ZooKeeper, open a command prompt and execute: C:\ZooKeeper\1\bin\zkServer.cmd
  • Open another command prompt and execute C:\ZooKeeper\2\bin\zkServer.cmd

After starting both of these servers, you should see some messages that indicate they have discovered one another. You can open the third server as well if you're interested in testing them all. Close these windows after this initial testing.

Installing ZooKeeper as services

As fun as opening command windows is, we should have these instances installed as services so we don't have to worry about them when we go to use them.

  • Navigate back to where you copied NSSM
  • Execute nssm install ZooKeeper1, set the path to C:\ZooKeeper\1\bin\zkServer.cmd and start up dir to C:\ZooKeeper\1\bin, hit Install Service
  • Execute nssm install ZooKeeper2, set the path to C:\ZooKeeper\2\bin\zkServer.cmd and start up dir to C:\ZooKeeper\2\bin, hit Install Service
  • Execute nssm install ZooKeeper3, set the path to C:\ZooKeeper\3\bin\zkServer.cmd and start up dir to C:\ZooKeeper\3\bin, hit Install Service
  • Open windows services, start ZooKeeper1, ZooKeeper2, ZooKeeper3

Install Solr

We'll do the same thing with Solr. We'll create and configure three folders where our Solr instance will live. Feel free to change any paths,

First Solr Instance

  • Create C:\Solr
  • Create C:\Solr\1\
  • Copy contents of Solr download into C:\Zolr\1
  • Navigate to C:\Solr\1\bin, open solr.in.cmd in a text editor
  • Uncomment ZK_HOST property, set to 127.0.0.1:2181
  • Uncomment ZK_CLIENT_TIMEOUT property
  • Uncomment SOLR_PORT
  • Uncomment SOLR_SSL_ENABLED
  • Uncomment SOLR_SSL_KEY_STORE
  • Set SOLR_SSL_KEY_STORE to C:\Solr\1\bin\etc\solr-ssl.keystore.jks
  • Uncomment SOLR_SSL_KEY_STORE_PASSWORD
  • Uncomment SOLR_SSL_KEY_STORE_TYPE
  • Uncomment SOLR_SSL_TRUST_STORE
  • Set SOLR_SSL_TRUST_STORE to C:\Solr\1\bin\etc\solr-ssl.keystore.jks
  • Uncomment SOLR_SSL_TRUST_STORE_PASSWORD
  • Uncomment SOLR_SSL_TRUST_STORE_TYPE
  • Uncomment SOLR_SSL_NEED_CLIENT_AUTH
  • Uncomment SOLR_SSL_WANT_CLIENT_AUTH
  • Create C:\Solr\1\bin\etc
  • Open command prompt in C:\Solr\1\bin\etc
  • Execute the following command:
keytool -genkeypair -alias solr-ssl -keyalg RSA -keysize 2048 -keypass secret -storepass secret -validity 9999 -keystore solr-ssl.keystore.jks -ext SAN=DNS:localhost,IP:192.168.1.3,IP:127.0.0.1 -dname "CN=localhost, OU=Organizational Unit, O=Organization, L=Location, ST=State, C=Country"
  • Create C:\Solr\1\bin\run.bat set contents to:
solr start -f -cloud -Dsolr.ssl.checkPeerName=false

Second Solr Instance

  • Copy C:\Solr\1 to C:\Solr\2
  • Open C:\Solr\2\bin\solr.in.bat in text editor
  • Set ZK_HOST to 127.0.0.1:2182
  • Set SOLR_PORT to 8984
  • Set SOLR_SSL_KEY_STORE to C:\Solr\2\bin\etc\solr-ssl.keystore.jks
  • Set SOLR_SSL_TRUST_STORE to C:\Solr\2\bin\etc\solr-ssl.keystore.jks

Third Solr Instance

  • Copy C:\Solr\1 to C:\Solr\3
  • Open C:\Solr\3\bin\solr.in.bat in text editor
  • Set ZK_HOST to 127.0.0.1:2183
  • Set SOLR_PORT to 8985
  • Set SOLR_SSL_KEY_STORE to C:\Solr\3\bin\etc\solr-ssl.keystore.jks
  • Set SOLR_SSL_TRUST_STORE to C:\Solr\3\bin\etc\solr-ssl.keystore.jks

Installing Solr as Services

Same story with Solr, we shouldn't have to manually start these instances when we want to use it. We'll use NSSM again to install these instances as services.

  • Navigate back to where you copied NSSM
  • Execute nssm install Solr1, set the path to C:\Solr\1\bin\run.bat and start up dir to C:\Solr\1\bin, hit Install Service
  • Execute nssm install Solr2, set the path to C:\Solr\2\bin\run.bat and start up dir to C:\Solr\2\bin, hit Install Service
  • Execute nssm install Solr3, set the path to C:\Solr\3\bin\run.bat and start up dir to C:\Solr\3\bin, hit Install Service
  • Open windows services, start Solr1, Solr2, Solr3

At this point, Solr should be up and running. Navigate to https://localhost:8983/ and if you go to Cloud > Tree in the sidebar and expand live_nodes, you should see three nodes present.

Solr with three lives nodes active

Additional Solr Configuration

solr zk upconfig -n testconfig -d C:\Solr\1\server\solr\configsets_default

While I'm just uploading a test config set here, this should be your configset for Sitecore.

At this point you should restart all Solr services. After that's completed, you should be able to create a new collection with the configset that you uploaded to ZooKeeper.

Conclusion

There were a lot of additional steps to get all of these instances running on the same server. In a different environment, you likely would just keep all the ports the same and keep all the directory structures consistent across all severs. Also in these examples, it might be better to keep the SSL key in a central location and just reference that single location.

Additional References