Sqoop安装与使用

使用sqoop进行将Hive 词频统计的结果数据传输到Mysql中

测试:

1.mysql准备接受数据的数据库与表

show databases;
create database if not exists wc;
use wc;
show tables;
create table if not exists `wc` (`word` varchar(100), `count` int) engine=InnoDB DEFAULT CHARSET =utf8;
desc wc;
show create table wc;

2.hive准备待传输的数据

stat-all.sh
jps
hive
show databases;
use hive;
show tables;
select * from wctext;
create table if not exists wc1  row format delimited fields terminated by '\t' as select word,count(1) as count from (select explode(split(line,' ')) as word from wctext) word group by word order by word ;
show create table wc1;
select * from wc1;
desc wc1;



3.sqoop进行数据传输

sqoop export --connect jdbc:mysql://127.0.0.1:3306/wc?useSSL=false --username root --password hadoop --table wc --export-dir /user/hive/warehouse/hive.db/wc1 --input-fields-terminated-by '\t'


4.mysql查看传输结果

use wc;
select * from wc;

使用电子书:

1.mysql准备接受数据的数据库与表

2.hive准备待传输的数据

select * from wctext;
create table if not exists wc2 row format delimited fields terminated by '\t' as select word,count(1) as count from (select explode(split(line,' ')) as word from wctext) word group by word order by word ;
show create table wc1;
select * from wc1;




3.sqoop进行数据传输

sqoop export --connect jdbc:mysql://127.0.0.1:3306/wc?useSSL=false --username root --password hadoop --table wc2 --export-dir /user/hive/warehouse/hive.db/wc2 --input-fields-terminated-by '\t'


4.mysql查看传输结果

use wc;
select * from wc2;

posted @ 2020-12-12 14:16  会喷水的海参  阅读(109)  评论(0编辑  收藏  举报