Friday, June 26, 2015

Start-up script for an installed Apache Zookeeper Cluster

If you have an installed Zookeeper-3.3.5 cluster, this script will save you from manually visiting each node and starting the zkServer there. All you have to do is grab a remote machine and run the script. The script will ask for the required information and your cluster would be up. Also, the script should work equally fine for both Ubuntu and CentOS.


#!/bin/bash

# Directory Name
echo "Enter the zookeeper setup location :"
read -e zookeeperSetupLocation

# Read the ips and the usernames of all the machines in the zookeeper cluster
echo "Enter the number of machines in the cluster";
read -e n;
for ((  i = 1 ;  i <= n;  i++  ))
do
echo "Enter the IP of cluster machine $i:"
read -e zkServer;
zkServerIPs[i]=$zkServer
echo "Enter the username of machine ${zkServerIPs[i]}"
read -e username
zkServerUsernames[i]=$username
done

# Start up the cluster
for ((  i = 1 ;  i <= n;  i++  ))
do
ssh ${zkServerUsernames[i]}@${zkServerIPs[i]} "$zookeeperSetupLocation/zookeeper-3.3.5/bin/zkServer.sh start;"
done


Thanks !!

No comments:

Post a Comment