我怎样才能从本地的Hadoop 2.6的安装进入S3 / S3N? [英] How can I access S3/S3n from a local Hadoop 2.6 installation?

查看:577
本文介绍了我怎样才能从本地的Hadoop 2.6的安装进入S3 / S3N?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图重现一个Amazon EMR集群上我的本地机器。为此,我已经安装的Hadoop的最新的稳定版本的现在 - 2.6.0 。 现在我想访问的S3存储,因为我做的EMR集群内。

我已经在核心site.xml中添加的AWS凭据:

 <性>
  <名称>&fs.s3.awsAccessKeyId LT; /名称>
  <价值>有的ID< /值GT;
< /性>

<性>
  <名称>&fs.s3n.awsAccessKeyId LT; /名称>
  <价值>有的ID< /值GT;
< /性>

<性>
  <名称>&fs.s3.awsSecretAccessKey LT; /名称>
  <价值>一些重点和LT; /值GT;
< /性>

<性>
  <名称>&fs.s3n.awsSecretAccessKey LT; /名称>
  <价值>一些重点和LT; /值GT;
< /性>
 

注:由于有对一些关键斜线,我逃脱了他们%2F

如果我尝试列出桶的内容:

  Hadoop的FS -ls S3://一些-URL /桶/
 

我得到这个错误:

LS:没有文件系统方案:S3

我再次编辑核心的site.xml,并添加相关的FS信息:

 <性>
  <名称>&fs.s3.impl LT; /名称>
  <价值> org.apache.hadoop.fs.s3.S3FileSystem< /值GT;
< /性>

<性>
  <名称>&fs.s3n.impl LT; /名称>
  <价值> org.apache.hadoop.fs.s3native.NativeS3FileSystem< /值GT;
< /性>
 

这一次,我得到一个不同的错误:

  -ls:致命内部错误
java.lang.RuntimeException的:抛出java.lang.ClassNotFoundException:类org.apache.hadoop.fs.s3.S3FileSystem未找到
        在org.apache.hadoop.conf.Configuration.getClass(Configuration.java:2074)
        在org.apache.hadoop.fs.FileSystem.getFileSystemClass(FileSystem.java:2578)
        在org.apache.hadoop.fs.FileSystem.createFileSystem(FileSystem.java:2591)
 

不知怎的,我怀疑纱线分布不具备必要的罐子,以便能够读取S3,但我不知道从哪里得到这些。任何指针在这个方向将是极大的AP preciated。

解决方案

由于某些原因,罐子 Hadoop的aws.jar ,其中包含的实施 NativeS3FileSystem 不是present在Hadoop中的2.6版本的的classpath 默认情况下。因此,试图通过添加下面的行 hadoop-env.sh ,位于 $ HADOOP_HOME /添加到类路径等/ Hadoop的/ hadoop-env.sh

 出口HADOOP_CLASSPATH = $ HADOOP_CLASSPATH:$ HADOOP_HOME /股/ Hadoop的/ tools / lib目录/ *
 

  

假设你使用的是Apache Hadoop的2.6

顺便说一句,你可以使用检查的Hadoop的类路径:

 斌/ Hadoop的类路径
 

I am trying to reproduce an Amazon EMR cluster on my local machine. For that purpose, I have installed the latest stable version of Hadoop as of now - 2.6.0. Now I would like to access an S3 bucket, as I do inside the EMR cluster.

I have added the aws credentials in core-site.xml:

<property>
  <name>fs.s3.awsAccessKeyId</name>
  <value>some id</value>
</property>

<property>
  <name>fs.s3n.awsAccessKeyId</name>
  <value>some id</value>
</property>

<property>
  <name>fs.s3.awsSecretAccessKey</name>
  <value>some key</value>
</property>

<property>
  <name>fs.s3n.awsSecretAccessKey</name>
  <value>some key</value>
</property>

Note: Since there are some slashes on the key, I have escaped them with %2F

If I try to list the contents of the bucket:

hadoop fs -ls s3://some-url/bucket/

I get this error:

ls: No FileSystem for scheme: s3

I edited core-site.xml again, and added information related to the fs:

<property>
  <name>fs.s3.impl</name>
  <value>org.apache.hadoop.fs.s3.S3FileSystem</value>
</property>

<property>
  <name>fs.s3n.impl</name>
  <value>org.apache.hadoop.fs.s3native.NativeS3FileSystem</value>
</property>

This time I get a different error:

-ls: Fatal internal error
java.lang.RuntimeException: java.lang.ClassNotFoundException: Class org.apache.hadoop.fs.s3.S3FileSystem not found
        at org.apache.hadoop.conf.Configuration.getClass(Configuration.java:2074)
        at org.apache.hadoop.fs.FileSystem.getFileSystemClass(FileSystem.java:2578)
        at org.apache.hadoop.fs.FileSystem.createFileSystem(FileSystem.java:2591)

Somehow I suspect the Yarn distribution does not have the necessary jars to be able to read S3, but I have no idea where to get those. Any pointers in this direction would be greatly appreciated.

解决方案

For some reason, the jar hadoop-aws.jar which contains the implementation to NativeS3FileSystem is not present in the classpath of hadoop by default in the version 2.6. So, try and add it to the classpath by adding the following line in hadoop-env.sh which is located in $HADOOP_HOME/etc/hadoop/hadoop-env.sh:

export HADOOP_CLASSPATH=$HADOOP_CLASSPATH:$HADOOP_HOME/share/hadoop/tools/lib/*

Assuming you are using Apache Hadoop 2.6

By the way you could check the classpath of hadoop using:

bin/hadoop classpath

这篇关于我怎样才能从本地的Hadoop 2.6的安装进入S3 / S3N?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆