如何使用c#验证WebHDFS [英] How to Authenticate WebHDFS with c#

查看:484
本文介绍了如何使用c#验证WebHDFS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试使用WebHDFS REST API将使用c#的文件上传到Hadoop。
此代码正常工作:

  
使用(var client = new System.Net.WebClient())
{
string result = client.DownloadString(http:// host:50070 / webhdfs / v1 / user / myuser /?op = LISTSTATUS);
client.DownloadFile(http:/ /host:50070/webhdfs/v1/user/myuser/tbible.txt?user.name=myuser&op=OPEN\",\"d:\tbible.txt) ;
}



此代码得到403 Forbidden:

 使用(var client = new System.Net.WebClient())
{

client.UploadFile(http:/ / host:50070 / webhdfs / v1 /user/myuser/?user.name=myuser&op=CREATE,PUT,d:\ bible.txt);
}



我尝试添加网络凭证,没有运气。
如何从.NET对我们的集群进行身份验证? Cluster是RHEL5上的Hortonworks HDP1.3。
(这篇文章中的额外空格是为了防止http://被链接)
另外,我希望使用微软的hadoop SDK,但它是alpha,并且不会在我的环境中编译: (

解决方案

确保您正在写入WebHDFS运行组下的目录。默认情况下,这是hdfs 。

快速检查目录的父目录中的 hadoop fs -ls 以获取组权限设置(可能看起来像用户名的第二列)。


I have been attempting to upload files using c# into Hadoop using the WebHDFS REST API. This code works fine:


    using (var client = new System.Net.WebClient())
    {
       string result = client.DownloadString("http:/ /host:50070/webhdfs/v1/user/myuser/?op=LISTSTATUS");
       client.DownloadFile("http:/ /host:50070/webhdfs/v1/user/myuser/tbible.txt?user.name=myuser&op=OPEN","d:\tbible.txt");
    }


This code gets a 403 Forbidden:


    using (var client = new System.Net.WebClient())
    {
client.UploadFile("http:/ /host:50070/webhdfs/v1/user/myuser/?user.name=myuser&op=CREATE", "PUT", "d:\bible.txt"); }


I have tried adding a network credential, with no luck. How do I authenticate to our Cluster from .NET? The Cluster is Hortonworks HDP1.3 on RHEL5. (The extra spaces in this post are to keep http:/ / from being a link) Also, I would have liked to use Microsoft's hadoop SDK, but it is alpha and wont compile in my environment :(

解决方案

Make sure that you are writing to a directory that is under the group which WebHDFS operates under. By default this is hdfs.

A quick way to check this doing hadoop fs -ls on the directory's parent directory to get the group permission settings (the second column that may look like a username).

这篇关于如何使用c#验证WebHDFS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆