datanode因org.apache.hadoop.util.DiskChecker $ DiskErrorException而失败

时间:2018-10-17 07:50:39

标签: hadoop

最近,我安装了Hadoop并格式化了namenode。名称节点启动正常,但数据节点启动失败。这是datanode错误日志

  STARTUP_MSG:   build = git@github.com:hortonworks/hadoop.git -r 3091053c59a62c82d82c9f778c48bde5ef0a89a1; compiled by 'jenkins' on 2018-05-11T07:53Z
STARTUP_MSG:   java = 1.8.0_181
************************************************************/
2018-10-17 15:08:42,769 INFO  datanode.DataNode (LogAdapter.java:info(47)) - registered UNIX signal handlers for [TERM, HUP, INT]
2018-10-17 15:08:43,665 INFO  checker.ThrottledAsyncChecker (ThrottledAsyncChecker.java:schedule(122)) - Scheduling a check for [DISK]file:/hadoop/hdfs/data/
2018-10-17 15:08:43,682 ERROR datanode.DataNode (DataNode.java:secureMain(2692)) - Exception in secureMain
org.apache.hadoop.util.DiskChecker$DiskErrorException: Invalid value configured for dfs.datanode.failed.volumes.tolerated - 1. Value configured is >= to the number of configured volumes (1).
    at org.apache.hadoop.hdfs.server.datanode.checker.StorageLocationChecker.check(StorageLocationChecker.java:174)
    at org.apache.hadoop.hdfs.server.datanode.DataNode.makeInstance(DataNode.java:2584)
    at org.apache.hadoop.hdfs.server.datanode.DataNode.instantiateDataNode(DataNode.java:2493)
    at org.apache.hadoop.hdfs.server.datanode.DataNode.createDataNode(DataNode.java:2540)
    at org.apache.hadoop.hdfs.server.datanode.DataNode.secureMain(DataNode.java:2685)
    at org.apache.hadoop.hdfs.server.datanode.DataNode.main(DataNode.java:2709)
2018-10-17 15:08:43,688 INFO  util.ExitUtil (ExitUtil.java:terminate(124)) - Exiting with status 1
2018-10-17 15:08:43,696 INFO  datanode.DataNode (LogAdapter.java:info(47)) - SHUTDOWN_MSG: 
/************************************************************
SHUTDOWN_MSG: Shutting down DataNode at hdp2.com/192.168.100.12

dfs.datanode.failed.volumes.tolerated - 1是什么意思?是什么导致了这样的错误?

2 个答案:

答案 0 :(得分:0)

检查hdfs-site.xml。此属性必须设置为0或更高:

dfs.datanode.failed.volumes.tolerated
  

在datanode停止之前允许失败的卷数   提供服务。默认情况下,任何卷故障都将导致数据节点   关闭。

答案 1 :(得分:0)

当我尝试解决此问题时,我搜索了sourceCode

 final int volFailuresTolerated =
  conf.getInt(DFSConfigKeys.DFS_DATANODE_FAILED_VOLUMES_TOLERATED_KEY,
              DFSConfigKeys.DFS_DATANODE_FAILED_VOLUMES_TOLERATED_DEFAULT);

String[] dataDirs = conf.getTrimmedStrings(DFSConfigKeys.DFS_DATANODE_DATA_DIR_KEY);

int volsConfigured = (dataDirs == null) ? 0 : dataDirs.length;
int volsFailed = volsConfigured - storage.getNumStorageDirs();
this.validVolsRequired = volsConfigured - volFailuresTolerated;

if (volFailuresTolerated < 0 || volFailuresTolerated >= volsConfigured) {
  throw new DiskErrorException("Invalid volume failure "
      + " config value: " + volFailuresTolerated);
}
if (volsFailed > volFailuresTolerated) {
  throw new DiskErrorException("Too many failed volumes - "
      + "current valid volumes: " + storage.getNumStorageDirs() 
      + ", volumes configured: " + volsConfigured 
      + ", volumes failed: " + volsFailed
      + ", volume failures tolerated: " + volFailuresTolerated);
}

如您所见

  

在datanode停止之前允许失败的卷数   提供服务。默认情况下,任何卷故障都将导致数据节点   关闭。

那是datanode可以容忍的磁盘损坏次数。

在Hadoop集群中,磁盘经常只读或损坏。在启动时,datanode将使用在dfs.datanode.data.dir下配置的文件夹(用于存储块)。如果存在一些无法使用的值以及上面配置的数字,则DataNode将无法启动。

在我的hadoop环境中,fs.datanode.data.dir被配置为1个磁盘,因此dfs.datanode.failed.volumes.tolerated被设置为1,这会使磁盘变坏。该行下只有一个磁盘,并且volFailuresToleratedvolsConfigured的值均为1,因此将导致代码失败。