Skip to main content

Setting Solr cloud with Zookeeper for Sitecore

Solr Cloud : 
SolrCloud is designed to provide a highly available, fault tolerant environment for distributing your indexed content and query requests across multiple servers.
It’s a system in which data is organized into multiple pieces, or shards, that can be hosted on multiple machines, with replicas providing redundancy for both scalability and fault tolerance, and a ZooKeeper server that helps manage the overall structure so that both indexing and search requests can be routed properly. For More Info visit SolrCloud.
Here I am going to explain Solrcloud setup (2 solr nodes on different machine) , 3 ZK (on different server) with shard 2.  Solrconfig file is placed on central location.
Prerequisites :
Zookeeper Setup /machine -1 : 
  • Download Zookeeper-3.4.10 and extract packages using 7-zip.
  • Place the extracted files under created directory (ZK_Home) on machine -1. Ex : E:\SolrCloudPOC\ZooServer\Zookeeper1Zoo1
  • Go inside ZK_Home\Conf directory and rename zoo_sample.cfg  to zoo.cfg.
  • Create a directory data/1 inside conf folder for storing the ZK data.
  • The ID identifies each server, so in the case of this first instance, you would create a file /conf/data/1/myid with the content “1” ( myid File should be without extension)zoo2.JPG
  • Edit the zoo.config file and modify the dataDir parameter where would you like to store the ZK data.  dataDir=/SolrCloudPOC/ZooServer/Zookeeper1/conf/data/1
  • Add server entries which list all ZK server that run ZK instances.  For server info visit site External ZooKeeper Ensemble                                                                    server.1= zookeeperServer1.com:2888:3888
    server.2= zookeeperServer2.com:2889:3889
    server.3= zookeeperServer3.com:2890:3890
  • Zoo.cfg file looks like :                  dataDir=/SolrCloudPOC/ZooServer/Zookeeper1/conf/data/1
    clientPort=2181
    initLimit=5
    syncLimit=2
    server.1= zookeeperServer1.com:2888:3888
    server.2= zookeeperServer2.com:2889:3889
    server.3= zookeeperServer3.com:2890:3890
  • Do host entry ex :                                                                                                              133.0.1.1 zookeeperServer1.com  ( First Server, IP should be of first server)
    133.0.1.2 zookeeperServer2.com ( Second server , IP should be of second server)
    133.0.1.3 zookeeperServer3.com ( Second server , IP should be of third server)
  • Now open the command prompt in Administrator mode and navigate ZK_HOME/bin directory. Execute the command zkserver.cmd which will start the ZK server. Zoo3.JPG
  • Repeat all the above steps on all server which run the ZK server.
Solr Setup | Machine – 1 : 
  • Install the JRE if it is not installed on server and setup the JAVA_HOME and path Solr1.JPG
  • Download the Solr -5.3.1 zip file and extract it in one directory. Ex -JAVA_DIR E:\SolrCloudPOC\Solr\solr1Solr2
  • Do ZK host entry ex :                                                                                                              133.0.1.1 zookeeperServer1.com  ( First Server, IP should be of first server)
    133.0.1.2 zookeeperServer2.com ( Second server , IP should be of second server)
    133.0.1.3 zookeeperServer3.com ( Second server , IP should be of third server)
  • Copy directory JAVA_DIR\configsets\sample_techproducts_configs\conf  and place it inside JAVA_DIR and rename the folder as SolrConfig. EX : E:\SolrCloudPOC\Solr\SolrConfigsolr3
  • Generate the schema.xml and place it inside solrconfig folder. For generating the schema.xml see the link : Generate the Solr Schema.xml
  • Now start the Solr. Open the command prompt in administrator mode and navigate the folder JAVA_DIR\bin and execute the command. solr start -cloud -p 8988 -z “zookeeperServer1.com:2181,zookeeperServer2.com:2182,zookeeperServer3.com:2183”Solr4
  • Browse the solr url : http:localhost:8988/solr and verify the Solr dashboard.
  • For stopping the Solr you can use command : solr stop -cloud -p 8988
  • Repeat above all steps for setting up the solr on machine -2 . For starting the solr on machine 2 use below command on command prompt. solr start -cloud -p 8989 -z “zookeeperServer1.com:2181,zookeeperServer2.com:2182,zookeeperServer3.com:2183
Push SolrConfig on ZooKeeper Server : 
  • We want to manage the Solrconfig by zookeeper centrally.
  • Login on Solr machine – 1 Server where Solrconfig placed inside folder E:\SolrCloudPOC\Solr\SolrConfig
  • Open the command prompt in Administrator mode. change the  directory E:\SolrCloudPOC\Solr\solr1\server\scripts\cloud-scripts and execute the below command.
  • zkcli.bat -zkhost “zookeeperServer1.com:2181,zookeeperServer2.com:2182,zookeeperServer3.com:2183” -cmd upconfig -confname solrconfig -confdir E:\SolrCloudPOC\Solr\SolrConfigSolr5.JPG
  • Browse the solr url : http:localhost:8988/solr and verify the SolrConfig files.  Solr6
Create the Collection : 
  • The Collections API is used to enable you to create, remove, or reload collections, but in the context of SolrCloud you can also use it to create collections with a specific number of shards and replicas etc. For more info visit :  Collection API
  • Browse below URL in Solr server inside browser for creating the collection.
  • http://localhost:8988/solr/admin/collections?action=CREATE&name=sitecore_analytics_index&numShards=2&replicationFactor=2&maxShardsPerNode=2&createNodeSet=[IP Address Solr1]:8988_solr,[IP Address of Solr2]:8989_solr&collection.configName=solrconfig
  • Verify the created collection after browsing the solr URL.Solr7.JPG
  • Verify created shard in File system : Solr8.JPG
  • Similarly you can create another collection.
Rebuild the Sitecore Index : 
  • Modify the Solr config file on CMS environment and point the base address on SolrCloud address. For more info for setting up the SOLR Config visit link Setting up Solr
  • EX :
  • Login to Siteore CMS server. navigate the control panel and click on Indexing Manger Link.
  • Select the index which you want to rebuild it and rebuild the index. solr9.JPG

Comments

Post a Comment

Popular posts from this blog

Sitecore Publishing target and Solr Configuration

Creating a new publishing target is very helpful if your Sitecore environment is setup in multiple content delivery servers. We can publish data from Master database to one or more publishing target databases. Main thing to notice here is Master database contains all versions of any content or assets while publishing target database contains single latest version for each language.      This post aims to provide systematic instructions to set up publishing target. It comprises of a target database (where the content will be published) and publishing target definition item in master database that points to that target database.             Post creation of publishing target need to take care of Solr configuration. This post cove master slave Solr configuration and onPublishEndAsync strategy. We are using 1 Solr Master instance and 6 Slave instance (2-EU, 2-Ap, 2- NA).     1   So...

Setup Sitecore Habitat v9.0 project in simple way

In this article , I would describe how to setup the Sitecore habitat V9.0 project with Sitecore Experience Platform 9.0 rev in very simple way. I used below system configuration to setup this project: 1. Windows 10 (32/64-bit) 2. IIS 10.0 3. .NET Framework 4.6.2 4. Microsoft Visual Studio 2017 5. Microsoft SQL Server 2017 6. Solr 6.6.2 7. Microsoft PowerShell® version 5.0 8. Web Platform Installer 5.0. 9. Web Deploy 3.6 for Hosting Servers 10. Node-v8.9.4-x64 Follow below steps to setup the project. A).   Habitat require Sitecore instance. Setup the clean Sitecore 9.0 instance. Ex : http://demo.local.com , Directory location : C:\inetpub\wwwroot\demo.local.com   For more info visit -   https://dev.sitecore.net/ B). Download the Habitat V9.0 project from Github site :  https://github.com/Sitecore/Habitat/     Note  :  When you download the packages, it is possible that the .ZIP packages are marked as blocke...

Web Deploy setup and configuration with Sitecore

Web Deploy empowers Visual Studio and WebMatrix to help developers streamline the deployment of Web applications to Microsoft IIS Web servers or to Microsoft Azure Websites. In addition, integration with Web Platform Installer allows developers to simply and easily install community webapplications.   This post describe the installation of Web Deploy and Configuration with Sitecore instance.  This post will be very useful if you want to sync your Sitecore media items with all of the CD's environment (Distributed environment) . In one of my previous project, I was keeping all the media items in file system and synchronizing all the files from CM to Cd's server. This solution is tested with 1 CMS and 6 CD's server (2-EU, 2- NA, 2- AP) with more than 5 Lakh files.  1.       Software Pre-requisites           a.       OS – Window 7/ Windows Server 2008 R2 Enterprise       ...