hive环境搭建,
一、 Hive搭建
wget http://mirror.bit.edu.cn/apache/hive/stable/hive-0.10.0-bin.tar.gz
Hive搭建在Hadoop的基础之上,相对就会简单很多。只需要设置Hadoop的HADOOP_HOME和HIVE_HOME即可了。
首先下载、解压,此操作与商品Hadoop的操作一样。值得注意的是,Apache的官网上会提供bin和dev两种版本的压缩包。建议使用bin版本。
完成之后,如下操作:
export PATH=$PATH:/u/opt/hive-0.10.0-bin/bin
export HADOOP_HOME=/u/opt/hadoop-1.2.1/
export HIVE_HOME=/u/opt/hive-0.10.0-bin/
二、 测试
完成命令,直接在hive/bin目录下启动hive,启动端口任意写一个未被占用的即可。/hive --service hiveserver 10000 &
在hive/bin目录下,输入./hive,进入hive命令的控制台。执行hql,就是hive的sql具体如下:
hadoop1:/u/opt/hive-0.10.0-bin/bin # ./hiveWARNING: org.apache.hadoop.metrics.jvm.EventCounter is deprecated. Please use org.apache.hadoop.log.metrics.EventCounter in all the log4j.properties files.Logging initialized using configuration in jar:file:/u/opt/hive-0.10.0-bin/lib/hive-common-0.10.0.jar!/hive-log4j.propertiesHive history file=/tmp/root/hive_job_log_root_201309151139_1246714134.txthive> show tables;OKTime taken: 2.923 secondshive> CREATE TABLE pokes (foo INT, bar STRING);OKTime taken: 0.436 secondshive> show tables;OKpokesTime taken: 0.095 secondshive> CREATE TABLE invites (foo INT, bar STRING) PARTITIONED BY (ds STRING);OKTime taken: 0.049 secondshive> show tables;OKinvitespokesTime taken: 0.065 secondshive> > show create table invites;OKCREATE TABLE invites( foo int, bar string)PARTITIONED BY ( ds string)ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe' STORED AS INPUTFORMAT 'org.apache.hadoop.mapred.TextInputFormat' OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat'LOCATION 'hdfs://hadoop1:9000/user/hive/warehouse/invites'TBLPROPERTIES ( 'transient_lastDdlTime'='1379216556')Time taken: 0.084 secondshive> quit;hadoop1:/u/opt/hive-0.10.0-bin/bin #参考:http://www.csdn.net/article/2010-09-01/278944
本站文章为和通数据库网友分享或者投稿,欢迎任何形式的转载,但请务必注明出处.
同时文章内容如有侵犯了您的权益,请联系QQ:970679559,我们会在尽快处理。