将目录传递给hadoop流:需要一些帮助

时间:2013-03-01 10:56:40

标签: shell hadoop streaming amazon emr

上下文是我尝试使用我运行的bash脚本在Amazon EMR (网络用户界面)上运行流媒体作业:

-input s3://emrdata/test_data/input -output s3://emrdata/test_data/output -mapper
s3://emrdata/test_data/scripts/mapperScript.sh -reducer NONE

输入目录中包含子目录,这些子目录包含gzip压缩数据文件。

失败的mapperScript.sh的相关部分是:

for filename in "$input"/*; do

dir_name=`dirname $filename`
fname=`basename $filename`

echo "$fname">/dev/stderr

modelname=${fname}.model

modelfile=$model_location/$modelname

echo "$modelfile">/dev/stderr

inputfile=$dirname/$fname

echo "$inputfile">/dev/stderr

outputfile=$output/$fname

echo "$outputfile">/dev/stderr

# Will do some processing on the files in the sub-directories here

done # this is the loop for getting input from all sub-directories

基本上,我需要以流模式读取子目录,当我运行它时,hadoop抱怨说:

2013-03-01 10:41:26,226 ERROR
org.apache.hadoop.security.UserGroupInformation (main):               
PriviledgedActionException as:hadoop cause:java.io.IOException: Not a
file:      s3://emrdata/test_data/input/data1 2013-03-01 10:41:26,226
ERROR org.apache.hadoop.streaming.StreamJob (main):  Error Launching
job : Not a file: s3://emrdata/test_data/input/data1

我知道有类似的q被问到here

建议那里写一个自己的InputFormat。我想知道我的脚本编写方式是否遗漏了其他东西/给出了EMR输入,或者用Java编写自己的InputFormat是我唯一的选择。

我尝试向EMR输入“input / *”,但没有运气。

1 个答案:

答案 0 :(得分:2)

虽然可能会有一些临时的解决方法,但本质上hadoop并不支持这一点,因为您可能会看到此here上有一张打开的票证。 所以inputpatth/*/*可能适用于2级子目录,它可能无法进一步嵌套。

您现在可以做的最好的事情是获取files / folders-without-any-subdirectory的列表,并在创建输入路径的csv列表后递归添加它们。您可以使用像s3cmd这样的sinple工具。