Configuring an external ZooKeeper ensemble
ZooKeeper is a centralized service for maintaining configuration information, mechanisms for fail-overs, and state management. In this example setup, ZooKeeper will manage the distribution of configuration files across the cluster and keep each Solr server synchronized with each other.
You can download ZooKeeper from the links provided here. To know which version of ZooKeeper you
should be using with your SolrCloud cluster, go to your Solr's <solr-home>/server/solr-webapp/webapp/WEB-INF/lib/
directory. In there, you should see the ZooKeeper library, which should tell you which version of ZooKeeper is
compatible with your SolrCloud cluster.
Assumptions
- This guide will be using Solr
8.5.2
and ZooKeeper3.6.1
. - Universal configurations will be stored at a shared directory mounted at
/datastore/apps/zookeeper/configs
. -
Three ZooKeeper instances will be configured, namely
zk1
,zk2
, andzk3
.-
zk1
- Home directory:
/datastore/apps/zookeeper/instances/zk1/
- IP address:
192.168.21.71
- Home directory:
-
zk2
- Home directory:
/datastore/apps/zookeeper/instances/zk2/
- IP address:
192.168.21.72
- Home directory:
-
zk3
- Home directory:
/datastore/apps/zookeeper/instances/zk3/
- IP address:
192.168.21.73
- Home directory:
-
Procedure
-
Download a copy of ZooKeeper's portable installer (
zookeeper-3.6.1.tar.gz
in this case), extract the file, and copy the extracted directory to each of your ZooKeeper instances' home directory.1 2 3 4 5 6 7 8 9 10 11
cd /datastore/apps/zookeeper/ # Dowload, extract, and rename the installer wget https://downloads.apache.org/zookeeper/zookeeper-3.6.1/apache-zookeeper-3.6.1-bin.tar.gz tar -xvf apache-zookeeper-3.6.1-bin mv apache-zookeeper-3.6.1-bin zookeeper # Copy the directory to each instance's home folder cp -r zookeeper instances/zk1/ cp -r zookeeper instances/zk2/ cp -r zookeeper instances/zk3/
-
Create
/data/<zookeper-id>/myid
files in each instance's home directory where:<zookeper-id>
should be replaced with the ZooKeeper instance's respective ID number and;- Every
myid
file's content is also the ZooKeeper instance's respective ID number.
1 2 3 4 5 6 7 8 9
# Create the directories first mkdir -p instances/zk1/data/1 mkdir -p instances/zk2/data/2 mkdir -p instances/zk3/data/3 # Create the files echo "1" > instances/zk1/data/1/myid echo "2" > instances/zk2/data/2/myid echo "3" > instances/zk3/data/3/myid
-
After creating the data directories, create each ZooKeeper instance's configuration file (
zoo.cfg
).1 2 3 4 5 6 7 8 9 10 11 12 13
# Open the configuration file vi <zookeeper-home>/zookeeper/conf/zoo.cfg # Define the desired configuration tickTime=2000 initTime=10 initLimit=5 syncLimit=5 clientPort=2181 dataDir=<zookeeper-home>/data/<zookeper-id> server.1=192.168.21.71:2888:3888 server.2=192.168.21.72:2888:3888 server.3=192.168.21.73:2888:3888
Placeholders should be replaced:
<zookeeper-home>
with the ZooKeeper instance's home directory.<zookeeper-id>
with the ZooKeeper instance's ID.
Perform these commands for every ZooKeeper instance.
-
Finally, start ZooKeeper by calling
zkServer.sh start
on each server.1 2 3
/datastore/apps/zookeeper/instances/zk1/zookeeper/bin/zkServer.sh start /datastore/apps/zookeeper/instances/zk2/zookeeper/bin/zkServer.sh start /datastore/apps/zookeeper/instances/zk3/zookeeper/bin/zkServer.sh start
That's it! Your ZooKeeper quorum is now ready with three instances up and running ready to serve Solr.