Time for action – adding a rack awareness script
We can enhance the default flat rack configuration by creating a script that derives the rack location for each host.
Create a script in the Hadoop user's home directory on the NameNode host called
rack-script.sh
, containing the following text. Remember to change the IP address to one of your HDFS nodes.#!/bin/bash if [ $1 = "10.0.0.101" ]; then echo -n "/rack1 " else echo -n "/default-rack " fi
Make this script executable.
$ chmod +x rack-script.sh
Add the following property to
core-site.xml
on the NameNode host:<property> <name>topology.script.file.name</name> <value>/home/Hadoop/rack-script.sh</value> </property>
Restart HDFS.
$ start-dfs.sh
Check the filesystem via
fsck
.$ Hadoop fsck –rack
The output of the preceding command can be shown in the following screenshot:
What just happened?
We first created a simple script that returns one value for a named node and a default value for all others....