gpt4 book ai didi

hadoop - 如何使用与客户端进程不同的所有者创建 HDFS 文件

转载 作者:可可西里 更新时间:2023-11-01 14:50:21 25 4
gpt4 key购买 nike

HDFS Administrator Guide

"When a file or directory is created, its owner is the user identity of the client process, and its group is the group of the parent directory (the BSD rule)."

此规则有任何异常(exception)吗?以用户“clientA”身份运行进程是否有任何方法可以创建具有不同所有者的文件?

我正在使用 hadoop.security.authentication=simple 运行。看来我可以调用setOwner事后,这是一个完全有效的后备解决方案。

最佳答案

它看起来很正常吗??

public static void main(String[] args) throws IOException, URISyntaxException, InterruptedException {
// TODO Auto-generated method stub

Configuration conf = new Configuration();
conf.addResource(new Path("/hadoop/projects/hadoop-1.0.4/conf/core-site.xml"));
conf.addResource(new Path("/hadoop/projects/hadoop-1.0.4/conf/hdfs-site.xml"));
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter the directory URI...");
String dirPath = br.readLine();
URI uri = new URI(dirPath);
System.out.println("Enter the user...");
String user = br.readLine();
FileSystem fs = FileSystem.get(uri, conf, user);
fs.mkdirs(new Path(uri.toString()), FsPermission.getDefault());
FSDataOutputStream fsDataOutputStream = fs.create(new Path(uri.toString()+"/file.txt"));
fsDataOutputStream.writeBytes("This is a demo file..!!!!");
}

关于hadoop - 如何使用与客户端进程不同的所有者创建 HDFS 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17091621/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com