Spark数据抽取1

大数据阶段二-1
阶段二-任务一的要求
任务一:数据抽取 |
修改customer_inf表
将修改过的customer_inf表放进hive里面执行
- 首先启动master并且查看一些hadoop有没有启动
- 之后直接:hive
- 然后在hive里面创建ods的库,创建完出现个ok就行了
create database ods;
- 切换到ods的库里面
use ods;
- 然后可以使用 hive cli执行 show partitions ods.customer_inf命令; 出行一个ok即可
show partitions ods.customer_inf;
- 最后将你修改好的customer_inf直接复制进去即可,出现ok就表示成功了
CREATE TABLE customer_inf (
customer_inf_id int,
customer_id int,
customer_name string,
identity_card_type int,
identity_card_no string,
mobile_phone string,
customer_email string,
gender string,
customer_point int,
register_time timestamp,
birthday timestamp,
customer_level int,
customer_money double,
modified_time timestamp
) partitioned by (etl_date string) row format delimited fields terminated by ',' lines terminated by '\n'; - 可是因为还没有导入数据所以里面什么也没有,但是你可以通过 desc customer_inf查看一下字段
desc customer_inf
- 将customer_inf表放进新建的ods库里面
- 查看字段
代码段导入数据
数据抽取代码部分一
package com.jnds |
从IDEA里面scp到master里面
scp .\task2.jar [email protected]:/tmp |
到msater里面跑任务
- 跑任务
spark-submit --master yarn --class com.jnds.task1 /tmp/task2.jar
成功表示
然后hive进去查看有没有导入成功
先
use 你键的库名
查看数据是否放成功
select * from customer_inf
最后输入这条命令然后截图,看到有这个就是算完成了(etl_date=20230703)
show partitions ods.customer_inf;
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 MENGLAN!