我是Hadoop和Hive的新手。我正在使用hadoop 2.7.0
和hive 1.1.1
。
我有一些格式很快的文件。我已经在我的hdfs中复制了它们。我想知道:1.如何使用hdfs中的这些文件创建配置单元表。2.如何配置hadoop来处理snappy文件。
编辑:我尝试了以下操作:
1.修改core-site.xml
:
<property>
<name>io.compression.codecs</name>
<value>org.apache.hadoop.io.compress.GzipCodec,
org.apache.hadoop.io.compress.DefaultCodec,
org.apache.hadoop.io.compress.SnappyCodec
</value>
</property>
2.修改后的mapred-site.xml
:
<property>
<name>mapreduce.map.output.compress</name>
<value>true</value>
</property>
<property>
<name>mapred.map.output.compress.codec</name>
<value>org.apache.hadoop.io.compress.SnappyCodec</value>
</property>
<property>
<name>mapreduce.admin.user.env</name>
<value>LD_LIBRARY_PATH=/Users/8417/repos/hadoop_ecosystem/hadoop-2.7.0/lib/native</value>
</property>
安装快捷的
brew install snappy
。cp /usr/local/Cellar/snappy/<version>/lib/snappy.* to $HADOOP_HOME/lib/snappy
cp /usr/local/Cellar/snappy/<version>/lib/snappy.* /Library/Java/Home/jre/lib
。
6.添加了以下环境变量:
export JAVA_LIBRARY_PATH="$HADOOP_HOME/lib/native"
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HADOOP_HOME/lib/native
export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native
export HADOOP_OPTS="-Djava.library.path=$HADOOP_HOME/lib"
但我不能让它发挥作用。我得到以下错误:
Machine:native user$ hadoop fs -text hive/part-00000.snappy
15/09/24 19:25:14 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Exception in thread "main" java.lang.UnsatisfiedLinkError: org.apache.hadoop.util.NativeCodeLoader.buildSupportsSnappy()Z
at org.apache.hadoop.util.NativeCodeLoader.buildSupportsSnappy(Native Method)
at org.apache.hadoop.io.compress.SnappyCodec.checkNativeCodeLoaded(SnappyCodec.java:63)
at org.apache.hadoop.io.compress.SnappyCodec.getDecompressorType(SnappyCodec.java:192)
at org.apache.hadoop.io.compress.CodecPool.getDecompressor(CodecPool.java:178)
at org.apache.hadoop.io.compress.CompressionCodec$Util.createInputStreamWithCodecPool(CompressionCodec.java:157)
at org.apache.hadoop.io.compress.SnappyCodec.createInputStream(SnappyCodec.java:162)
at org.apache.hadoop.fs.shell.Display$Text.getInputStream(Display.java:163)
at org.apache.hadoop.fs.shell.Display$Cat.processPath(Display.java:102)
at org.apache.hadoop.fs.shell.Command.processPaths(Command.java:317)
at org.apache.hadoop.fs.shell.Command.processPathArgument(Command.java:289)
at org.apache.hadoop.fs.shell.Command.processArgument(Command.java:271)
at org.apache.hadoop.fs.shell.Command.processArguments(Command.java:255)
at org.apache.hadoop.fs.shell.Command.processRawArguments(Command.java:201)
at org.apache.hadoop.fs.shell.Command.run(Command.java:165)
at org.apache.hadoop.fs.FsShell.run(FsShell.java:287)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:84)
at org.apache.hadoop.fs.FsShell.main(FsShell.java:340)
Machine:native user$ hadoop checknative
15/09/24 19:41:16 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Native library checking:
hadoop: false
zlib: false
snappy: false
lz4: false
bzip2: false
openssl: false
15/09/24 19:41:16 INFO util.ExitUtil: Exiting with status 1
确保您安装了snappy,并且您的hadoop能够"看到"它:
hadoop checknative
...
snappy: true /usr/lib64/libsnappy.so.1
...
还要确保你的文件扩展名是".snappy"。差不多就是这样。
启动蜂箱或直线并创建您的桌子:
create external table t1(f1 int, ...) location '/path/to/dir/with/snappy/files';