sqoop資料匯入匯出常用功能

2021-07-25 07:21:35 字數 1053 閱讀 3203

sqoop wget下來解壓後即可使用,常用的匯入匯出語句為:

//匯入到hdfs中

./sqoop import --connect jdbc:mysql://localhost:3306/kbs --username hive --password 123456 --table user --columns 'username,address' -m 1 --target-dir '/sqoop/user'

//匯入到hive中,新增where條件

./sqoop import --connect jdbc:mysql://localhost:3306/kbs --username hive --password 123456 --table user --columns 'username,address' -m 1 --hive table users --where 'username=linfenliang'

//匯入到hive中,新增select語句

./sqoop import --connect jdbc:mysql://localhost:3306/kbs --username hive --password 123456 --columns 'username,address' -m 1 --target-dir '/sqoop/user_select' --hive table users --query 'select username,password from user where username = linfenliang and $conditions'

//匯出hive資料到mysql中

./sqoop emport --connect jdbc:mysql://localhost:3306/kbs --username hive --password 123456 -m 1 --table mysql_table --export-dir '/sqoop/user'

應用:

一般我們會先把資料從資料庫中匯入到資料倉儲中,如hdfs或hive中,

然後借助hive進行資料分析與處理,

資料分析處理完成後,將結果寫入到mysql中即可

Sqoop資料匯入匯出常用引數

公有 connect 指定mysql jdbc url password 指定mysql密碼 username 指定mysql賬號 匯入hdfs使用 as textfile 資料儲存到hdfs的時候是text檔案格式 as parquetfile 資料儲存到hdfs的時候是parquet檔案格式 d...

Sqoop(二) Sqoop匯入 匯出資料

1.2 rdbms hive 1.3 rdbms hbase 2.匯出資料 在sqoop中,匯入 概念指 從非大資料集群 rdbms 向大資料集群 hdfs,hive,hbase 中傳輸資料,叫做 匯入,即使用import關鍵字。sqoop import connect jdbc mysql top...

sqoop匯入匯出

sqoop官方手冊位址 最近在看sqoop有些感想,就寫下來。sqoop是大資料裡面匯入匯出的乙個工具。關於import匯出 可以從mysql匯出到hdfs,hbase,hive,案例如下,這是乙個匯出到hdfs的案例 import connect jdbc mysql username root ...