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 # ./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 #

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值