Google Hadoop 的云连接器不适用于 Pig

Google Cloud connector for Hadoop doesn't work with Pig

我将 Hadoop 与 HDFS 2.7.1.2.4 和 Pig 0.15.0.2.4 (Hortonworks HDP 2.4) 一起使用,并尝试使用 Google Cloud Storage Connector for Spark and Hadoop(GitHub 上的大数据互操作)。当我尝试

时它可以正常工作
hadoop fs -ls gs://bucket-name

但是当我在 Pig 中尝试以下操作时(在 mapreduce 模式下):

data = LOAD 'gs://softline/o365.avro' USING AvroStorage();
data = STORE data INTO 'gs://softline/o366.avro' USING AvroStorage();

Pig 失败并出现以下错误:

org.apache.pig.backend.executionengine.ExecException: ERROR 2118: Wrong FS scheme: hdfs, in path: hdfs://hdp.slweb.ru:8020/user/root, expected scheme: gs
    at org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.PigInputFormat.getSplits(PigInputFormat.java:279)
    at org.apache.hadoop.mapreduce.JobSubmitter.writeNewSplits(JobSubmitter.java:301)
    at org.apache.hadoop.mapreduce.JobSubmitter.writeSplits(JobSubmitter.java:318)
    at org.apache.hadoop.mapreduce.JobSubmitter.submitJobInternal(JobSubmitter.java:196)
    at org.apache.hadoop.mapreduce.Job.run(Job.java:1290)
    at org.apache.hadoop.mapreduce.Job.run(Job.java:1287)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAs(Subject.java:422)
    at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1657)
    at org.apache.hadoop.mapreduce.Job.submit(Job.java:1287)
    at org.apache.hadoop.mapreduce.lib.jobcontrol.ControlledJob.submit(ControlledJob.java:335)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.apache.pig.backend.hadoop23.PigJobControl.submit(PigJobControl.java:128)
    at org.apache.pig.backend.hadoop23.PigJobControl.run(PigJobControl.java:194)
    at java.lang.Thread.run(Thread.java:745)
    at org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.MapReduceLauncher.run(MapReduceLauncher.java:276)
Caused by: java.lang.IllegalArgumentException: Wrong FS scheme: hdfs, in path: hdfs://hdp.slweb.ru:8020/user/root, expected scheme: gs
    at com.google.cloud.hadoop.fs.gcs.GoogleHadoopFileSystemBase.checkPath(GoogleHadoopFileSystemBase.java:741)
    at com.google.cloud.hadoop.fs.gcs.GoogleHadoopFileSystem.checkPath(GoogleHadoopFileSystem.java:90)
    at org.apache.hadoop.fs.FileSystem.makeQualified(FileSystem.java:466)
    at com.google.cloud.hadoop.fs.gcs.GoogleHadoopFileSystemBase.makeQualified(GoogleHadoopFileSystemBase.java:701)
    at com.google.cloud.hadoop.fs.gcs.GoogleHadoopFileSystem.getGcsPath(GoogleHadoopFileSystem.java:163)
    at com.google.cloud.hadoop.fs.gcs.GoogleHadoopFileSystemBase.setWorkingDirectory(GoogleHadoopFileSystemBase.java:1094)
    at org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.PigInputFormat.getSplits(PigInputFormat.java:235)
    ... 18 more

如果需要,我可以post GC 连接器的日志。

有人用这个连接器使用 Pig 吗?如有任何帮助,我们将不胜感激。

TL;DR 在启动 pig 作业时显式设置 workmapreduce.job.working.dir=/user/root/

如果在作业提交期间未明确设置工作目录,则Hadoop 会将工作目录设置为默认文件系统的工作目录。当使用 HDFS 作为默认 FS 时,工作目录通常类似于 'hdfs://namenode:port/user/<your username>'。

调用 PigInputFormat#getSplits 时,它会获取与其正在操作的输入路径关联的文件系统。在这种情况下,文件系统是 GoogleHadoopFileSystem 的一个实例。 Pig 然后检查其输入的路径,如果路径是非本地的,则调用 FileSystem#setWorkingDirectory(job.getWorkingDirectory())。这里的问题是作业的工作目录是 'hdfs://namenode:port/user/<your username>',GoogleHadoopFileSystem 将拒绝将其作为设置为自己的工作目录的路径(因为它只支持 'gs://' 路径)。