如何使用Pig访问远程机器上的HDFS?

时间:2013-02-14 08:46:10

标签: hadoop apache-pig hdfs

远程计算机上安装了Hadoop(example.host.com)。猪也安装在那台机器上。

如何从其他计算机访问该计算机上的hdfs?

我不想从远程复制文件。我只想对那些以avro格式存储的文件运行查询。

我在本地计算机上安装了Pig,并将以下行添加到pig.properties文件

fs.default.name=hdfs://example.host.com:8020
mapred.job.tracker=example.host.com:8021

但是当我开始生猪时它会出现以下错误

2013-02-15 12:35:26,534 [main] INFO  org.apache.pig.Main - Apache Pig version 0.10.1-SNAPSHOT (rexported) compiled Feb 14 2013, 17:55:12
2013-02-15 12:35:26,535 [main] INFO  org.apache.pig.Main - Logging error messages to: /log/path/pig_1360911926530.log
2013-02-15 12:35:26,818 [main] INFO  org.apache.pig.backend.hadoop.executionengine.HExecutionEngine - Connecting to hadoop file system at: hdfs://example.host.com:8020
2013-02-15 12:35:26.907 java[2346:1c03] Unable to load realm info from SCDynamicStore
2013-02-15 12:35:27,574 [main] ERROR org.apache.pig.Main - ERROR 2999: Unexpected internal error. Failed to create DataStorage
Details at logfile: /log/path/pig_1360911926530.log

在日志文件的内容中“/log/path/pig_1360911926530.log”是

Error before Pig is launched
----------------------------
ERROR 2999: Unexpected internal error. Failed to create DataStorage

java.lang.RuntimeException: Failed to create DataStorage
        at org.apache.pig.backend.hadoop.datastorage.HDataStorage.init(HDataStorage.java:75)
        at org.apache.pig.backend.hadoop.datastorage.HDataStorage.<init>(HDataStorage.java:58)
        at org.apache.pig.backend.hadoop.executionengine.HExecutionEngine.init(HExecutionEngine.java:205)
        at org.apache.pig.backend.hadoop.executionengine.HExecutionEngine.init(HExecutionEngine.java:118)
        at org.apache.pig.impl.PigContext.connect(PigContext.java:208)
        at org.apache.pig.PigServer.<init>(PigServer.java:246)
        at org.apache.pig.PigServer.<init>(PigServer.java:231)
        at org.apache.pig.tools.grunt.Grunt.<init>(Grunt.java:47)
        at org.apache.pig.Main.run(Main.java:487)
        at org.apache.pig.Main.main(Main.java:111)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:601)
        at org.apache.hadoop.util.RunJar.main(RunJar.java:156)
Caused by: org.apache.hadoop.ipc.RPC$VersionMismatch: Protocol org.apache.hadoop.hdfs.protocol.ClientProtocol version mismatch. (client = 61, server = 63)
        at org.apache.hadoop.ipc.RPC.getProxy(RPC.java:401)
        at org.apache.hadoop.ipc.RPC.getProxy(RPC.java:379)
        at org.apache.hadoop.hdfs.DFSClient.createRPCNamenode(DFSClient.java:119)
        at org.apache.hadoop.hdfs.DFSClient.<init>(DFSClient.java:238)
        at org.apache.hadoop.hdfs.DFSClient.<init>(DFSClient.java:203)
        at org.apache.hadoop.hdfs.DistributedFileSystem.initialize(DistributedFileSystem.java:89)
        at org.apache.hadoop.fs.FileSystem.createFileSystem(FileSystem.java:1386)
        at org.apache.hadoop.fs.FileSystem.access$200(FileSystem.java:66)
        at org.apache.hadoop.fs.FileSystem$Cache.get(FileSystem.java:1404)
        at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:254)
        at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:123)
        at org.apache.pig.backend.hadoop.datastorage.HDataStorage.init(HDataStorage.java:72)
        ... 14 more
================================================================================

2 个答案:

答案 0 :(得分:1)

正如您所看到的,您获得的异常是版本不匹配。你确定XXX有$ HADOOP_HOME init的类路径吗?它真的看起来像是指向错误的罐子。

答案 1 :(得分:0)

在本地计算机上解压缩Hadoop tar文件,然后将配置文件指向群集中的NameNode,然后使用hadoop fs -get命令将文件从远程计算机获取到本地计算机。