0


Sqoop 的数据处理和开发--头歌

第1关:Sqoop数据导入语法学习

start-all.sh 
schematool -dbType mysql -initSchema 

第2关:Mysql导入数据至HDFS上

mysql -uroot -p123123 -h127.0.0.1 

create database hdfsdb;

use hdfsdb;

create table student(stu_no int primary key, stu_name varchar(20), stu_age int);

insert into student values(202001,"zhangsan",18);

insert into student values(202001,"lisi",19);

insert into student values(202001,"wangwu",20);

exit;

sqoop import --connect jdbc:mysql://127.0.0.1:3306/hdfsdb --username root --password 123123 --query 'select stu_name,stu_age from student where $CONDITIONS' --target-dir /user/root/hdfsdb3 --fields-terminated-by ',' -m 1 

第3关:Mysql导入数据至Hive中

现在hive里面建表

启动hive

create table test2(stu_no int,stu_name string,stu_age int)

row format delimited

fields terminated by ",";

exit;

sqoop import --connect jdbc:mysql://127.0.0.1:3306/hdfsdb --username root --password 123123 --query 'select stu_no, stu_name,stu_age from student where stu_age>=20 and $CONDITIONS' --target-dir /user/root/hdfsdb6 --fields-terminated-by ',' -m 1

进入hive

load data inpath '/user/root/hdfsdb6/part-m-00000' into table test2; 
标签: sqoop mysql hive

本文转载自: https://blog.csdn.net/m0_46560176/article/details/124575474
版权归原作者 Fdecad 所有, 如有侵权,请联系我们删除。

“Sqoop 的数据处理和开发--头歌”的评论:

还没有评论