一、将hive的表数据用sqoop抽取到mysql

1、编写oozie workflow和Coordinator

##
[root@hadoop-senior oozie-apps]# pwd
/opt/cdh-5.3.6/oozie-4.0.0-cdh5.3.6/oozie-apps [root@hadoop-senior oozie-apps]# ls wf-user-select/
coordinator.xml hive-site.xml job.properties lib select-user.sql workflow.xml [root@hadoop-senior oozie-apps]# ls wf-user-select/lib/
mysql-connector-java-5.1.27-bin.jar ##job.properties //start:2019-05-17 end:2019-05-18 ,此任务执行周期为1天
nameNode=hdfs://hadoop-senior.ibeifeng.com:8020
jobTracker=hadoop-senior.ibeifeng.com:8032
queueName=default
oozieAppsRoot=user/root/oozie-apps
oozieDataRoot=user/root/oozie/datas oozie.use.system.libpath=true oozie.coord.application.path=${nameNode}/${oozieAppsRoot}/wf-user-select
start=2019-05-17T13:45+0800
end=2019-05-18T14:00+0800
workflowAppUri=${nameNode}/${oozieAppsRoot}/wf-user-select outputDir=wf-user-select/output ##workflow.xml
<workflow-app xmlns="uri:oozie:workflow:0.5" name="wf-user-select">
<start to="hive-node"/> <action name="hive-node">
<hive xmlns="uri:oozie:hive-action:0.5">
<job-tracker>${jobTracker}</job-tracker>
<name-node>${nameNode}</name-node>
<prepare>
<delete path="${nameNode}/${oozieDataRoot}/${outputDir}"/>
</prepare>
<job-xml>${nameNode}/${oozieAppsRoot}/hive-select/hive-site.xml</job-xml>
<configuration>
<property>
<name>mapred.job.queue.name</name>
<value>${queueName}</value>
</property>
</configuration>
<script>select-user.sql</script>
<param>OUTPUT=${nameNode}/${oozieDataRoot}/${outputDir}</param>
</hive>
<ok to="sqoop-node"/>
<error to="fail"/>
</action> <action name="sqoop-node">
<sqoop xmlns="uri:oozie:sqoop-action:0.3">
<job-tracker>${jobTracker}</job-tracker>
<name-node>${nameNode}</name-node>
<configuration>
<property>
<name>mapred.job.queue.name</name>
<value>${queueName}</value>
</property>
</configuration>
<command>export --connect jdbc:mysql://hadoop-senior.ibeifeng.com:3306/test --username root --password 123456 --table my_user --num-mappers 1 --fields-terminated-by "\t" --export-dir /user/root/oozie/datas/wf-user-select/output</command>
</sqoop>
<ok to="end"/>
<error to="fail"/>
</action> ##select-user.sql
--drop table tmp_user
drop table if exists default.tmp_user ; --create table tmp_user
create table default.tmp_user like user_hive location '${OUTPUT}' ; --load data to tmp_user
insert into table tmp_user
select
id, account, password
from
user_hive
where
id >= 15
and
account like 'beif%' ; ##coordinator.xml //每天1点30开始执行,
<coordinator-app name="cron-coord" frequency="30 1 * * *"
start="${start}" end="${end}" timezone="GMT+0800"
xmlns="uri:oozie:coordinator:0.4">
<action>
<workflow>
<app-path>${workflowAppUri}</app-path>
<configuration>
<property>
<name>jobTracker</name>
<value>${jobTracker}</value>
</property>
<property>
<name>nameNode</name>
<value>${nameNode}</value>
</property>
<property>
<name>queueName</name>
<value>${queueName}</value>
</property>
</configuration>
</workflow>
</action>
</coordinator-app> ##hive-site.xml

2、执行

[root@hadoop-senior oozie-apps]# /opt/cdh-5.3.6/hadoop-2.5.0-cdh5.3.6/bin/hdfs dfs -put wf-user-select/ oozie-apps/

[root@hadoop-senior oozie-4.0.0-cdh5.3.6]# bin/oozie job -config oozie-apps/wf-user-select/job.properties -run

1.22-1.24 Oozie企业使用案例的更多相关文章

  1. 7个自定义定时任务并发送消息至邮箱或企业微信案例(crontab和at)

    前言 更好熟悉掌握at.crontab定时自定义任务用法. 实验at.crontab定时自定义任务运用场景案例. 作业.笔记需要. 定时计划任务相关命令及配置文件简要说明 at 工具 由包 at 提供 ...

  2. 《Linux企业应用案例精解(第2版)》新书开始发售

    <Linux企业应用案例精解(第2版)>新书开始发售 650) this.width=650;" title="linux企业应用案例精解 第2版" alt= ...

  3. Jenkins 搭建企业实战案例 (发布与回滚)

    让我们的代码部署变得easy,不再难,Jenkins是一个可扩展的持续集成引擎,是一个开源软件项目,旨在提供一个开放易用的软件平台,使软件的持续集成变成可能.Jenkins非常易于安装和配置,简单易用 ...

  4. 3.awk数组详解及企业实战案例

    awk数组详解及企业实战案例 3.打印数组: [root@nfs-server test]# awk 'BEGIN{array[1]="zhurui";array[2]=" ...

  5. 《Linux企业应用案例精解》一书配套视频发布

    <Linux企业应用案例精解>一书配套视频发布(每周更新视频教程),通过读者平台账号,可以在平台下载AVI格式.所有读者都能获得本书中涉及的软件资料,轻松搭建你的学习环境. 当当购书地址: ...

  6. hadoop 企业应用案例--大众点评

    hadoop 企业应用案例--大众点评 http://f.dataguru.cn/thread-260531-1-1.html

  7. 有关memcached企业面试案例讲解

    有关memcached企业面试案例讲解 1.Memcached是什么,有什么作用?    a. memcached是一个开源的.高性能的内存的缓存软件,从名称上看Mem就是内存的意思,而Cache就是 ...

  8. ESB架构之企业实施案例

    ESB架构之企业实施案例 ESB解决令企业最头痛的信息系统整合问题 SOA 架构中的ESB是更好的应用于异构系统集成整合还是用于统一服务调用/基础服务实施

  9. 大数据技术之_09_Flume学习_Flume概述+Flume快速入门+Flume企业开发案例+Flume监控之Ganglia+Flume高级之自定义MySQLSource+Flume企业真实面试题(重点)

    第1章 Flume概述1.1 Flume定义1.2 Flume组成架构1.2.1 Agent1.2.2 Source1.2.3 Channel1.2.4 Sink1.2.5 Event1.3 Flum ...

随机推荐

  1. GTK入门学习:布局练习之计算器

    接下来,我们做一个布局练习.例如以下图: 我们用表格布局实现,表格布局參考坐标例如以下: 这里我们用到行编辑控件( GtkEntry ). 行编辑的创建: GtkWidget * gtk_entry_ ...

  2. Centos 安装Puppet

    环境说明: OS:CentOS 5.4 i386puppetmaster    192.168.0.12    hostname: puppetmaster.info.comclient       ...

  3. oracle sql 当初始化数据时避免重复主键

    一:当有主键序列自动增长时候(序列为:seq_cct_id) insert into cs_cost_type (CCT_ID, CCT_NAME, CCT_RATE, CCT_RATE_TYPE, ...

  4. 【windows phone】CollectionViewSource的妙用

    在windows phone中绑定集合数据的时候,有时候需要分层数据,通常需要以主从试图形式显示.通常的方法是将第二个ListBox(主视图)的数据源绑定到第一个ListBox (从视图)的Selec ...

  5. springboot中tomcat找不到jsp页面【转载】

    这个原理还没搞明白,只知道是内嵌的tomcat找jsp时默认不读取resources目录,但是具体的默认读取的是哪个目录,打了一下午断点我也没找到.... 修改方式,添加配置修改tomcat的读取目录 ...

  6. jquery 通过ajax 提交表单

    1.需要引入以下两个js文件 <script src="Easyui/jquery-1.7.2.min.js"></script>    <scrip ...

  7. firefox coap安装使用

    coap 插件: 百度搜索firefox coap也能找到该插件https://addons.mozilla.org/zh-CN/firefox/addon/copper-270430/在firefo ...

  8. appium(3)-Running Tests

    Running Tests   Preparing your app for test (iOS) Test apps run on the simulator have to be compiled ...

  9. h5 placeholder 设置无效

    下面设置方式无效: ::-webkit-input-placeholder { /* WebKit browsers */ color: #999; } :-moz-placeholder { /* ...

  10. Python类的特殊属性

    Python中的特殊属性 定义如下类: class Foo(object): """Foo class definition""" 类的特殊 ...