While performing distcp, it is frequently required to specify Namenode HA for remote cluster. Recently, I had a requirement to move data from production to DR cluster using distcp. In my case, both production and DR cluster utilize Namenode HA.
To get distcp to recognize HA information for remote cluster, hdfs-site.xml file needs to be modified. There are 2 ways of achieving it.
- Creating a copy of hdfs-site.xml file - This can be done if developer doesn’t have access to modify default hdfs-site.xml for cluster. To use this option, a new config directory should be created. At a minimum following files need to be copied to new config directory.
Now, config directory can be specified on command line using
- Modifying default hdfs-site.xml file for cluster – This allows any hadoop command to accept HA Namenode for remote cluster. Using Ambari, new properties can be added to custom hdfs-site section
Note: It only works with Ambari 2.4.0 and above.
In either case, following changes need to be made to hdfs-site.xml file.
dfs.nameservices property should be modified to add multiple nameservices. Multiple nameservices can be added by listing services separated by ,
For any new Nameservice, following entries should be added to hdfs-site.xml
Voilla! These techniques can be extended to get multiple Nameservices recognized by any hadoop commands. This can be very beneficial if working on multiple clusters from single machine.