2011-12-06 7 views
0

私はhadoopでテストしようとしています。コードは次のようになります。 System.setProperty( "test.build.data"、 "/ folder"); config = new Configuration(); クラスタ=新しいMiniDFSCluster(config、1、true、null);MiniDFSClusterはioexceptionを返します

が、新しいMiniDFSCluster(設定、1、trueの場合、ヌル)で、それは例外をスロー:

java.io.IOException: Cannot run program "du": CreateProcess error=2, The system cannot find the file specified. 
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:470) 
    at org.apache.hadoop.util.Shell.runCommand(Shell.java:149) 
    at org.apache.hadoop.util.Shell.run(Shell.java:134) 
    at org.apache.hadoop.fs.DU.<init>(DU.java:53) 
    at org.apache.hadoop.fs.DU.<init>(DU.java:63) 
    at org.apache.hadoop.hdfs.server.datanode.FSDataset$FSVolume.<init>(FSDataset.java:333) 
    at org.apache.hadoop.hdfs.server.datanode.FSDataset.<init>(FSDataset.java:689) 
    at org.apache.hadoop.hdfs.server.datanode.DataNode.startDataNode(DataNode.java:302) 
    at org.apache.hadoop.hdfs.server.datanode.DataNode.<init>(DataNode.java:216) 
    at org.apache.hadoop.hdfs.server.datanode.DataNode.makeInstance(DataNode.java:1283) 
    at org.apache.hadoop.hdfs.server.datanode.DataNode.instantiateDataNode(DataNode.java:1238) 
    at org.apache.hadoop.hdfs.MiniDFSCluster.startDataNodes(MiniDFSCluster.java:417) 
    at org.apache.hadoop.hdfs.MiniDFSCluster.<init>(MiniDFSCluster.java:280) 
    at org.apache.hadoop.hdfs.MiniDFSCluster.<init>(MiniDFSCluster.java:124) 
    at ebay.Crawler.TestAll.testinit(TestAll.java:53) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37) 
    at java.lang.reflect.Method.invoke(Method.java:599) 
    at junit.framework.TestCase.runTest(TestCase.java:168) 
    at junit.framework.TestCase.runBare(TestCase.java:134) 
    at junit.framework.TestResult$1.protect(TestResult.java:110) 
    at junit.framework.TestResult.runProtected(TestResult.java:128) 
    at junit.framework.TestResult.run(TestResult.java:113) 
    at junit.framework.TestCase.run(TestCase.java:124) 
    at junit.framework.TestSuite.runTest(TestSuite.java:232) 
    at junit.framework.TestSuite.run(TestSuite.java:227) 
    at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:81) 
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49) 
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) 
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) 
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) 
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) 
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) 
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified. 
    at java.lang.ProcessImpl.<init>(ProcessImpl.java:92) 
    at java.lang.ProcessImpl.start(ProcessImpl.java:41) 
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:463) 
    ... 33 more 

は、誰かが私にこれを解決する方法をいくつかのヒントを与えてくださいませんか? ありがとうございます。

答えて

1

duコマンドがシステムに存在しないか、PATHに存在しないように見えます。 WindowsでHadoopを使用している場合は、Cygwinをインストールする必要があります。とにかくwhich duは、duバイナリの場所を示します。

+0

ありがとうございました。 cygwinが適切ではないからです^^ –

0

あなたはHadoopのClouderaディストリビューションを使用していると思われます。バージョン1.0.0の 'vanilla' HadoopはWindows上で動作します - 少なくともファイルの作成と書き込みは行います。

ローカルWindows環境で単体テストを実行する必要がある場合は、Mavenプロファイルプロパティを使用してローカルMaven設定の1.0.0を設定し、POMに 'remote'設定を指定してみてください。グローバル設定は、POM固有の設定を上書きします。

のsettings.xml

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> 
    <profiles> 
    <profile> 
     <id>windows</id> 
      <properties> 
      <hadoop.version>1.0.0</hadoop.version> 
      </properties> 
    </profile> 
    </profiles> 
    <activeProfiles> 
    <activeProfile>windows</activeProfile> 
    </activeProfiles> 
</settings> 

のpom.xml

<properties> 
    <hadoop.version>0.20.2-cdh3u2</hadoop.version> 
</properties> 

<dependency> 
    <groupId>org.apache.hadoop</groupId> 
    <artifactId>hadoop-core</artifactId> 
    <version>${hadoop.version}</version> 
</dependency> 
関連する問題