hive 

show tables;

create table hive_test(name string);

LOAD DATA LOCAL INPATH '/home/hadoop/input/test3.txt' overwrite INTO TABLE hive_test; 

select * from hive_test;

drop table hive_test;

show tables;


cat a.txt

1,h  

2,i  

3,v  

4,e  

hive> create table a(id int,name string)  

   > row format delimited fields terminated by ',';  

hive> load data local inpath '/root/桌面/Test/wc-in/a.txt' into table a; 

hive> select * from a;  




在Hive内使用dfs命令

hive> dfs -ls /usr/hive/warehouse/a; 

hive> dfs -cat /usr/hive/warehouse/a/*; 


登陆MySQL创建数据库:hive_db

<value>jdbc:mysql://localhost:3306/hive_db?createDatabaseIfNoExist=true</value>


登陆mysql

mysql> use hive_db;  

mysql> select TBL_ID, CREATE_TIME,DB_ID, OWNER, TBL_NAME,TBL_TYPE from TBLS; 


在hdfs查看生成文件(同上步骤[6.3])

hdfs dfs -ls/usr/hive/warehouse/a

hdfs dfs -cat  /usr/hive/warehouse/a/*  



关闭安全模式

hadoop dfsadmin-safemode leave  


-调用HiveServer2客户端和beeline命令用法

--启用服务,信息不动时Ctrl+C退出

create table Test_beeline(id int); 




hive还有个web图形界面,这里补充一下配置

首先停掉matestore服务,然后在hive-site.xml加入如下配置

<property>

<name>hive.hwi.war.file</name>

<value>lib/hive-hwi-1.2.0.war</value>

<description>hwi得war路径</description>

</property>


beeline

./bin/hive --service hiveserver2  &


bin/beeline


嵌入模式:

beeline> !connect jdbc:hive2:// 

Connecting to jdbc:hive2://

Enter username for jdbc:hive2://: 

Enter password for jdbc:hive2://: 

远程模式:

beeline -u jdbc:hive2://192.168.133.147:10000  -n root  -p liguodong


<property>

<name>hive.metastore.uris</name>

<value>thrift://192.168.133.147:9083</value>

<description>Thrift URI for the remote metastore. Used by metastore client to connect to remote metastore.</description>

</property>