windows上传文件到虚拟机的hdfs上

Connie ·
更新时间:2024-09-21
· 942 次阅读

org.apache.hadoop.security.AccessControlException: Permission denied: user=ASUS, access=WRITE, inode
今天在windows连接虚拟机的hdfs,通过IDEA上传文件到虚拟机的hdfs上,出现了权限不足问题,原因是以windows的用户上传文件,所以出错,原代码如下:

package cn.edu.lingnan.hdfsclient; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.fs.FileSystem; import org.apache.hadoop.fs.Path; import org.junit.Test; import java.io.IOException; import java.net.URI; public class HDFSClient { @Test public void put() throws IOException { FileSystem fileSystem = FileSystem.get(URI.create("hdfs://192.168.218.130:9000"),new Configuration()); fileSystem.copyFromLocalFile(new Path("D:\\1.txt"),new Path("/")); fileSystem.close(); } }

后来加了一句以虚拟机的用户上传文件:

System.setProperty("hadoop","user");

运行还是出错,经过上网搜索发现是要在hadoop的hdfs-site.xml配置文件加上用户才行:

dfs.permissions false

然后代码就能顺利执行,文件也能成功上传了。
在这里插入图片描述


作者:情深不仅李义山



hdfs windows 虚拟机

需要 登录 后方可回复, 如果你还没有账号请 注册新账号