一、 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 # ./hive
WARNING: 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.properties
Hive history file=/tmp/root/hive_job_log_root_201309151139_1246714134.txt
hive> show tables;
OK
Time taken: 2.923 seconds
hive> CREATE TABLE pokes (foo INT, bar STRING);
OK
Time taken: 0.436 seconds
hive> show tables;
OK
pokes
Time taken: 0.095 seconds
hive> CREATE TABLE invites (foo INT, bar STRING) PARTITIONED BY (ds STRING);
OK
Time taken: 0.049 seconds
hive> show tables;
OK
invites
pokes
Time taken: 0.065 seconds
hive>
> show create table invites;
OK
CREATE 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 seconds
hive> quit;
hadoop1:/u/opt/hive-0.10.0-bin/bin #