Reply
Highlighted
New Contributor
Posts: 1
Registered: ‎04-03-2018

Creating / Running Sqoop Job in Shell Action Using Oozie

[ Edited ]

I'm trying to run a Sqoop job in Shell script using Oozie. Please note, that i'm using cdh5 in my local machine (vm with 12G of RAM), and HUE to build the workflow.

I created a Sqoop job that extracts data from Mysql to HDFS, in a shell script. And I run it using 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

The Job has been created (I can find it when I do a list cmd, see bellow):

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

1.png

 

I even executed the job from my terminal and it works (see cmd below):

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

I deleted the last imported folder, and tried to re-execute the job again but this time in Oozie (in shell action). It gives an error (see below):

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]

Here is the 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>

Here is the 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"/>

 

Here is a view from HUE: 

2.png

 

The reason why i'm trying to run a sqoop job in shell script from Oozie, is that I want to create a sqoop job that remenbers the last value imported so that it can increment the table, and then schedule it using Oozie. So this is just a first step test!

 

Can you please help ? Thanks,

Cloudera Employee
Posts: 70
Registered: ‎04-03-2017

Re: Creating / Running Sqoop Job in Shell Action Using Oozie

Hi,

 

Can you please share the job logs from YARN page? Or you can run the below command.

 

--> yarn logs -applicationId <application ID> -appOwner <AppOwner>

 

This will tell us more info that why the job is failing.

 

Regards

Nitish