Skip to content

Instantly share code, notes, and snippets.

@nddipiazza
Last active July 28, 2017 20:23
Show Gist options
  • Save nddipiazza/d43b3244ec6c6f41ea6b834b1e7b102d to your computer and use it in GitHub Desktop.
Save nddipiazza/d43b3244ec6c6f41ea6b834b1e7b102d to your computer and use it in GitHub Desktop.
A simple bash script that can set up a Linux node for a 3 node cluster
#!/usr/bin/env bash
# Enter each private IP address of each node in this list
zkhost1=IPADDRESS1
zkhost2=IPADDRESS2
zkhost3=IPADDRESS3
zkhost=$zkhost1:9983,$zkhost2:9983,$zkhost3:9983
# Assign an ID to this node.
# This will be the only thing in this script that is unique on each node of the cluster.
# Use increasing IDs starting with 1, 2, 3, etc.
# IMPORTANT: Make sure the ID matches up with the zkhost# from above, or Fusion will not start!
myid=1
# The Fusion home directory. If you are using another version of fusion, update this line.
fusion_dir=$HOME/fusion/3.1.0
# This will create the data/zookeeper directory and create the myid file.
mkdir "$fusion_dir/data/zookeeper"
echo "$myid" > "$fusion_dir/data/zookeeper/myid"
# This will add each server node to the zoo.cfg
echo "server.1=$zkhost1:2888:3888" >> "$fusion_dir/conf/zookeeper/zoo.cfg"
echo "server.2=$zkhost2:2888:3888" >> "$fusion_dir/conf/zookeeper/zoo.cfg"
echo "server.3=$zkhost3:2888:3888" >> "$fusion_dir/conf/zookeeper/zoo.cfg"
# This will add zookeeper host to the agent properties.
echo "" >> "$fusion_dir/conf/fusion.properties"
echo "" >> "$fusion_dir/conf/fusion.properties"
echo "solr.zk.connect = $zkhost" >> "$fusion_dir/conf/fusion.properties"
echo "api.zk.connect = $zkhost" >> "$fusion_dir/conf/fusion.properties"
echo "connectors.zk.connect = $zkhost" >> "$fusion_dir/conf/fusion.properties"
echo "spark-master.zk.connect = $zkhost" >> "$fusion_dir/conf/fusion.properties"
echo "spark-worker.zk.connect = $zkhost" >> "$fusion_dir/conf/fusion.properties"
echo "ui.zk.connect = $zkhost" >> "$fusion_dir/conf/fusion.properties"
sed -i "s/# default.zk.connect = .*/default.zk.connect = $zkhost/g" "$fusion_dir/conf/fusion.properties"
# This will start Fusion
"$fusion_dir/bin/fusion" start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment