高可用Hadoop平台-Oozie工作流

1.概述

  在开发Hadoop的相关应用使用,在业务不复杂,任务不多的情况下,我们可以直接使用Crontab去完成相关应用的调度。今天给大家介绍的是统一管理各种调度任务的系统,下面为今天分享的内容目录:

  • 内容介绍
  • Oozie Server
  • 截图预览

  下面开始今天的内容分享。

2.内容介绍

  今天的内容不涉及Oozie的具体细节操作,它的工作流程在下一篇博客为大家详细介绍。今天主要给大家分享Oozie的作用,它的集成步骤等内容。

2.1 作用

  Oozie它是一个开源的工作流调度系统,它可以管理逻辑复杂的多个Hadoop作业任务,按照指定的顺序将其进行协同工作。比如说,我们日常的工作场景:

  1. 收集数据到HDFS
  2. 编写MR去清洗数据,生成新的数据存放到指定的HDFS路径下
  3. 创建Hive表分区,并加载数据到对应的表分区
  4. 使用HQL进行业务指标统计,并将统计的结果输出到对应的Hive大表当中
  5. 对统计后的大表当中的数据进行数据导出共外界业务去调用使用

  通过上述的日常工作流程,我们可以编写工作流系统,生成一个工作流实例,然后每天定时去运行实例即可。针对这样一种Hadoop的应用场景,Oozie能够简化我们的任务调度并执行。

2.2 基础环境

  本次给大家分享的基础环境是:

Name   Value
操作系统 CentOS6.6
工作流 Oozie4.2
Hadoop 2.6

  

 

 

 

  以上便是本篇博客需依赖的基础环境。另外还需要用到JDK,Maven,MySQL驱动文件等。

3.Oozie Server

  Oozie Server能够为我们提供便捷的Job管理功能,可以通过其可视化界面去管理Job的运行状态,当然也支持构建复杂的Hadoop Job流程,各个Job之间的依赖关系可以通过工作流进行配置,由Oozie Server统一去执行。

3.1 依赖包准备

  • Maven

  下载安装Maven环境,命令如下所示:

wget http://mirrors.hust.edu.cn/apache/maven/maven-3/3.3.3/binaries/apache-maven-3.3.3-bin.tar.gz

tar -zxvf apache-maven-3.3.3-bin.tar.gz

  接着添加环境变量,如下所示:

export M2_HOME=/home/hadoop/maven-3.3.3
export PATH=$PATH:$ES_HOME/bin

  然后输入一下命令使之立即生效:



. /etc/profile

  最后,我们输入 mvn -version 命令,若能现实对应的Maven版本号,即表示Maven环境集成OK。

  • MySQL

  关于 MySQL 数据库的安装配置较为简单,这里就不多做赘述了。

  • Tomcat

  由于Oozie会用其Web容器,这里需要安装Tomcat Web服务器,可以到Apache的官网下载对应的安装包,这里不多做赘述。

  • ExtJS工具包

  在可视化会依赖该工具包,所以这里我们需要下载其工具,下载地址我们可以在Oozie的DG_QuickStart页面找到,如下图所示:

高可用Hadoop平台-Oozie工作流

  地址如下所示:



wget http://dev.sencha.com/deploy/ext-2.2.zip
  • Oozie

  这里我们可以在Oozie的官网下载其安装包,下载地址:



wget http://mirrors.cnnic.cn/apache/oozie/4.2.0/oozie-4.2.0.tar.gz

3.2 Oozie集成

  在准备好环境后,接下来,我们去集成Oozie。首先,我们将下载的Oozie安装包进行解压,然后,使用Maven命令对其进行打包。操作命令如下所示:

# 解压
tar -zxvf oozie-4.2.0.tar.gz

# 进入
cd oozie-4.2.0

# 打包
mvn clean package assembly:single -DskipTests

  注意:这里需要对pom文件进行修改,将JDK、Hadoop、HBase、Hive等组件的版本号进行统一,与你使用的版本号一致即可。

  成功后出现以下图所示:

高可用Hadoop平台-Oozie工作流

  生成的路径地址如下所示:



/home/hadoop/oozie-4.2.0/distro/target/oozie-4.2.0-distro/oozie-4.2.0

  此时,我们修改Oozie的环境变量,如下所示:

export OOZIE_HOME=/home/hadoop/oozie-4.2.0/distro/target/oozie-4.2.0-distro/oozie-4.2.0
export PATH=$PATH:$OOZIE_HOME/bin

  接着,我们在$OOZIE_HOME目录下创建一个文件夹用于存放ExtJS和Hadoop的JAR文件,这里我们将前面下载的ExtJS的压 缩包和Hadoop的Share目录下的JAR文件拷贝到libext文件夹下即可。由于,我们使用了MySQL来存储Oozie的元数据,所以需要用到 MySQL的驱动包,因而,我们需要将MySQL的驱动包拷贝到libext目录下。

  在准备完这些后,下面我们开始安装,命令如下所示:

# 进入$OOZIE_HOME/bin目录
./oozie-setup.sh prepare-war

  生成以下信息,表示成功,内容如下所示:

[hadoop@nna bin]$ ./oozie-setup.sh prepare-war
  setting CATALINA_OPTS="$CATALINA_OPTS -Xmx1024m"

INFO: Adding extension: /home/hadoop/oozie-4.2.0/distro/target/oozie-4.2.0-distro/oozie-4.2.0/libext/commons-configuration-1.6.jar
INFO: Adding extension: /home/hadoop/oozie-4.2.0/distro/target/oozie-4.2.0-distro/oozie-4.2.0/libext/hadoop-auth-2.6.0.jar
INFO: Adding extension: /home/hadoop/oozie-4.2.0/distro/target/oozie-4.2.0-distro/oozie-4.2.0/libext/hadoop-common-2.6.0.jar
INFO: Adding extension: /home/hadoop/oozie-4.2.0/distro/target/oozie-4.2.0-distro/oozie-4.2.0/libext/hadoop-common-2.6.0-tests.jar
INFO: Adding extension: /home/hadoop/oozie-4.2.0/distro/target/oozie-4.2.0-distro/oozie-4.2.0/libext/hadoop-hdfs-2.6.0.jar
INFO: Adding extension: /home/hadoop/oozie-4.2.0/distro/target/oozie-4.2.0-distro/oozie-4.2.0/libext/hadoop-hdfs-2.6.0-tests.jar
INFO: Adding extension: /home/hadoop/oozie-4.2.0/distro/target/oozie-4.2.0-distro/oozie-4.2.0/libext/hadoop-hdfs-nfs-2.6.0.jar
INFO: Adding extension: /home/hadoop/oozie-4.2.0/distro/target/oozie-4.2.0-distro/oozie-4.2.0/libext/hadoop-mapreduce-client-app-2.6.0.jar
INFO: Adding extension: /home/hadoop/oozie-4.2.0/distro/target/oozie-4.2.0-distro/oozie-4.2.0/libext/hadoop-mapreduce-client-common-2.6.0.jar
INFO: Adding extension: /home/hadoop/oozie-4.2.0/distro/target/oozie-4.2.0-distro/oozie-4.2.0/libext/hadoop-mapreduce-client-core-2.6.0.jar
INFO: Adding extension: /home/hadoop/oozie-4.2.0/distro/target/oozie-4.2.0-distro/oozie-4.2.0/libext/hadoop-mapreduce-client-hs-2.6.0.jar
INFO: Adding extension: /home/hadoop/oozie-4.2.0/distro/target/oozie-4.2.0-distro/oozie-4.2.0/libext/hadoop-mapreduce-client-hs-plugins-2.6.0.jar
INFO: Adding extension: /home/hadoop/oozie-4.2.0/distro/target/oozie-4.2.0-distro/oozie-4.2.0/libext/hadoop-mapreduce-client-jobclient-2.6.0.jar
INFO: Adding extension: /home/hadoop/oozie-4.2.0/distro/target/oozie-4.2.0-distro/oozie-4.2.0/libext/hadoop-mapreduce-client-jobclient-2.6.0-tests.jar
INFO: Adding extension: /home/hadoop/oozie-4.2.0/distro/target/oozie-4.2.0-distro/oozie-4.2.0/libext/hadoop-mapreduce-client-shuffle-2.6.0.jar
INFO: Adding extension: /home/hadoop/oozie-4.2.0/distro/target/oozie-4.2.0-distro/oozie-4.2.0/libext/hadoop-mapreduce-examples-2.6.0.jar
INFO: Adding extension: /home/hadoop/oozie-4.2.0/distro/target/oozie-4.2.0-distro/oozie-4.2.0/libext/hadoop-nfs-2.6.0.jar
INFO: Adding extension: /home/hadoop/oozie-4.2.0/distro/target/oozie-4.2.0-distro/oozie-4.2.0/libext/hadoop-yarn-api-2.6.0.jar
INFO: Adding extension: /home/hadoop/oozie-4.2.0/distro/target/oozie-4.2.0-distro/oozie-4.2.0/libext/hadoop-yarn-applications-distributedshell-2.6.0.jar
INFO: Adding extension: /home/hadoop/oozie-4.2.0/distro/target/oozie-4.2.0-distro/oozie-4.2.0/libext/hadoop-yarn-applications-unmanaged-am-launcher-2.6.0.jar
INFO: Adding extension: /home/hadoop/oozie-4.2.0/distro/target/oozie-4.2.0-distro/oozie-4.2.0/libext/hadoop-yarn-client-2.6.0.jar
INFO: Adding extension: /home/hadoop/oozie-4.2.0/distro/target/oozie-4.2.0-distro/oozie-4.2.0/libext/hadoop-yarn-common-2.6.0.jar
INFO: Adding extension: /home/hadoop/oozie-4.2.0/distro/target/oozie-4.2.0-distro/oozie-4.2.0/libext/hadoop-yarn-registry-2.6.0.jar
INFO: Adding extension: /home/hadoop/oozie-4.2.0/distro/target/oozie-4.2.0-distro/oozie-4.2.0/libext/hadoop-yarn-server-applicationhistoryservice-2.6.0.jar
INFO: Adding extension: /home/hadoop/oozie-4.2.0/distro/target/oozie-4.2.0-distro/oozie-4.2.0/libext/hadoop-yarn-server-common-2.6.0.jar
INFO: Adding extension: /home/hadoop/oozie-4.2.0/distro/target/oozie-4.2.0-distro/oozie-4.2.0/libext/hadoop-yarn-server-nodemanager-2.6.0.jar
INFO: Adding extension: /home/hadoop/oozie-4.2.0/distro/target/oozie-4.2.0-distro/oozie-4.2.0/libext/hadoop-yarn-server-resourcemanager-2.6.0.jar
INFO: Adding extension: /home/hadoop/oozie-4.2.0/distro/target/oozie-4.2.0-distro/oozie-4.2.0/libext/hadoop-yarn-server-tests-2.6.0.jar
INFO: Adding extension: /home/hadoop/oozie-4.2.0/distro/target/oozie-4.2.0-distro/oozie-4.2.0/libext/hadoop-yarn-server-web-proxy-2.6.0.jar
INFO: Adding extension: /home/hadoop/oozie-4.2.0/distro/target/oozie-4.2.0-distro/oozie-4.2.0/libext/mysql-connector-java-5.1.32-bin.jar

New Oozie WAR file with added 'ExtJS library, JARs' at /home/hadoop/oozie-4.2.0/distro/target/oozie-4.2.0-distro/oozie-4.2.0/oozie-server/webapps/oozie.war


INFO: Oozie is ready to be started

  若失败,可根据提示做对应的处理。

  这样,我们在/home/hadoop/oozie-4.2.0/distro/target/oozie-4.2.0-distro/oozie-4.2.0/oozie-server/webapps目录下就生成了oozie.war文件。

3.3 配置Oozie

  我们在$OOZIE_HOME/conf目录下修改oozie-site.xml文件,内容如下所示:

<property>
        <name>oozie.service.JPAService.jdbc.driver</name>
            <value>com.mysql.jdbc.Driver</value>
         <description>JDBC driver class. </description>
    </property>
    <property>
         <name>oozie.service.JPAService.jdbc.url</name>
         <value>jdbc:mysql://nna:3306/oozie</value>
         <description>JDBC URL.</description>
    </property>
    <property>
        <name>oozie.service.JPAService.jdbc.username</name>
         <value>root</value>
         <description>DB user name.</description>
    </property>
    <property>
         <name>oozie.service.JPAService.jdbc.password</name>
         <value>root</value>
         <description>DB user password.</description> 
   </property>

  这里我们使用手动去创建数据库,oozie.service.JPAService.create.db.schema若为true属性,即表示去自动创建。手动创建脚本如下所示:

CREATE DATABASE oozie;
GRANT ALL ON oozie.* TO 'root'@'nna' IDENTIFIED BY 'root';
FLUSH PRIVILEGES;

  然后,我们使用以下命令,生成数据表:

#在$OOZIE_HOME/bin目录下操作
./ooziedb.sh create -sqlfile oozie.sql -run

  生成以下内容:

[hadoop@nna bin]$ ./ooziedb.sh create -sqlfile oozie.sql -run
  setting CATALINA_OPTS="$CATALINA_OPTS -Xmx1024m"

Validate DB Connection
DONE
DB schema does not exist
Check OOZIE_SYS table does not exist
DONE
Create SQL schema
DONE
Create OOZIE_SYS table
DONE

Oozie DB has been created for Oozie version '4.2.0'


The SQL commands have been written to: oozie.sql

  若执行正常,会生成oozie.sql的脚本,如下图所示:
高可用Hadoop平台-Oozie工作流

3.4 启动

  接下来,我们去启动Oozie,命令如下所示:

# 在$OOZIE_HOME/bin目录下 
./oozie-start.sh

  正常启动内容如下所示:

[hadoop@nna bin]$ ./oozie-start.sh 
WARN: Use of this script is deprecated; use 'oozied.sh start' instead

Setting OOZIE_HOME:          /home/hadoop/oozie-4.2.0/distro/target/oozie-4.2.0-distro/oozie-4.2.0
Setting OOZIE_CONFIG:        /home/hadoop/oozie-4.2.0/distro/target/oozie-4.2.0-distro/oozie-4.2.0/conf
Sourcing:                    /home/hadoop/oozie-4.2.0/distro/target/oozie-4.2.0-distro/oozie-4.2.0/conf/oozie-env.sh
  setting CATALINA_OPTS="$CATALINA_OPTS -Xmx1024m"
Setting OOZIE_CONFIG_FILE:   oozie-site.xml
Setting OOZIE_DATA:          /home/hadoop/oozie-4.2.0/distro/target/oozie-4.2.0-distro/oozie-4.2.0/data
Setting OOZIE_LOG:           /home/hadoop/oozie-4.2.0/distro/target/oozie-4.2.0-distro/oozie-4.2.0/logs
Setting OOZIE_LOG4J_FILE:    oozie-log4j.properties
Setting OOZIE_LOG4J_RELOAD:  10
Setting OOZIE_HTTP_HOSTNAME: nna
Setting OOZIE_HTTP_PORT:     11000
Setting OOZIE_ADMIN_PORT:     11001
Setting OOZIE_HTTPS_PORT:     11443
Setting OOZIE_BASE_URL:      http://nna:11000/oozie
Setting CATALINA_BASE:       /home/hadoop/oozie-4.2.0/distro/target/oozie-4.2.0-distro/oozie-4.2.0/oozie-server
Setting OOZIE_HTTPS_KEYSTORE_FILE:     /home/hadoop/.keystore
Setting OOZIE_HTTPS_KEYSTORE_PASS:     password
Setting OOZIE_INSTANCE_ID:       nna
Setting CATALINA_OUT:        /home/hadoop/oozie-4.2.0/distro/target/oozie-4.2.0-distro/oozie-4.2.0/logs/catalina.out
Setting CATALINA_PID:        /home/hadoop/oozie-4.2.0/distro/target/oozie-4.2.0-distro/oozie-4.2.0/oozie-server/temp/oozie.pid

Using   CATALINA_OPTS:        -Xmx1024m -Dderby.stream.error.file=/home/hadoop/oozie-4.2.0/distro/target/oozie-4.2.0-distro/oozie-4.2.0/logs/derby.log
Adding to CATALINA_OPTS:     -Doozie.home.dir=/home/hadoop/oozie-4.2.0/distro/target/oozie-4.2.0-distro/oozie-4.2.0 -Doozie.config.dir=/home/hadoop/oozie-4.2.0/distro/target/oozie-4.2.0-distro/oozie-4.2.0/conf -Doozie.log.dir=/home/hadoop/oozie-4.2.0/distro/target/oozie-4.2.0-distro/oozie-4.2.0/logs -Doozie.data.dir=/home/hadoop/oozie-4.2.0/distro/target/oozie-4.2.0-distro/oozie-4.2.0/data -Doozie.instance.id=nna -Doozie.config.file=oozie-site.xml -Doozie.log4j.file=oozie-log4j.properties -Doozie.log4j.reload=10 -Doozie.http.hostname=nna -Doozie.admin.port=11001 -Doozie.http.port=11000 -Doozie.https.port=11443 -Doozie.base.url=http://nna:11000/oozie -Doozie.https.keystore.file=/home/hadoop/.keystore -Doozie.https.keystore.pass=password -Djava.library.path=

Setting up oozie DB
  setting CATALINA_OPTS="$CATALINA_OPTS -Xmx1024m"

Validate DB Connection
DONE
DB schema exists

The SQL commands have been written to: /tmp/ooziedb-9100396876446618885.sql

Using CATALINA_BASE:   /home/hadoop/oozie-4.2.0/distro/target/oozie-4.2.0-distro/oozie-4.2.0/oozie-server
Using CATALINA_HOME:   /home/hadoop/oozie-4.2.0/distro/target/oozie-4.2.0-distro/oozie-4.2.0/oozie-server
Using CATALINA_TMPDIR: /home/hadoop/oozie-4.2.0/distro/target/oozie-4.2.0-distro/oozie-4.2.0/oozie-server/temp
Using JRE_HOME:        /usr/java/jdk1.7
Using CLASSPATH:       /home/hadoop/oozie-4.2.0/distro/target/oozie-4.2.0-distro/oozie-4.2.0/oozie-server/bin/bootstrap.jar
Using CATALINA_PID:    /home/hadoop/oozie-4.2.0/distro/target/oozie-4.2.0-distro/oozie-4.2.0/oozie-server/temp/oozie.pid

4.截图预览

  然后,我们可以输入浏览地址,查看是否启动正常,如下图所示:

高可用Hadoop平台-Oozie工作流

5.总结

  关于Oozie的集成,会有点繁琐,本篇博客只是针对单独的Oozie去集成,后续博客会给大家介绍Oozie集成到Hadoop集群,以及相关工作流的用法介绍等。

6.结束语

  这篇博客就和大家分享到这里,如果大家在研究学习的过程当中有什么问题,可以加群进行讨论或发送邮件给我,我会尽我所能为您解答,与君共勉!

上一篇:SpringBoot自注册定时任务


下一篇:深入分析:12C ASM Normal冗余中PDB文件块号与AU关系与恢复