无法在 Oozie 的 Sqoop 工作流中加载 HiveConf

Could not load HiveConf in Sqoop workflow in Oozie

我在 Oozie 中创建了一个 Sqoop 工作流,用于将数据从 MySQL sqoop 到 Hive table。

如果我在终端中 运行 Sqoop 作业,它 运行 很好并且数据已成功插入 Hive table,但是如果我将作业放在 Oozie 中并且 运行 它,它给我一个错误:

Could not load org.apache.hadoop.hive.conf.HiveConf. Make sure HIVE_CONF_DIR is set correctly.

Encountered IOException running import job: java.io.IOException: java.lang.ClassNotFoundException: org.apache.hadoop.hive.conf.HiveConf

谁能帮我解决这个问题?

我这里使用的是 HDP 2.5。

下面是我的 Oozie 属性文件:

nameNode=hdfs://master.nodes:8020
jobTracker=master.nodes:8050
queueName=default
examplesRoot=jas-oozie

oozie.use.system.libpath=true
oozie.libpath=${nameNode}/user/oozie/share/lib
oozie.action.sharelib.for.pig=hive,pig,hcatalog
oozie.action.sharelib.for.hive=pig,hcatalog,atlas,hive

oozie.wf.application.path=${nameNode}/user/${user.name}/${examplesRoot}/jas-oozie-workflow.xml
outputDir=jas

以下是 Oozie 的 xml 文件:

<?xml version="1.0" encoding="UTF-8"?>

<workflow-app xmlns="uri:oozie:workflow:0.2" name="jas-import-wf">
    <start to="sqoop-import-air-quality-node"/>

    <action name="sqoop-import-air-quality-node">
        <sqoop xmlns="uri:oozie:sqoop-action:0.2">
            <job-tracker>${jobTracker}</job-tracker>
            <name-node>${nameNode}</name-node>
            <prepare>
                <delete path="${nameNode}/user/${wf:user()}/${examplesRoot}/output-data"/>
                <!-- <mkdir path="${nameNode}/user/${wf:user()}/${examplesRoot}/output-data"/> -->
            </prepare>
            <configuration>
                <property>
                    <name>mapred.job.queue.name</name>
                    <value>${queueName}</value>
                </property>
            </configuration>
            <arg>import</arg>
            <arg>--connect</arg>
            <arg>jdbc:mysql://xx.xx.xx.xx:3306/xxxx?dontTrackOpenResources=true&amp;defaultFetchSize=1000&amp;useCursorFetch=true&amp;zeroDateTimeBehavior=convertToNull</arg>
            <arg>--driver</arg>
            <arg>com.mysql.jdbc.Driver</arg>
            <arg>--username</arg>
            <arg>xx</arg>
            <arg>--password</arg>
            <arg>xx</arg>
            <arg>--query</arg>
            <arg>
                select <fields> from <table> where $CONDITIONS
            </arg>
            <arg>--hive-import</arg>
            <arg>--hive-drop-import-delims</arg>
            <arg>--hive-overwrite</arg>
            <arg>--hive-table</arg>
            <arg>table</arg>
            <arg>--target-dir</arg>
            <arg>/user/${wf:user()}/${examplesRoot}/output-data/sqoop-import</arg>
            <arg>-m</arg>
            <arg>1</arg>
        </sqoop>
        <ok to="end"/>
        <error to="import-air-quality-fail"/>
    </action>

    <kill name="import-air-quality-fail">
        <message>Sqoop from ICP failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
    </kill>

    <end name="end"/>
</workflow-app>

谢谢。

1) 在路径 ${nameNode}/user/${user.name}/${examplesRoot}/

中创建目录 lib

2) 在 ${nameNode}/user/${user.name}/${examplesRoot}/lib/ 路径中添加 hive-exec jar 并重试