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.
- Solr: https://lucene.apache.org/solr/downloads.html (v7.2.1)
- Zookeeper: https://www.apache.org/dyn/closer.cgi/zookeeper/ (v3.5.5). Choose the.bin.tar file. For example: apache-zookeeper-3.5.5-bin.tar
- Get Solrssl.ps1 from Kam Figy’s blog: https://kamsar.net/index.php/2017/10/Quickly-add-SSL-to-Solr/ This is the Powershell script to create self-signed SSL for installed Solr instances.
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”.
- Node 1:
\node1\solr-7.2.1\bin> solr start -c -p 8983 -z localhost:2181
- 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
configsetfolder under the “
node1\solr-7.2.1\server\solr\configsets”and copy the
_defaultfolder to a new
- In the
sitecore_configs/solrconfig.xmlfile, set the
- In this new folder, open the
managed-schemafile in the
conffolder and do the following:
- Set the value in
- In the fields section, add the following field configuration for
name="_uniqueid" type="string" indexed="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
- 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
solr.search and add the token
<add name="solr.search" 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.