gpt4 book ai didi

linux - 克服 HDFS-2556 : unit tests directory and permissions

转载 作者:可可西里 更新时间:2023-11-01 16:18:35 25 4
gpt4 key购买 nike

我正在尝试在 hadoop 上进行 JUnit 测试,我使用 MiniDFSCluster、MiniMRCluster 和 JUnit 编写了一个在本地 mini-hadoop 环境中运行的测试用例。

但是我收到了这个错误:

 WARNING: Metrics system not started: Cannot locate configuration: tried hadoop-metrics2-datanode.properties, hadoop-metrics2.properties
Dec 18, 2012 4:42:29 PM org.apache.hadoop.hdfs.server.datanode.DataNode makeInstance
WARNING: Invalid directory in dfs.data.dir: Incorrect permission for build/test/data/dfs/data/data1, expected: rwxr-xr-x, while actual: rwxrwxr-x
Dec 18, 2012 4:42:29 PM org.apache.hadoop.hdfs.server.datanode.DataNode makeInstance
WARNING: Invalid directory in dfs.data.dir: Incorrect permission for build/test/data/dfs/data/data2, expected: rwxr-xr-x, while actual: rwxrwxr-x
Dec 18, 2012 4:42:29 PM org.apache.hadoop.hdfs.server.datanode.DataNode makeInstance
SEVERE: All directories in dfs.data.dir are invalid.

这看起来像 HDFS 错误 https://issues.apache.org/jira/browse/HDFS-2556这仍然悬而未决。

由于我无法更改我正在使用的 hadoop 版本,是否有办法强制 hadoop 接受这些权限?

我试过:System.setProperty("dfs.datanode.data.dir.perm", "775");但是 hadoop 会忽略它们。

此外,我无法手动更改权限,似乎迷你集群每次运行都会重新创建它们。

有没有办法在不修改 hadoop 或更改版本的情况下克服这个问题?谢谢。

最佳答案

您可以使用此处提供的解决方法, https://www.mail-archive.com/issues@hbase.apache.org/msg52961.html

更新:链接中的代码片段(以防链接断开)

    try {
Process process = Runtime.getRuntime().exec("/bin/sh -c umask");
BufferedReader br = new BufferedReader(new
InputStreamReader(process.getInputStream()));
int rc = process.waitFor();
if (rc == 0) {
String umask = br.readLine();

int umaskBits = Integer.parseInt(umask, 8);
int permBits = 0777 & ~umaskBits;
String perms = Integer.toString(permBits, 8);

log.info("Setting dfs.datanode.data.dir.perm to " + perms);
hBaseTestingUtility.getConfiguration().set("dfs.datanode.data.dir.perm", perms);
} else {
log.warn("Failed running umask command in a shell, nonzero return value ");
}
} catch (Exception e) {
// ignore errors, we might not be running on POSIX, or "sh" might not be on the path
log.warn("Couldn't get umask", e);
}

关于linux - 克服 HDFS-2556 : unit tests directory and permissions,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13936364/

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