How to enable JMX port for Namenode and Datanode in Hadoop from Ambari

I am using HDP 3.1.1. I am trying to enable JMX for HDFS by following the below link. After restarting the HDFS. again the changes are removing automatically. I tried to add the same lines from Ambari as well At that time HDFS itself is not starting.