Sqoop的使用

将hive客户端的hive-site.xml复制到$SOOP_HOME/conf目录下,不然会提示hive自己建的数据库不存在

复制代码
全节点:zkServer.sh start

cdh1:  start-dfs.sh

cdh1:  start-yarn.sh

cdh3:  yarn-daemon.sh start resourcemanager

hive客户端节点:sqoop import --connect jdbc:mysql://cdh3:3306/mycdh --username root --password 147258 --table DemoDate --delete-target-dir --hive-database datademo
--hive-import --hive-overwrite --create-hive-table --hive-table sqDemoDate --m 3
复制代码
复制代码
//成功
hive (datademo)> show tables;
OK
tab_name
demo
sqdemodate
Time taken: 0.115 seconds, Fetched: 2 row(s)
hive (datademo)> select * from sqdemodate;
OK
sqdemodate.id   sqdemodate.starttime    sqdemodate.endtime      sqdemodate.diff sqdemodate.indate
1       2022-02-24      2022-02-26      3       2022-02-26 17:22:26.0
2       2022-02-20      2022-02-23      2       2022-02-26 17:22:26.0
3       2022-02-04      2022-02-06      1       2022-02-26 17:22:26.0
4       2022-02-12      2022-02-16      2       2022-02-26 17:22:26.0
5       2022-02-03      2022-02-08      2       2022-02-26 17:22:26.0
6       2022-02-21      2022-02-27      5       2022-02-26 17:22:26.0
7       2022-02-24      null    0       2022-02-26 17:41:56.0
Time taken: 4.181 seconds, Fetched: 7 row(s)
hive (datademo)>
复制代码

hive导出到MySQL

[root@cdh1 /]# sqoop export --connect jdbc:mysql://cdh3:3306/BigData --username root --password 147258 --table demo1 
--export-dir '/hive/warehouse/bigdata.db/demo1' --fields-terminated-by '/001';
posted @   M_Fight๑҉  阅读(24)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· 实操Deepseek接入个人知识库
· CSnakes vs Python.NET:高效嵌入与灵活互通的跨语言方案对比
· 【.NET】调用本地 Deepseek 模型
· Plotly.NET 一个为 .NET 打造的强大开源交互式图表库
点击右上角即可分享
微信分享提示