hive 中使用lzo
1 启动hive 错误
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/hive/conf/HiveConf
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:247)
at org.apache.hadoop.util.RunJar.main(RunJar.java:149)
解决方法是,安装Hadoop时,修改Hadoop目录下/conf/hadoop-env.sh时,添加HADOOP_CLASSPATH变量覆盖了原有的变量,改成如下的形式即可:
HADOOP_CLASSPATH=$HADOOP_CLASSPATH:
2 创建测试表
create table lzo(name string) STORED AS INPUTFORMAT 'com.hadoop.mapred.DeprecatedLzoTextInputFormat' OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat';
3 压缩测试数据
lzop users.txt
4 导入数据
load data local inpath '/home/hadoop/tmp/tmplzo.txt.lzo' into table lzo;
4 测试
select * from lzo;