错误:无法找到datanode建议检查群集健康

问题描述:

我已经写了下面的代码创建/写入文件到hdfs通过PHP。用下面的API参考https://github.com/Yujiro3/WebHDFS错误:无法找到datanode建议检查群集健康

但代码提供了以下错误而无法上传文件中所需的目录:

{"RemoteException":{"exception":"IOException","javaClassName":"java.io.IOException","message":"Failed to find datanode, suggest to check cluster health."} 
HTTP/1.1 403 Forbidden 
Cache-Control: no-cache 
Expires: Mon, 07 Mar 2016 21:28:39 GMT 
Date: Mon, 07 Mar 2016 21:28:39 GMT 
Pragma: no-cache 
Expires: Mon, 07 Mar 2016 21:28:39 GMT 
Date: Mon, 07 Mar 2016 21:28:39 GMT 
Pragma: no-cache 
Content-Type: application/json 
Transfer-Encoding: chunked 
Server: Jetty(6.1.26) 

这里是我的代码:

<?php 

require 'WebHDFS.php'; 
$hdfs = new WebHDFS(); 

$hdfs -> put('/user/webuser/sample.txt', "sample \ n test \ n"); 
?> 

什么修正应我做?

看来你的hdfs datanode是无法访问,并且与你的php无关。

从您的控制台尝试创建一个文件夹没有PHP,就像这样:

hdfs dfs -mkdir hdfs:///demofolder 

我猜,这会因为数据节点发生故障停机。

检查您的hdfs-site.xml文件以查看dfs.datanode.data.dir指向的位置,并确保该位置存在。然后在同一个文件中查找dfs.datanode.address。我的是0.0.0.0:50010

尝试远程登录到该IP端口:

telnet 0.0.0.0 50010 

你应该能够连接。如果你不能,那么你需要启动你的数据节点。我能够通过运行:

/usr/hdp/2.1.2/hadoop-hdfs/bin/hdfs datanode 

“hdfs”的位置可能与我的不同。 假设您已经开始尝试再次创建文件夹。如果那有效,然后再次尝试你的PHP。

我注意到的最后一件事是在WebHDFS.php中它有默认的hdfs主机和端口。

public function __construct($host='localhost', $port='50070') { 
    $this->_host = $host; 
    $this->_port = $port; 
} 

确保您的配置与默认值一致,除非您要覆盖它们。 祝你好运。