Support Questions

Find answers, ask questions, and share your expertise

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

avatar
 
1 ACCEPTED SOLUTION

avatar
Master Mentor

@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"

.


View solution in original post

2 REPLIES 2

avatar
Master Mentor

@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"

.


avatar

@Jay Kumar SenSharma thank you,it worked