有没有Spring支持wedhdfs?我没有在谷歌上找到任何有用的链接.
我想通过webhdfs连接到具有正常身份验证和kerberos身份验证的hadoop.春天是否支持这个?
任何有用的链接都会有所帮助.
谢谢
我正在尝试使用Kerberos保护我的HDP2 Hadoop集群.
到目前为止,Hdfs,Hive,Hbase,Hue Beeswax和Hue Job /任务浏览器都正常工作; 然而Hue的文件浏览器无法正常工作,它回答:
WebHdfsException at /filebrowser/
AccessControlException: SIMPLE authentication is not enabled. Available:[TOKEN, KERBEROS] (error 500)
Request Method: GET
Request URL: http://bt1svlmy:8000/filebrowser/
Django Version: 1.2.3
Exception Type: WebHdfsException
Exception Value:
AccessControlException: SIMPLE authentication is not enabled. Available:[TOKEN, KERBEROS] (error 500)
Exception Location: /usr/lib/hue/desktop/libs/hadoop/src/hadoop/fs/webhdfs.py in _stats, line 208
Python Executable: /usr/bin/python2.6
Python Version: 2.6.6
(...)
Run Code Online (Sandbox Code Playgroud)
我的hue.ini文件配置了所有security_enabled=true和其他相关参数设置.
我尝试了http://hadoop.apache.org/docs/r1.0.4/webhdfs.html#Authentication上给出的curl命令
curl -i --negotiate -L -u : "http://172.19.115.50:14000/webhdfs/v1/filetoread?op=OPEN"
Run Code Online (Sandbox Code Playgroud)
答案:
HTTP/1.1 403 Forbidden
Server: Apache-Coyote/1.1 …Run Code Online (Sandbox Code Playgroud) 你好,我正在使用 pywebhdfs python lib。我通过调用并尝试在 HDFS 上创建文件来连接 EMR。我遇到了异常,这似乎与我正在执行的操作无关,因为我在这里没有达到任何连接限制。是因为 webhdfs 的工作原理吗
from pywebhdfs.webhdfs import PyWebHdfsClient
hdfs = PyWebHdfsClient(host='myhost',port='50070', user_name='hadoop')
my_data = '01010101010101010101010101010101'
my_file = 'user/hadoop/data/myfile.txt'
hdfs.create_file(my_file, my_data)
Run Code Online (Sandbox Code Playgroud)
抛出:
requests.exceptions.ConnectionError: HTTPConnectionPool(host='masterDNS', port=50070): 超过 url 的最大重试次数:/webhdfs/v1/user/hadoop/data/myfile.txt?op=CREATE&user.name=hadoop (由NewConnectionError(': 无法建立新连接: [Errno 115] 操作正在进行中',))
我有一个 Spring 应用程序,它使用 WebHDFS 从 HDFS 读取文件。当我在 IDEA 中测试它时,它可以工作。但是在我构建项目并在本地虚拟机或连接到 HDFS 的服务器上部署 Docker 映像后,我得到:
AuthenticationException: Unauthorized
Run Code Online (Sandbox Code Playgroud)
在我的本地机器上,我必须定期初始化令牌
kinit
Run Code Online (Sandbox Code Playgroud)
用于认证。如果我不这样做,我会得到同样的错误。我在服务器上测试了没有 Docker 的应用程序,它也可以工作。我认为 Docker 映像没有看到令牌。但我不知道该怎么办。
Kerberos 用于安全。
有什么建议吗?
我组装的一个 Java 客户端可以工作:
import java.io.File;
import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.Path;
public class HdfsAppend {
public static final String hdfs = "hdfs://my222host.com";
public static final String hpath = "/tmp/odp/testfile";
public static final String message = "Hello, world!\n";
public static void main(String[] args) throws IOException {
Configuration conf = new Configuration();
conf.set("fs.defaultFS", hdfs);
FileSystem fs = FileSystem.get(conf);
Path filenamePath = new Path(hpath);
FSDataOutputStream out = fs.append(filenamePath);
out.writeBytes("DUPA DUPA DUPA\n");
}
}
Run Code Online (Sandbox Code Playgroud)
但是curl和Python whoops客户端都以类似的方式失败,这里是curl:
curl -i -X POST …Run Code Online (Sandbox Code Playgroud) 有没有一种方法或任何命令可以让我了解每个数据节点的磁盘空间或总集群磁盘空间?
我尝试了命令
dfs -du -h /
Run Code Online (Sandbox Code Playgroud)
但似乎我没有权限对许多目录执行它,因此无法获取实际的磁盘空间。
以下是非 hadoop 系统上的客户端代码,用于在安全的远程 HDFS 上执行操作。
Configuration conf = new
Configuration();
conf.set("hadoop.security.authentication", "kerberos");
conf.set("java.security.krb5.conf",krbPath);
conf.set("fs.defaultFS", "webhdfs://10.31.251.254:50070");
conf.set("fs.webhdfs.impl", org.apache.hadoop.hdfs.web.WebHdfsFileSystem.class.getName());
conf.set("com.sun.security.auth.module.Krb5LoginModule", "required");
conf.set("debug", "true");
conf.set("ticketCache", "DIR:/etc/");
System.out.print("Conf......");
UserGroupInformation.setConfiguration(conf);
UserGroupInformation.loginUserFromKeytab("Dummy@EXAMPLE.COM", keytab);
System.out.print("Obtained......");
URI uri = URI.create("webhdfs://Dummy:50070");
FileSystem fs = FileSystem.get(uri, conf);
if (fs.mkdirs(new Path("/testKerb2")))
System.out.print("Directory created...");
Run Code Online (Sandbox Code Playgroud)
我能够执行这些操作,但无法从 krb5.conf 中读取票证配置值。conf 文件中提到的票证生命周期为 1m,但代码生成了一张生命周期为 1d 的票证。而且票证也不会在配置的票证缓存中生成。
请帮助配置,以便代码从 krb5.conf 文件中读取并在配置的路径中生成票证。
在控制台 o/p 中跟随
*911 [main] DEBUG org.apache.hadoop.security.UserGroupInformation - hadoop login commit
912 [main] DEBUG org.apache.hadoop.security.UserGroupInformation - using kerberos user:hdfs/YYYY@EXAMPLE.COM
914 [main] INFO org.apache.hadoop.security.UserGroupInformation - Login successful for user …Run Code Online (Sandbox Code Playgroud) 我有一个使用 WebHDFS 管理 HDFS 的工作应用程序。我需要能够在 Kerberos 安全集群上执行此操作。
问题是,没有库或扩展来协商我的应用程序的票证,我只有一个基本的 HTTP 客户端。
是否可以创建一个 Java 服务来处理票证交换,并且一旦获得服务票证就将其传递给应用程序以在 HTTP 请求中使用?换句话说,我的应用程序会要求 Java 服务协商票证,然后它将服务票证以字符串或原始字符串形式返回给我的应用程序,而应用程序只需将其附加到 HTTP 请求?
编辑:是否有像 @SamsonScharfrichter 为 HTTPfs 描述的类似的优雅解决方案?(据我所知,它不支持委托令牌)
EDIT2:大家好,我仍然完全迷失了。我试图找出 Hadoop-auth 客户端,但没有运气。你能再帮我一下吗?我已经花了几个小时阅读它,但运气不佳。这些例子说要这样做:
* // establishing an initial connection
*
* URL url = new URL("http://foo:8080/bar");
* AuthenticatedURL.Token token = new AuthenticatedURL.Token();
* AuthenticatedURL aUrl = new AuthenticatedURL();
* HttpURLConnection conn = new AuthenticatedURL(url, token).openConnection();
* ....
* // use the 'conn' instance
* ....
Run Code Online (Sandbox Code Playgroud)
我已经在这里迷路了。我需要什么初始连接?怎么能
new AuthenticatedURL(url, token).openConnection();
Run Code Online (Sandbox Code Playgroud)
取两个参数?对于这种情况没有构造函数。(我因此而出错)。主体不应该在某个地方指定吗?这可能不会那么容易。
URL url = new URL("http://<host>:14000/webhdfs/v1/?op=liststatus");
AuthenticatedURL.Token …Run Code Online (Sandbox Code Playgroud) 是否可以使用webhdfs?检查HDFS中目录的内容?
这可以像hdfs dfs -ls通常那样工作,而是使用webhdfs.
如何webhdfs使用Python 2.6 列出目录?
有没有办法通过 webhdfs REST API 检查 HDFS 路径上是否存在某些同名文件?
我的示例网址:
http://my-sample-url:port/webhdfs/v15/tmp/mydata/sample.txt?op=CREATE&user.name=john&namenoderpcaddress=prodaddress&createflag=&createparent=true&overwrite=false
Run Code Online (Sandbox Code Playgroud)
我正在通过 HTTPClient 应用程序调用此 API。如何检查该 hdfs 路径上是否存在同名文件,以便我可以决定进一步处理?
我正在寻找单行解决方案。
我正在尝试查看删除选项是否适用于 webhdfs :
http://ec2-ab-cd-ef-hi.compute-1.amazonaws.com:14000/webhdfs/v1/user/barak/barakFile.csv?op=DELETE&user.name=hadoop
Run Code Online (Sandbox Code Playgroud)
但我收到一个错误:
{"RemoteException":{"message":"Invalid HTTP GET operation [DELETE]",
"exception":"IOException","javaClassName":"java.io.IOException"}}
Run Code Online (Sandbox Code Playgroud)
此文件拥有所有权限 (777)。
[hadoop@ip-172-99-9-99 ~]$ hadoop fs -ls hdfs:///user/someUser
Found 2 items
-rwxrwxrwx 1 hadoop hadoop 344 2015-12-10 08:33 hdfs:///user/someUser/someUser.csv
Run Code Online (Sandbox Code Playgroud)
我还应该检查什么以允许通过 Amazon EMR WEBHDFS 删除选项