【问题标题】:using amazon s3 as input,output and to store intermediate results in EMR map reduce job使用 amazon s3 作为输入、输出并将中间结果存储在 EMR map reduce 作业中
【发布时间】:2013-04-25 15:48:47
【问题描述】:

我正在尝试将 Amazon s3 存储与 EMR 结合使用。但是,当我当前运行我的代码时,我会遇到多个错误,例如

java.lang.IllegalArgumentException: This file system object (hdfs://10.254.37.109:9000)    does not support access to the request path 's3n://energydata/input/centers_200_10k_norm.csv' You possibly called FileSystem.get(conf) when you should have called FileSystem.get(uri, conf) to obtain a file system supporting your path.
at org.apache.hadoop.fs.FileSystem.checkPath(FileSystem.java:384)
at org.apache.hadoop.hdfs.DistributedFileSystem.getPathName(DistributedFileSystem.java:129)
at org.apache.hadoop.hdfs.DistributedFileSystem.open(DistributedFileSystem.java:154)
at org.apache.hadoop.fs.FileSystem.open(FileSystem.java:429)
at edu.stanford.cs246.hw2.KMeans$CentroidMapper.setup(KMeans.java:112)
at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:142)
at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:771)
at org.apache.hadoop.mapred.MapTask.run(MapTask.java:375)
at org.apache.hadoop.mapred.Child$4.run(Child.java:255)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:396)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1132)
at org.apache.hadoop.mapred.Child.main(Child.java:249)

在 main 中,我像这样设置我的输入和输出路径,并将 s3n://energydata/input/centers_200_10k_norm.csv 放入我在映射器和减速器中检索的配置 CFILE 中:

FileSystem fs = FileSystem.get(conf);
conf.set(CFILE, inPath); //inPath in this case is s3n://energydata/input/centers_200_10k_norm.csv
FileInputFormat.addInputPath(job, new Path(inputDir));
FileOutputFormat.setOutputPath(job, new Path(outputDir));

在我尝试访问 CFILE (s3n://energydata/input/centers_200_10k_norm.csv) 的映射器和减速器中发生上述错误的具体示例。这就是我尝试获取路径的方式:

FileSystem fs = FileSystem.get(context.getConfiguration());
Path cFile = new Path(context.getConfiguration().get(CFILE));
DataInputStream d = new DataInputStream(fs.open(cFile));  ---->Error

s3n://energydata/input/centers_200_10k_norm.csv 是程序的输入参数之一,当我启动 EMR 作业时,我将输入和输出目录指定为 s3n://energydata/input 和 s3n:/ /能源数据/输出

我尝试按照file path in hdfs 中的建议进行操作,但仍然出现错误。任何帮助将不胜感激。

谢谢!

【问题讨论】:

    标签: hadoop amazon-web-services amazon-s3 mapreduce amazon-emr


    【解决方案1】:

    试试吧:

    Path cFile = new Path(context.getConfiguration().get(CFILE));
    FileSystem fs = cFile.getFileSystem(context.getConfiguration());
    DataInputStream d = new DataInputStream(fs.open(cFile));
    

    【讨论】:

    • 谢谢。我实际上使用以下代码修复了它:uriStr = "s3n://energydata/output/"; URI uri = URI.create(uriStr);文件系统 fs = FileSystem.get(uri, context.getConfiguration());路径 cFile = new Path(context.getConfiguration().get(CFILE));DataInputStream d = new DataInputStream(fs.open(cFile));
    • 是的 - 这也是一个类似的修复。最主要的是在 OP 中,文件系统句柄是默认句柄。 Path.getFileSystem 或 FileSystem.get(path, conf) 获取特定路径的文件系统
    【解决方案2】:

    谢谢。我实际上使用以下代码修复了它:

    String uriStr =  "s3n://energydata/centroid/";
    URI uri = URI.create(uriStr);
    FileSystem fs = FileSystem.get(uri, context.getConfiguration());    
    Path cFile = new Path(context.getConfiguration().get(CFILE));  
    DataInputStream d = new DataInputStream(fs.open(cFile));
    

    【讨论】:

      猜你喜欢
      • 2023-04-01
      • 2016-07-30
      • 2016-10-15
      • 1970-01-01
      • 1970-01-01
      • 2011-05-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多