miketwais

work up

hue上使用oozie调度sqoop import mysql数据到hive

近期实践CDH大数据平台的搭建使用,CDH搭建结束后,尝试使用oozie调度从mysql导出数据到hive表中。

 

 

1.CDH 搭建

  

 

 

 资源需求如上,由于目前CDH新版本收费,我们选择使用CDH 6.3.2版本,自己网上找资源。

安装的所有组件:

 

 

 

 2.因为用sqoop从mysql导入数据,需要先配置jdbc-mysql驱动

我的mysql版本是mysql 5.7.26,对应使用mysql-connector-java-8.0.26.jar

将mysql-connector-java-8.0.26.jar拷贝到 CDH所有节点的/var/lib/sqoop/下(我的CDH集群是三台机器)

另外,在mysql中创建表,创建测试数据

create table user(
id int(10) primary key not null auto_increment,
name varchar(20) not null,
age int(10) not null
) ENGINE=InnoDB DEFAULT CHARSET=UTF8;
View Code
insert into user (name,age) values('user1', 12);
insert into user (name,age) values('user2', 13);
insert into user (name,age) values('user3', 14);
insert into user (name,age) values('user4', 15);
insert into user (name,age) values('user5', 16);
insert into user (name,age) values('user6', 17);
insert into user (name,age) values('user7', 18);
insert into user (name,age) values('user8', 19);
View Code

ps:一定确保mysql能够被远程访问

 

3.在hue上配置workflow

Query-->Scheduler-->Workflow

 

点击shell脚本,拖到下方位置,写入shell命令:

#!bin/bash

sqoop import --connect jdbc:mysql://*****:3306/ura-demo --username root --password root --table user --target-dir /tmp/sqoop1 -m 1 --hive-import --hive-table default.user --create-hive-table
echo "hello hue!"

 

 

 点击执行。

查看结果:

 

 到yarn查看详细日志:

 

 点击ID

 

 

 

 

 4.查看hive表结果

 

 可见mysql的user表中的数据进入hive的 user表 :

 

posted @ 2021-12-31 14:25  MasonZhang  阅读(292)  评论(0编辑  收藏  举报