Setup SolrCloud with Zookeeper For Sitecore

Apache Solr includes the ability to set up a cluster of Solr servers that combines fault tolerance and high availability called SolrCloud, these capabilities provide distributed indexing and search capabilities.

SolrCloud is flexible distributed search and indexing, without a master node to allocate nodes, shards and replicas. Instead, Solr uses Zookeeper to manage these locations, depending on configuration files and schemas. Queries and updates can be sent to any server. Solr will use the information in the Zookeeper database to figure out which servers need to handle the request.

From Sitecore 9.0 update 2, Sitecore supports SolrCloud – the Solr scaled environment. Here are steps to setup SolrCloud with Zookeeper:

1, Create a SolrCloud farm.

We use 2 Solr nodes plus an external Zookeeper instance to form a farm. Download Solr and Zookeeper from following links and extract them to same folder. Both node1 and 2 have same Solr extract files.

Install Apache Zookeeper as a standalone service.

  • Copy and Rename “zoo_sample.cfg” to “zoo.cfg” in “\apache-zookeeper-3.5.5-bin\conf”.
  • Inside zoo.cfg, edit “dataDir=/tmp/zookeeper” to something like “dataDir=/var/zookeeper” which is the location of Zookeeper snapshot storage.
  • Add entries in System Environment Variables: ZOOKEEPER_HOME = C:\Solrs\ apache-zookeeper-3.5.5-bin. Edit System Variable “Path” and append “;%ZOOKEEPER_HOME%\bin” at last.
  • Open Cmd window and type zkserver. The Zookeeper will start to run on the default port 2181 setup in zoo.cfg.
  • Before you start any SolrCloud nodes, you must configure your solr cluster properties in ZooKeeper, so that Solr nodes know to communicate via SSL.
  • Navigate to the folder \solr-7.2.1\server\scripts\cloud-scripts in command prompt and run command below.

       server\scripts\cloud-scripts\zkcli.bat -zkhost localhost:2181 -cmd clusterprop -name urlScheme -val https

  • Start Solr on node 1 and 2 with cloud mode. Navigate to node 1 and 2 Solr bin folder from Command Prompt window. These commands create a solr service on port 8983 and 7574, also attach them to Zookeeper “localhost:2128”.
  1. Node 1: \node1\solr-7.2.1\bin> solr start -c -p 8983 -z localhost:2181
  2. Node 2: \node2\solr-7.2.1\bin> solr start -c -p 7574 -z localhost:2181
  • Run command “solr status”, you can see Zookeeper is listening 2 live nodes on ports 8983 and 7574.
  • Run Solrssl.ps1 against both node 1 and 2 to add self-signed SSL certificates to Solr instances.

2, Upload the Solr configuration to Zookeeper

  • In node 1 folder, locate the configset folder under the “node1\solr-7.2.1\server\solr\configsets” and copy the _default folder to a new sitecore_configs folder.
  • In the sitecore_configs/solrconfig.xml file, set the autoCreateFieldssetting to false (update.autoCreateFields:false).
  • In this new folder, open the managed-schema file in the conf folder and do the following:
  1. Set the value in <uniqueKey>id</uniqueKey> to _uniqueid.
  2. In the fields section, add the following field configuration for _uniqueid:

<field name="_uniqueid" type="string" indexed="true" required="true" stored="true"/>

  • Go to the “node1\solr-7.2.1\bin” folder under command prompt, run the following command:

solr zk upconfig -d sitecore_configs -n sitecore -z localhost:2181

3, Add collections to SolrCloud farm

  • In one of the nodes, navigate to the Collections page in the Solr admin UI, Click Add Collection.
  • The collection names need to be matched to with core names in Sitecore index config files. Be aware of the prefix setup in SIF script.
  • In the config set field, click the sitecore collection.
  • Repeat for all Sitecore indexes.

4, Configure Sitecore to use SolrCloud as search provider

Open the “App_Config\ConnectionStrings.config” file. Specify the connection string key and add the token solrCloud=true:

<add name="" connectionString="https://localhost:8983/solr;solrCloud=true" />

5, Populate the Solr schema

  • Open the Sitecore Control Panel.
  • Click Populate Solr Managed Schema.
  • Select all indexes and click Populate.
This entry was posted in Sitecore, Solr and tagged , , , , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s