Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]

Support Questions

Find answers, ask questions, and share your expertise
Announcements
Share your experience with Cloudera on G2 and get a $25 Amazon Gift card.
Hi, I'm CLEO! Something exciting is coming to the Community. Stay Tuned!

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

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?

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