將資料通過shell指令碼從hdfs匯入到hive中

2021-09-22 20:37:35 字數 856 閱讀 3230

在建立專案的時候 需要將資料匯入 則此時的資料不能通過hql來再shell中展示 所以需要記錄指令碼

而這塊內容應該寫在乙個單獨的模組下面

需要注意的是對檔案的明明

xx_yy_zz.hql

xx 檔名 yy 表示資料庫對應表明 zz分割槽性質如按照天則為yyyymmdd

這樣明明的好處就是一目了然 讓人明白它是哪的檔案用於做什麼的

drop table if exists ods_company_$;

create external table ods_company_$(

company_id int

,company_address string

,company_attr string

,company_boss string

,company_name string

,company_phone string

)stored as parquet

location '/sqoop/btrip_pg/$/tb_company'

執行真個shell指令碼 過程

啟動hdfs ,yarn

sqoop2-server : 建立job 以及用於將資料從postgresql匯入到hdfs

hiveserver2 將資料從hdfs匯入到hive中

將指令碼傳到 linux上

通過指令執行指令碼 有

hive -f ods_company_yyyymmdd.hql --hivevar yyyymmdd=20171201
yyyymmdd 為日期與指令碼中的yyyym

yyyymmdd對應

如何將JSON資料通過Get方法獲取資料

介面格式如下 imuser getcontact?getcontact userid 9 其中 userid 9 為json格式 我是用asihttprequest來請求資料的,方法如下 nsmutabledictionary mudic nsmutabledictionary alloc init...

通過shell指令碼批量操作mysql資料庫

建立建表語句 學生表 student sno,sname,s sage,sdept 學號 主鍵,姓名,性別,年齡,所在系 create table student sno int 10 not null comment 學號 sname varchar 16 not null comment 姓名 ...

通過shell指令碼操作mysql資料庫

在做一些日常的運維工作的時候,經常需要些一些shell指令碼進行裝置效能以及其它引數的監控。在過去的一年工作中,接觸到的比較多的是對資料庫中某些資訊的監控。於是就想到了用shell mysql crontab進行實現。下面附上通過shell命令列非互動式的運算元據庫的方法 mysql hhostna...