kettle連接Hive操作
從Hive中下載數據到excel中
-
拉出表輸入步驟,然後創建一個新的數據庫連接,連接上Hive。
這裏第一次連接時報錯,懷疑是Hive沒啓動,後面在node-1上運行hive發現還是不行,然後使用node-3遠程連接Hive,再在這進行測試,發現ok。
-
選取要導出的表,後續的步驟一致了。
向Hive中寫入數據
將剛剛下載下來的數據寫入到test1表中。
首先拉出excel輸出和表輸入,然後老步驟,不過這裏的數據庫連接是連接Hive。
通過Hadoopcopyfiles作業組件把數據加載到hive數據庫中
將下面鏈接下載好的數據上傳至Hive中。
<http://wiki.pentaho.com/download/attachments/23530622/weblogs_parse.txt.zip?version=1&modificationDate=1327068013000>
- 先在Hive上創建對應的表。
建表語句:
create table pttest.weblogs(
t_ip string,
full_request string,
day string,
month string,
month_num int,
year string,
hour string,
minute string,
second string,
timezone string,
http_verb string,
uri string,
http_status_code string,
bytes_returned string,
referrer string,
user_agent string
)
row format delimited fields terminated by '\t';
- 然後創建一個作業(這裏不是創建轉換),使用Hadoop copy file 作業組件。
-
查看結果。
執行Hive的SQL語句
創建一個作業,使用核心對象下的腳本里的SQL,連接上Hive,然後執行下面SQL。
SQL語句:
create table pttest.weblogs_agg
as
select t_ip,year,month,month_num,count(*)
from pttest.weblogs
group by t_ip,year,month,month_num;