HIVE简单部署

1.下载   http://labs.renren.com/apache-mirror/hive/stable/hive-0.8.1.tar.gz
2.安装
安装hive之前确保已经安装了hadoop,hadoop简单安装请查看[url] http://alikevin2011.iteye.com/blog/1534712[/url]
[root@inc-platform-dev-145-5 hive]# tar -zxvf hive-0.8.1.tar.gz 

配置HIVE_HOME
[root@inc-platform-dev-145-5 hive]# vi /etc/profile
..
export HIVE_HOME=/home/kevin/work/hive
export HADOOP_HOME=/home/kevin/work/hadoop
export PATH=$JAVA_HOME/bin:$ANT_HOME/bin:$ANTX_HOME/bin:$HIVE_HOME/bin:$HADOOP_HOME/bin:$PAT
...

配置文件生效
[root@inc-platform-dev-145-5 hive]# source /etc/profile


3.进入hive的shell
[root@inc-platform-dev-145-5 hive]# bin/hive
Logging initialized using configuration in jar:file:/home/kevin/work/hive/lib/hive-common-0.8.1.jar!/hive-log4j.properties
Hive history file=/tmp/root/hive_job_log_root_201206061019_1215788833.txt
hive> 

4.创建简单表
[root@inc-platform-dev-145-5 hive]# su - work
[work@inc-platform-dev-145-5 ~]$ /home/kevin/work/hive/bin/hive
Logging initialized using configuration in jar:file:/home/kevin/work/hive/lib/hive-common-0.8.1.jar!/hive-log4j.properties
Hive history file=/tmp/work/hive_job_log_work_201206061022_606817436.txt
hive> CREATE TABLE pokes (foo INT, bar STRING);
OK
Time taken: 11.116 seconds

5.创建带有分区的表
hive> CREATE TABLE invites (foo INT, bar STRING) PARTITIONED BY (ds STRING);
OK
Time taken: 0.05 seconds

6.显示所有表
hive> SHOW TABLES;
OK
invites
pokes
Time taken: 0.099 seconds
hive> SHOW TABLES '.*s';
OK
invites
pokes
Time taken: 0.044 seconds

7.显示表结构
hive> DESCRIBE invites;
OK
foo     int
bar     string
ds      string
Time taken: 0.131 seconds

8.修改表结构
hive> ALTER TABLE pokes ADD COLUMNS (new_col INT);
OK
Time taken: 4.712 seconds
hive>  ALTER TABLE invites ADD COLUMNS (new_col2 INT COMMENT 'a comment');
OK
Time taken: 0.112 seconds
hive> ALTER TABLE events RENAME TO 3koobecaf;

9.删除表结构
hive> show tables;
OK
invites
pokes
Time taken: 0.101 seconds
hive> DROP TABLE pokes;
OK
Time taken: 3.353 seconds
hive> show tables;
OK
invites
Time taken: 0.069 seconds
hive> 

10.由文件加载数据到表中
数据文件片段examples/files/kv1.txt
...
86val_86
311val_311
27val_27
165val_165
409val_409
255val_255
278val_278
98val_98
484val_484
265val_265
193val_193
401val_401
150val_150
273val_273
224val_224
369val_369
66val_66
...

加载到pokes表

猜你喜欢

转载自alikevin2011.iteye.com/blog/1537115
今日推荐