在Windows 7上没有Hadoop的猪

我试图在Windows 7机器上运行PigUnittesting,然后在Ubuntu集群上运行实际的pig脚本,然后开始认为我对“ withouthadoop ”的理解不正确。

我是否需要安装Hadoop才能在Windows 7机器上本地运行PigUnittesting?

我安装了:

  1. 日食朱诺和ant
  2. cygwin的

我成立了:

  1. JAVA_HOME=C:\Program Files\Java\jdk1.6.0_39
  2. PIG_HOME=C:\Users\john.doe\Java\eclipse\pig
  3. PIG_CLASSPATH=%PIG_HOME%\bin

我使用eclipse的Ant构build器jar-allpigunit-jar

  1. pig.jar
  2. pig-withouthadoop.jar
  3. pigunit.jar

当我在cygwin中inputpig -x local ,我得到:

 $./pig -x local cygpath: can't convert empty path Exception in thread "main" java.io.IOException: Error opening job jar: /usr/lib/pig/pig-withouthadoop.jar at org.apache.hadoop.util.RunJar.main(RunJar.java:135) Caused by: java.io.FileNotFoundException: \usr\lib\pig\pig-withouthadoop.jar (the systen cannot find the given path) at java.util.zip.ZipFile.open(Native Method) at java.util.zip.ZipFile.<init>(ZipFile.java:127) at java.util.jar.JarFile.<init>(JarFile.java:136) at java.util.jar.JarFile.<init>(JarFile.java:73) at org.apache.hadoop.util.RunJar.main(RunJar.java:133) 

当我尝试使用选项“ Run as JUnit ”从eclipse中的http://pig.apache.org/docs/r0.10.0/test.html#pigunit运行testing时,我得到:

 java.io.IOException at org.apache.pig.pigunit.pig.PigServer.registerScript(PigServer.java:62) at org.apache.pig.pigunit.PigTest.registerScript(PigTest.java:171) at org.apache.pig.pigunit.PigTest.assertOutput(PigTest.java:267) at org.apache.pig.pigunit.PigTest.assertOutput(PigTest.java:262) at da.utils.pigunit.PigUnitExample.testTop2Queries(PigUnitExample.java:72) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) at org.junit.runners.ParentRunner.run(ParentRunner.java:309) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) 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) 

我开始认为我错过了一些在Windows上运行Pig的关键基本信息,我不得不说,我没有经验的Windows 7和Cygwin用户,我来自Unix世界。

和你一样,我正在尝试使用cygwin在Windows PC上运行Pig安装,以便在单个JVM上使用小数据集学习Pig Latin。 不是一个巨大的问题,你会想到,但痛苦几乎无法忍受。 我来自Windows背景,UNIX部分对我来说是陡峭的学习曲线。 pig-withouthadoop jar不包含hadoop,所以hadoop需要在您的机器上安装使用它; pig.jar包含猪自己的hadoop版本,如果hadoop还没有安装在你的机器上,也可以使用。 这是我理解它的方式,似乎是通过将每个.jar的内容列表转储到文本文件并在Notepad ++中查看结果而诞生的。

当你在Cygwin的美元提示符下键入pig -x local,bash命令脚本“pig”被调用并运行。 用$ cd bin $ cat pig来看看它(从你的PIG_HOME)。 过去几天我已经用vim(!)解决了这个问题,接近代码的末尾是cygwin用户的一个小叉子,为了将环境变量直到现在都变成Unix格式,变成了一个表示Windows版本的java.exe将在脚本的末尾调用“exec java …”时明白。 没有这个转换,Windows java.exe将不能理解它的参数:

'#'cygwin路径翻译
如果$ cygwin; 那么CLASSPATH = cygpath -p -w "$CLASSPATH" PIG_HOME = cygpath -d "£PIG_HOME" PIG_LOG_DIR = cygpath -d "$PIG_LOG_DIR" fi

Cygpath是一个将UNIX风格的文件路径转换成Windows风格的文件路径的cygwin工具,反之亦然。 错误消息:“cygpath:无法转换空路径”必须来自这里,我认为。 检查CLASSPATH,PIG_HOME和PIG_LOG_DIR是否为空,可能是将自己的回显命令放在脚本中。

在我的机器和安装上,这里产生了一个错误,但与您的不一样。 我发现用-m替换-w和-d,这使得cygpath使用C:/ Program Files / Java …语法转换工作。 但其他问题出现了,我将留给我自己的问题。

不要反抗 从Web Platform安装程序在Windows上安装Hadoop HDInsight服务器: http : //www.microsoft.com/web/downloads/platform.aspx

它不需要很长的时间,也不占用太多的空间,而且整个制作都是为你而设的。 我不能拿猪脚参数,并没有HBase,但你得到HDFS,猪,蜂巢。 你甚至可以得到一个完整的本地集群,如果只是遵循:: http://social.msdn.microsoft.com/Forums/en-US/hdinsight/thread/885efc22-fb67-4df8-8648-4ff38098dac6/

我已经安装猪0.12在cygwin(我运行Windows 7的64位),而不安装hadoop。 据我所知,我所遵循的步骤是:

  • 安装Cygwin64(使用Perl包)

  • 下载pig-0.12.1.tar.gz,复制到home文件夹

  • 在cygwin中提取到主文件夹:

    $ tar xzf pig-0.12.1.tar.gz

  • 导出JAVA_HOME:

    $ export JAVA_HOME = / cygdrive / c / Program \ Files / Java / jre6 /

  • 添加猪到路径:

    $ export PATH =〜/ pig-0.12.1 / bin /:$ PATH

  • 将pig-0.12.1.jar重命名为pig.jar:

    $ cp pig-0.12.1.jar pig.jar

  • 导出PIG_CLASSPATH:

    $ export PIG_CLASSPATH =〜/ pig-0.12.1 / pig.jar

  • 以本地模式运行猪(启动Grunt):

    $ pig -x local

  • 会出现一个警告:“cygpath:不能创建C:\ cygwin64 \ home \ xxx \ pig-0.12.1 \ logs的简称”我们可以简单地通过运行:

    $ mkdir日志

根据这个注释[1] ,直接使用Cygwin在Windows 7上不可能使用Hadoop本地库:

Hadoop本地库仅在* nix平台上受支持。 不幸的是,不知道Cygwin的工作[

我跟踪了错误消息cygpath: can't convert empty path为行JAVA_LIBRARY_PATH=cygpath -w "$JAVA_LIBRARY_PATH"的行JAVA_LIBRARY_PATH=cygpath -w "$JAVA_LIBRARY_PATH" ,我注意到[2]

 Comment some translation in hadoop-config.sh. #if $cygwin; then #HADOOP_PREFIX=`cygpath -w "$HADOOP_PREFIX"` #HADOOP_LOG_DIR=`cygpath -w "$HADOOP_LOG_DIR"` #JAVA_LIBRARY_PATH=`cygpath -w "$JAVA_LIBRARY_PATH"` #fi 

现在我得到以下错误:

 Error before Pig is launched -- ERROR 2999: Unexpected internal error. java.lang.UnsupportedOperationException: Not implemented by the DistributedFileSystem FileSystem implementation 

所以我从中得出的结论是,即使在本地模式下,Pig也需要HDFS。 HDFS需要Hadoop本地库。 而本地库已知不在Cygwin上工作。 因此:恕我直言,猪不能运行Cygwin,因为它是。

在Windows 7上运行PigUnit。 我不安装Cygwin。 感谢康斯坦丁Kudryavtsev我使用他的FixHadoopOnWindows.runFix() http://simpletoad.blogspot.com/2013/05/pigunit-issue-on-windows.html我在我的setUp调用runFix,例&#x5982;

 private static PigTest test; @BeforeClass public static void setUp() throws IOException, ParseException { try { FixHadoopOnWindows.runFix(); // TODO: load pig script properly test = new PigTest("src/pig/example.pig"); //test.override(...); } catch (Exception e) { } } 

使用maven,需要以下依赖项

  <dependency> <groupId>org.apache.hadoop</groupId> <artifactId>hadoop-core</artifactId> <version>1.2.1</version> <scope>test</scope> </dependency> <dependency> <groupId>org.apache.pig</groupId> <artifactId>pig</artifactId> <version>0.15.0</version> </dependency> <dependency> <groupId>org.jboss.forge</groupId> <artifactId>forge-javassist</artifactId> <version>2</version> </dependency> <dependency> <groupId>org.apache.pig</groupId> <artifactId>pigunit</artifactId> <version>0.15.0</version> <scope>test</scope> </dependency>