Last active
October 25, 2018 11:29
Star
You must be signed in to star a gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# File Name: rack-topology.sh | |
# Adjust/Add the property "net.topology.script.file.name" | |
# to core-site.xml with the "absolute" path the this | |
# file. ENSURE the file is "executable". | |
# Supply appropriate rack prefix | |
RACK_PREFIX=default | |
# To test, supply a hostname as script input: | |
if [ $# -gt 0 ]; then | |
CTL_FILE=${CTL_FILE:-"rack_topology.data"} | |
HADOOP_CONF=${HADOOP_CONF:-"/etc/hadoop/conf"} | |
if [ ! -f ${HADOOP_CONF}/${CTL_FILE} ]; then | |
echo -n "/$RACK_PREFIX/rack " | |
exit 0 | |
fi | |
while [ $# -gt 0 ] ; do | |
nodeArg=$1 | |
exec< ${HADOOP_CONF}/${CTL_FILE} | |
result="" | |
while read line ; do | |
ar=( $line ) | |
if [ "${ar[0]}" = "$nodeArg" ] ; then | |
result="${ar[1]}" | |
fi | |
done | |
shift | |
if [ -z "$result" ] ; then | |
echo -n "/$RACK_PREFIX/rack " | |
else | |
echo -n "/$RACK_PREFIX/rack_$result " | |
fi | |
done | |
else | |
echo -n "/$RACK_PREFIX/rack " | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# File name: rack_topology.data | |
# This file should be: | |
# - Placed in the /etc/hadoop/conf directory | |
# - On the Namenode (and backups IE: HA, Failover, etc) | |
# - On the Job Tracker OR Resource Manager (and any Failover JT's/RM's) | |
# This file should be placed in the /etc/hadoop/conf directory. | |
# Add Hostnames to this file. Format <host ip> <rack_location> | |
bigdataserver-5 /rack1 | |
bigdataserver-6 /rack1 | |
bigdataserver-7 /rack2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment