Skip to main content
vinith_alampall
Silver ⭐️⭐️
Jun 11, 2019 1:25 PM UTC
Solved

DataNode has specific JMX port number 50070,how do I get it dynamically,Like I want to hit a particular Jmx port,but I don't want to hard code port number,I want to know where it is stored

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?

jsensharma
Platinum ⭐️⭐️
Jun 11, 2019 1:35 PM UTC

@Alampally Vinith

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"

.


2 replies

jsensharma
Platinum ⭐️⭐️
Platinum ⭐️⭐️
Jun 11, 2019 1:35 PM UTC

@Alampally Vinith

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"

.


Translate
vinith_alampall
Silver ⭐️⭐️
Jun 12, 2019 11:12 AM UTC

@Jay Kumar SenSharma thank you,it worked

Translate