Saturday, March 2, 2019

Hadoop HDFS Admin - Network Topology Of Cluster


sudo vi /etc/hadoop/conf/core-site.xml


<property>

    <name>net.topology.node.switch.mapping.impl</name>

    <value>org.apache.hadoop.net.ScriptBasedMapping</value>

</property>



<property>

    <name>net.topology.script.file.name</name>

    <value>/etc/hadoop/conf/topology.sh</value>

</property>



sudo vi /etc/hadoop/conf/topology.data



10-10-10-10 /rack1

20-20-20-20 /rack1

30-30-30-30 /rack1

40-40-40-40 /rack2



--Topology script will be called when Namenode starts


./etc/hadoop/conf/topology.sh 10-10-10-10 20-20-20-20 30-30-30-30 40-40-40-40


sudo vi /etc/hadoop/conf/topology.sh



#!/bin/bash

HADOOP_CONF=/etc/hadoop/conf

while [ $# -gt 0 ] ; do

  nodeArg=$1

  exec< ${HADOOP_CONF}/topology.data

  result=""

  while read line ; do

    ar=( $line )

    if [ "${ar[0]}" = "$nodeArg" ] ; then

      result="${ar[1]}"

    fi

  done

  shift

  if [ -z "$result" ] ; then

     echo -n "/rack0"

  else

    echo -n "$result "

  fi

done



--IP Address encoded with rack information


xx.xx.rackno.nodeno

50-50-50-50