hbase:minidfscluster.java在某些环境中失败

c8ib6hqw  于 2021-06-03  发布在  Hadoop
关注(0)|答案(1)|浏览(287)

我正在编写一些代码来访问hbase,并且正在编写单元测试来创建一个minidfscluster作为测试设置的一部分。

(defn test-config [& options]
    (let [testing-utility (HBaseTestingUtility.)]
        (.startMiniCluster testing-utility 1)
        (let [config (.getConfiguration testing-utility)]
            (if (not= options nil)
                (doseq [[key value] options]
                    (.set config key value)))
            config)))

;; For those who don't read Clojure, lines 2 and 3 cause 
;; the failure and are equivalent to the following Java
;; 
;; HBaseTestingUtility testingUtility = new HBaseTestingUtility();
;; testingUtility.startMiniCluster(1);  // blows up on Linux but not Mac OSX

这在带有java hotspot的mac osx上运行良好:

$ java -version
java version "1.6.0_51"
Java(TM) SE Runtime Environment (build 1.6.0_51-b11-457-11M4509)
Java HotSpot(TM) 64-Bit Server VM (build 20.51-b01-457, mixed mode)

$ lein test

lein test hbase.config-test

lein test hbase.table-test
2013-07-12 17:44:13.488 java[27384:1203] Unable to load realm info from SCDynamicStore
Starting DataNode 0 with dfs.data.dir: /Users/dwilliams/Desktop/Repos/mobiusinversion/hbase/target/test-data/fe0199fd-0168-48d9-98ce-b4a5e62d3257/dfscluster_bbad1095-58d1-4571-ba12-4d4f1c24203f/dfs/data/data1,/Users/dwilliams/Desktop/Repos/mobiusinversion/hbase/target/test-data/fe0199fd-0168-48d9-98ce-b4a5e62d3257/dfscluster_bbad1095-58d1-4571-ba12-4d4f1c24203f/dfs/data/data2
Cluster is active

Ran 11 tests containing 14 assertions.
0 failures, 0 errors.

但在linux环境中运行时,会出现以下错误:

ERROR in (create-table) (MiniDFSCluster.java:426)
Uncaught exception, not in assertion.
expected: nil
  actual: java.lang.NullPointerException: null
 at org.apache.hadoop.hdfs.MiniDFSCluster.startDataNodes (MiniDFSCluster.java:426)
    org.apache.hadoop.hdfs.MiniDFSCluster.<init> (MiniDFSCluster.java:284)
    org.apache.hadoop.hbase.HBaseTestingUtility.startMiniDFSCluster (HBaseTestingUtility.java:444)
    org.apache.hadoop.hbase.HBaseTestingUtility.startMiniCluster (HBaseTestingUtility.java:612)
    org.apache.hadoop.hbase.HBaseTestingUtility.startMiniCluster (HBaseTestingUtility.java:568)
    org.apache.hadoop.hbase.HBaseTestingUtility.startMiniCluster (HBaseTestingUtility.java:555)

我提交了travis ci的罚单,因为这第一次出现在那里,我认为这可能是由于他们的环境。
https://github.com/travis-ci/travis-ci/issues/1240
然而,在与travis支持人员讨论之后,我能够在centos上重现这个错误。我在linux上尝试了sunjdk和openjdk,但都产生了相同的错误。这是怎么回事?这是一个微不足道的配置问题吗?也许是在macosx的env中设置的linux env中没有设置的东西?
如果要运行测试,请克隆repo
https://github.com/mobiusinversion/hbase
然后做莱恩测试。非常感谢您的帮助!
更新:
提交了这张hbase jira罚单
https://issues.apache.org/jira/browse/hbase-8944

ilmyapht

ilmyapht1#

简而言之:设置“ umask 022 “在运行测试之前。
长话短说:从hadoop1.x版本运行minidfscluster是一个常见的环境问题,hbasetestinguility在内部使用它。它已经在hadoop0.22+(包括2.0+,但目前不是1.x)中得到了有效的修复。
根本问题是https://issues.apache.org/jira/browse/hdfs-2556.
当minidfscluster启动时,它将创建用于datanode进程的临时存储目录(配置为“dfs.data.dir”)。这些将使用当前设置的umask创建。当每个datanode启动时,它检查“dfs.data.dir”中配置的目录是否都存在,以及目录权限是否与预期值匹配(设置为“dfs.datanode.data.dir.perm”)。如果目录权限与预期值不匹配(默认为“755”),则datanode进程退出。
默认情况下,在hadoop1.x中,该值设置为“755”,因此如果将umask设置为“022”,数据目录将具有正确的权限。但是,如果权限与预期值不匹配,datanode将中止,并且您将在测试日志文件中看到如下错误:

WARN  [main] datanode.DataNode(1577): Invalid directory in dfs.data.dir: Incorrect permission for /.../dfs/data/data2, expected: rwxr-xr-x, while actual: rwxrwxr-x

在hadoop的更高版本中,如果目录权限不匹配,datanode将尝试将其更改为预期值。只有当此操作失败时,datanode才会中止。hdfs-2556建议将此更改向后移植到1.x版本,但尚未修复。

相关问题