hadoop ha环境下的datanode启动报错java.lang.NumberFormatException: For input string: "10m"
hadoop ha环境启动start-dfs.sh的时候datanode启动不了,并且报错。
[hadoop@datanode2 ~]$ cat /home/hadoop/hadoop-2.7.3/logs/hadoop-hadoop-datanode-datanode2.log
2019-03-24 18:40:46,422 FATAL org.apache.hadoop.hdfs.server.datanode.DataNode: Exception in secureMain
java.lang.NumberFormatException: For input string: "10m"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Long.parseLong(Long.java:441)
at java.lang.Long.parseLong(Long.java:483)
at org.apache.hadoop.conf.Configuration.getLong(Configuration.java:1311)
at org.apache.hadoop.hdfs.server.datanode.DataXceiverServer.<init>(DataXceiverServer.java:123)
at org.apache.hadoop.hdfs.server.datanode.DataNode.initDataXceiver(DataNode.java:904)
at org.apache.hadoop.hdfs.server.datanode.DataNode.startDataNode(DataNode.java:1111)
at org.apache.hadoop.hdfs.server.datanode.DataNode.<init>(DataNode.java:429)
at org.apache.hadoop.hdfs.server.datanode.DataNode.makeInstance(DataNode.java:2374)
at org.apache.hadoop.hdfs.server.datanode.DataNode.instantiateDataNode(DataNode.java:2261)
at org.apache.hadoop.hdfs.server.datanode.DataNode.createDataNode(DataNode.java:2308)
at org.apache.hadoop.hdfs.server.datanode.DataNode.secureMain(DataNode.java:2485)
at org.apache.hadoop.hdfs.server.datanode.DataNode.main(DataNode.java:2509)
然后排查了一下自己的配置文件,只有如下的一个10m
<!--hdfs移动数据的速度,默认值为1M/S的速度。一般情况下设置为10M;好像只能设置数字-->
<property>
<name>dfs.datanode.balance.bandwidthPerSec</name>
<value>10m</value>
<description>
Specifies the maximum amount of bandwidth that each datanode
can utilize for the balancing purpose in term of
the number of bytes per second. You can use the following
suffix (case insensitive):
k(kilo), m(mega), g(giga), t(tera), p(peta), e(exa)to specify the size
(such as 128k, 512m, 1g, etc.).
Or provide complete size in bytes (such as 134217728 for 128 MB).
</description>
</property>
问题的报错,从英文看来很明显,dfs.datanode.balance.bandwidthPerSec并不支持10m这样的格式,而是只适用数字,所以将10m换成=10485760(10*1024*1024),
重启start-dfs.sh后,可以看到datanode启动正常了。