Preparing Zookeeper for SolrCloud 7.7.

Created: 18 April 2019  Modified:

One of the key ingredients to get SolrCloud working is setting up Zookeeper. The Solr website has a good article on preparing Zookeeper for SolrCloud. I had done this a few years ago, for Solr 4. Found myself a little disoriented when I came back, to do the same, for Solr 7.7. Reading the link above is recommended if you are not familiar with Zookeeper. I will be using cluster and ensemble interchangeable. As well as server and node.

First lets define our cluster/ensemble. We’ll make it a simple cluster of three nodes.

Good Diagram

Deployment will consist of placing Zookeeper server in /your/directory/path/zookeeper. Then we make and deploy the same zoo.cfg file to all the servers/nodes. This is followed by creating a myid file which is different on all the nodes. This is a basic setup and doesn’t include security and monitoring. Download the latest Zookeeper and extract it to a location where you can browse and add/change files.

The first step is to create our zoo.cfg file that will be deployed to all the servers/nodes. You can set a custom client port. In this example I have set it to the default which is 2181. If you do set a differenct port number see Zookeeper: Useful Command Line

/your/directory/path/zookeeper/conf/zoo.cfg

 # The number of milliseconds of each tick
tickTime=2000
=  The number of ticks that the initial
=  synchronization phase can take
initLimit=10
=  The number of ticks that can pass between
=  sending a request and getting an acknowledgement
syncLimit=2

=  the directory where the snapshot is stored.
=  dataDir=/opt/zookeeper/data
=  NOTE: Solr defaults the dataDir to <solrHome>/zoo_data
dataDir=/your/directory/path/zookeeper/data

=  the port at which the clients will connect
clientPort=2181
=  NOTE: Solr sets this based on zkRun / zkHost params
server.1=192.168.0.1:2888:3888
server.2=192.168.0.2:2888:3888
server.3=192.168.0.3:2888:3888


= Remove old stuff
autopurge.snapRetainCount=3
autopurge.purgeInterval=1

Now we create our myid file. This contains a number that corresponds to the server entries in the zoo.cfg. So the myid file for 192.168.0.1 will contain “1” and 192.168.0.3 myid file will contain “3”.

/your/directory/path/zookeeper/data/myid

1

As part of a deploy script I found the following Linux command lines useful for automatically creating the myid files on the servers. This would need to be run on the target servers.

parse zoo.cfg and find myid

cat /apps01/zookeeper/conf/zoo.cfg | grep $(hostname -i) | cut -d'=' -f 1 | cut -d'.' -f 2 > /your/directory/path/zookeeper/data/myid
tags: zookeeper - solr - solrcloud
   Less Is More