Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

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

Solved Go to solution
Highlighted

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

New Contributor
 
1 ACCEPTED SOLUTION

Accepted Solutions

Re: 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

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

.


2 REPLIES 2

Re: 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

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

.


Re: 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

New Contributor

@Jay Kumar SenSharma thank you,it worked