05-用户画像+mysql-hive数据导入

发布于:2024-07-25 ⋅ 阅读:(125) ⋅ 点赞:(0)

将用户数据导入数仓

在这里插入图片描述

新建 create_hive_table.sh文件

在终端执行以下文件
sh create_hive_table.sh

sqoop create-hive-table \
--connect jdbc:mysql://up01:3306/tags_dat \    tags_dat库名
--username root \       root 用户名
--password 123456 \    123456  密码
--table tbl_users \     tbl_users表名
--hive-database db_ods  \    db_ods  hive数据库库名
--hive-table tbl_users      tbl_users  表名

wait

sqoop create-hive-table \
--connect jdbc:mysql://up01:3306/tags_dat \
--username root \
--password 123456 \
--table tbl_goods \
--hive-database db_ods  \
--hive-table tbl_goods

wait

sqoop create-hive-table \
--connect jdbc:mysql://up01:3306/tags_dat \
--username root \
--password 123456 \
--table tbl_logs \
--hive-database db_ods  \
--hive-table tbl_logs

wait

sqoop create-hive-table \
--connect jdbc:mysql://up01:3306/tags_dat \
--username root \
--password 123456 \
--table tbl_orders \
--hive-database db_ods  \
--hive-table tbl_orders

导入脚本

 sqoop import \
 --connect jdbc:mysql://up01:3306/tags_dat \
 --username root \
 --password 123456 \
 --table tbl_users \
 --hive-import \
 --hive-overwrite \
 --hive-database db_ods  \
 --hive-table tbl_users \
 --delete-target-dir \
 -m 2

 wait

sqoop import \
 --connect jdbc:mysql://up01:3306/tags_dat \
 --username root \
 --password 123456 \
 --table tbl_goods \
 --hive-import \
 --hive-overwrite \
 --hive-database db_ods  \
 --hive-table tbl_goods \
 --delete-target-dir \
 -m 2

wait

sqoop import \
 --connect jdbc:mysql://up01:3306/tags_dat \
 --username root \
 --password 123456 \
 --table tbl_logs \
 --hive-import \
 --hive-overwrite \
 --hive-database db_ods  \
 --hive-table tbl_logs \
 --delete-target-dir \
 -m 2

wait

sqoop import \
 --connect jdbc:mysql://up01:3306/tags_dat \
 --username root \
 --password 123456 \
 --table tbl_orders \
 --hive-import \
 --hive-overwrite \
 --hive-database db_ods  \
 --hive-table tbl_orders \
 --delete-target-dir \
 -m 2

网站公告

今日签到

点亮在社区的每一天
去签到