Created on
06-11-2019
06:25 AM
- last edited on
06-07-2026
11:32 PM
by
VidyaSargur
I want to hit a specific JMX port for the DataNode (which is port 50070), but I don't want to hardcode the port number. How can I retrieve this port number dynamically, and where exactly is it stored?
Created 06-11-2019 06:35 AM
May be you can invoke the Ambari API call to find the current HDFS Configs and then grep the configs that you want.
Example Finding DataNode Http Port.
# curl -s -u admin:admin -H "X-Requested-By:ambari" -X GET "http://$AMBARI_HOSTNAME:8080/api/v1/clusters/$CLUSTER_NAME/configurations/service_config_versions?service_name=HDFS%26is_current=true" | grep "dfs.datanode.http.address" | awk -F"\"" '{print $4}'Example Finding NameNode Http Port.
# curl -s -u admin:admin -H "X-Requested-By:ambari" -X GET "http://$AMBARI_HOSTNAME:8080/api/v1/clusters/$CLUSTER_NAME/configurations/service_config_versions?service_name=HDFS%26is_current=true" | grep "dfs.namenode.http-address" | awk -F"\"" '{print $4}'.
Also if you have the filesystem access then you can get the configs properties values from the following file:
# grep -A1 'dfs.namenode.http-address' /etc/hadoop/conf/hdfs-site.xml # grep -A1 'dfs.datanode.http.address' /etc/hadoop/conf/hdfs-site.xml
.
Another option will be to get the output of the following commands:
# hdfs getconf -confKey "dfs.datanode.http.address"
.
Created 06-11-2019 06:35 AM
May be you can invoke the Ambari API call to find the current HDFS Configs and then grep the configs that you want.
Example Finding DataNode Http Port.
# curl -s -u admin:admin -H "X-Requested-By:ambari" -X GET "http://$AMBARI_HOSTNAME:8080/api/v1/clusters/$CLUSTER_NAME/configurations/service_config_versions?service_name=HDFS%26is_current=true" | grep "dfs.datanode.http.address" | awk -F"\"" '{print $4}'Example Finding NameNode Http Port.
# curl -s -u admin:admin -H "X-Requested-By:ambari" -X GET "http://$AMBARI_HOSTNAME:8080/api/v1/clusters/$CLUSTER_NAME/configurations/service_config_versions?service_name=HDFS%26is_current=true" | grep "dfs.namenode.http-address" | awk -F"\"" '{print $4}'.
Also if you have the filesystem access then you can get the configs properties values from the following file:
# grep -A1 'dfs.namenode.http-address' /etc/hadoop/conf/hdfs-site.xml # grep -A1 'dfs.datanode.http.address' /etc/hadoop/conf/hdfs-site.xml
.
Another option will be to get the output of the following commands:
# hdfs getconf -confKey "dfs.datanode.http.address"
.
Created 06-12-2019 04:12 AM
@Jay Kumar SenSharma thank you,it worked