我正在尝试在Google Compute引擎上针对我们的压缩数据运行Hadoop Job,这些数据位于Google云端存储上。 在尝试通过SequenceFileInputFormat读取数据时,我得到以下异常:
hadoop@hadoop-m:/home/salikeeno$ hadoop jar ${JAR} ${PROJECT} ${OUTPUT_TABLE}
14/08/21 19:56:00 INFO jaws.JawsApp: Using export bucket 'askbuckerthroughhadoop' as specified in 'mapred.bq.gcs.bucket'
14/08/21 19:56:00 INFO bigquery.BigQueryConfiguration: Using specified project-id 'regal-campaign-641' for output
14/08/21 19:56:00 INFO gcs.GoogleHadoopFileSystemBase: GHFS version: 1.2.8-hadoop1
14/08/21 19:56:01 WARN mapred.JobClient: Use GenericOptionsParser for parsing the arguments. Applications should implement Tool for the same.
14/08/21 19:56:03 INFO input.FileInputFormat: Total input paths to process : 1
14/08/21 19:56:09 INFO mapred.JobClient: Running job: job_201408211943_0002
14/08/21 19:56:10 INFO mapred.JobClient: map 0% reduce 0%
14/08/21 19:56:20 INFO mapred.JobClient: Task Id : attempt_201408211943_0002_m_000001_0, Status : FAILED
java.lang.RuntimeException: native snappy library not available
at org.apache.hadoop.io.compress.SnappyCodec.getDecompressorType(SnappyCodec.java:189)
at org.apache.hadoop.io.compress.CodecPool.getDecompressor(CodecPool.java:125)
at org.apache.hadoop.io.SequenceFile$Reader.init(SequenceFile.java:1581)
at org.apache.hadoop.io.SequenceFile$Reader.<init>(SequenceFile.java:1490)
at org.apache.hadoop.io.SequenceFile$Reader.<init>(SequenceFile.java:1479)
at org.apache.hadoop.io.SequenceFile$Reader.<init>(SequenceFile.java:1474)
at org.apache.hadoop.mapreduce.lib.input.SequenceFileRecordReader.initialize(SequenceFileRecordReader.java:50)
at org.apache.hadoop.mapred.MapTask$NewTrackingRecordReader.initialize(MapTask.java:521)
at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:763)
at org.apache.hadoop.mapred.MapTask.run(MapTask.java:364)
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:415)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1190)
at org.apache.hadoop.mapred.Child.main(Child.java:249)
非常感谢
答案 0 :(得分:7)
默认情况下,bdutil部署将包含Snappy。
你的最后一个问题是在一般情况下最容易回答的问题,所以我将从那里开始。传送依赖关系的一般指导是应用程序应该使用分布式缓存将JAR和库分发给工作程序(Hadoop 1或2)。如果您的代码已经在使用GenericOptionsParser,则可以使用-libjars标志来分配JAR。可以在Cloudera的博客上找到更长时间的讨论,该博客还讨论了脂肪JAR:http://blog.cloudera.com/blog/2011/01/how-to-include-third-party-libraries-in-your-map-reduce-job/
为了安装和配置其他系统级组件,bdutil支持扩展机制。扩展的一个很好的例子是与bdutil捆绑的Spark扩展:extensions / spark / spark_env.sh。当运行bdutil扩展时添加了-e标志,例如,使用Hadoop部署Spark:
./bdutil -e extensions/spark/spark_env.sh deploy
关于你的第一个和第二个问题:在GCE上处理Hadoop中的Snappy时有两个障碍。第一个是由Apache构建并与Hadoop 2 tarball捆绑在一起的本机支持库是为i386构建的,而GCE实例是amd64。 Hadoop 1捆绑了两个平台的二进制文件,但是如果没有捆绑或修改环境,snappy就无法定位。由于这种体系结构的不同,Hadoop 2中没有可用的原生压缩器(snappy或其他),并且在Hadoop 1中不容易使用Snappy。第二个障碍是默认情况下没有安装libsnappy本身。
克服这两者的最简单方法是创建自己的Hadoop tarball,其中包含amd64本机Hadoop库以及libsnappy。下面的步骤可以帮助您执行此操作并暂存生成的tarball以供bdutil使用。
首先,使用Debian Wheezy backports映像启动新的GCE VM,并授予VM服务帐户对云存储的读/写访问权限。我们将使用它作为我们的构建机器,我们可以在构建/存储二进制文件后立即放弃它。
SSH到您的新实例并运行以下命令,检查一路上的任何错误:
sudo apt-get update
sudo apt-get install pkg-config libsnappy-dev libz-dev libssl-dev gcc make cmake automake autoconf libtool g++ openjdk-7-jdk maven ant
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/
wget http://apache.mirrors.lucidnetworks.net/hadoop/common/hadoop-1.2.1/hadoop-1.2.1.tar.gz
tar zxvf hadoop-1.2.1.tar.gz
pushd hadoop-1.2.1/
# Bundle libsnappy so we don't have to apt-get install it on each machine
cp /usr/lib/libsnappy* lib/native/Linux-amd64-64/
# Test to make certain Snappy is being loaded and is working:
bin/hadoop jar ./hadoop-test-1.2.1.jar testsequencefile -seed 0 -count 1000 -compressType RECORD xxx -codec org.apache.hadoop.io.compress.SnappyCodec -check
# Create a new tarball of Hadoop 1.2.1:
popd
rm hadoop-1.2.1.tar.gz
tar zcvf hadoop-1.2.1.tar.gz hadoop-1.2.1/
# Store the tarball on GCS:
gsutil cp hadoop-1.2.1.tar.gz gs://<some bucket>/hadoop-1.2.1.tar.gz
SSH到您的新实例并运行以下命令,检查一路上的任何错误:
sudo apt-get update
sudo apt-get install pkg-config libsnappy-dev libz-dev libssl-dev gcc make cmake automake autoconf libtool g++ openjdk-7-jdk maven ant
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/
# Protobuf 2.5.0 is required and not in Debian-backports
wget http://protobuf.googlecode.com/files/protobuf-2.5.0.tar.gz
tar xvf protobuf-2.5.0.tar.gz
pushd protobuf-2.5.0/ && ./configure && make && sudo make install && popd
sudo ldconfig
wget http://apache.mirrors.lucidnetworks.net/hadoop/common/hadoop-2.4.1/hadoop-2.4.1-src.tar.gz
# Unpack source
tar zxvf hadoop-2.4.1-src.tar.gz
pushd hadoop-2.4.1-src
# Build Hadoop
mvn package -Pdist,native -DskipTests -Dtar
pushd hadoop-dist/target/
pushd hadoop-2.4.1/
# Bundle libsnappy so we don't have to apt-get install it on each machine
cp /usr/lib/libsnappy* lib/native/
# Test that everything is working:
bin/hadoop jar share/hadoop/common/hadoop-common-2.4.1-tests.jar org.apache.hadoop.io.TestSequenceFile -seed 0 -count 1000 -compressType RECORD xxx -codec org.apache.hadoop.io.compress.SnappyCodec -check
popd
# Create a new tarball with libsnappy:
rm hadoop-2.4.1.tar.gz
tar zcf hadoop-2.4.1.tar.gz hadoop-2.4.1/
# Store the new tarball on GCS:
gsutil cp hadoop-2.4.1.tar.gz gs://<some bucket>/hadoop-2.4.1.tar.gz
popd
popd
一旦你有一个捆绑了正确本机库的Hadoop版本,我们可以通过为Hadoop 1更新bdutil_env.sh或者为Hadoop 2更新hadoop2_env.sh来指向新的Hadoop tarball bdutil。在任何一种情况下,打开适当的文件并寻找一个块:
# URI of Hadoop tarball to be deployed. Must begin with gs:// or http(s)://
# Use 'gsutil ls gs://hadoop-dist/hadoop-*.tar.gz' to list Google supplied options
HADOOP_TARBALL_URI='gs://hadoop-dist/hadoop-1.2.1-bin.tar.gz'
并将指向的URI更改为我们在上面存储tarball的URI:例如,
HADOOP_TARBALL_URI='gs://<some bucket>/hadoop-1.2.1.tar.gz'