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;
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
<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>
本文轉自 liqius 51CTO部落格,原文連結:http://blog.51cto.com/szgb17/1926659,如需轉載請自行聯系原作者