1

我正在尝试使用 Oozie 在 Shell 脚本中运行 Sqoop 作业。请注意,我在本地机器(具有 12G RAM 的 vm)中使用 cdh5,并使用 HUE 来构建工作流程。

我在 shell 脚本中创建了一个 Sqoop 作业,该作业将数据从 Mysql 提取到 HDFS。我使用 Oozie 运行它:

sqoop job --create testmetastore --meta-connect jdbc:hsqldb:hsql://localhost:16000/sqoop -- import --connect jdbc:mysql://localhost:3306/retail_db --table EMPLOYEE --username root --password cloudera --target-dir hdfs://localhost:8020/user/cloudera/EMPLOYEES -m 1

Job 已创建(我可以在执行 list cmd 时找到它,见下文):

sqoop job --list --meta-connect jdbc:hsqldb:hsql://localhost:16000/sqoop

sqoop 作业 --list

我什至从我的终端执行了这项工作并且它可以工作(见下面的 cmd):

sqoop job --meta-connect jdbc:hsqldb:hsql://localhost:16000/sqoop --exec testmetastore

我删除了最后一个导入的文件夹,并尝试再次执行该作业,但这次是在 Oozie 中。它给出了一个错误(见下文):

18/12/23 10:47:06 INFO mapreduce.ImportJobBase: counters are unavailable. To get this information, 
18/12/23 10:47:06 INFO mapreduce.ImportJobBase: you will need to enable the completed job store on 
18/12/23 10:47:06 INFO mapreduce.ImportJobBase: the jobtracker with:
18/12/23 10:47:06 INFO mapreduce.ImportJobBase: mapreduce.jobtracker.persist.jobstatus.active = true
18/12/23 10:47:06 INFO mapreduce.ImportJobBase: mapreduce.jobtracker.persist.jobstatus.hours = 1
18/12/23 10:47:06 INFO mapreduce.ImportJobBase: A jobtracker restart is required for these settings
18/12/23 10:47:06 INFO mapreduce.ImportJobBase: to take effect.
18/12/23 10:47:06 ERROR tool.ImportTool: Import failed: Import job failed!
Failing Oozie Launcher, Main class [org.apache.oozie.action.hadoop.ShellMain], exit code [1]

这是 sqoop-site.xml:

          <property>
    <name>sqoop.metastore.client.enable.autoconnect</name>
    <value>false</value>
    <description>If true, Sqoop will connect to a local metastore
      for job management when no other metastore arguments are
      provided.
    </description>
  </property>

  <property>
    <name>sqoop.metastore.client.autoconnect.url</name>
    <value>jdbc:hsqldb:hsql://localhost:16000</value>
    <description>The connect string to use when connecting to a
      job-management metastore. If unspecified, uses ~/.sqoop/.
      You can specify a different path here.
    </description>
  </property>
  <property>
    <name>sqoop.metastore.client.autoconnect.username</name>
    <value>SA</value>
    <description>The username to bind to the metastore.
    </description>
  </property>
  <property>
    <name>sqoop.metastore.client.autoconnect.password</name>
    <value></value>
    <description>The password to bind to the metastore.
    </description>
  </property>

  <property>
    <name>sqoop.metastore.client.record.password</name>
    <value>true</value>
    <description>If true, allow saved passwords in the metastore.
    </description>
  </property>

  <property>
    <name>sqoop.metastore.server.location</name>
    <value>/tmp/sqoop-metastore/shared.db</value>
    <description>Path to the shared metastore database files.
    If this is not set, it will be placed in ~/.sqoop/.
    </description>
  </property>

  <property>
    <name>sqoop.metastore.server.port</name>
    <value>16000</value>
    <description>Port that this metastore should listen on.
    </description>
  </property>

这是workflow.xml:

<workflow-app name="MyWorkflow" xmlns="uri:oozie:workflow:0.5">
<start to="shell-7268"/>
<kill name="Kill">
    <message>Action failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
</kill>
<action name="shell-7268">
    <shell xmlns="uri:oozie:shell-action:0.1">
        <job-tracker>${jobTracker}</job-tracker>
        <name-node>${nameNode}</name-node>
        <exec>/user/cloudera/sqpexec.sh</exec>
        <file>/user/cloudera/sqpexec.sh#sqpexec.sh</file>
        <file>/user/cloudera/sqoop-site.xml#sqoop-site.xml</file>
          <capture-output/>
    </shell>
    <ok to="End"/>
    <error to="Kill"/>
</action>
<end name="End"/>

这是 HUE 的视图:HUE 中的工作流程

我试图在 Oozie 的 shell 脚本中运行 sqoop 作业的原因是,我想创建一个 sqoop 作业来记住最后导入的值,以便它可以增加表,然后使用 Oozie 对其进行调度。所以这只是第一步测试!

你能帮忙吗?谢谢,

4

0 回答 0