The Hortonworks Community Connection is now live. A completely rebuilt Q&A forum, Knowledge Base, Code Hub and more, backed by the experts in the industry.

You will be redirected here in 10 seconds. If your are not redirected, click here to visit the new site.

The legacy Hortonworks Forum is now closed. You can view a read-only version of the former site by clicking here. The site will be taken offline on January 31,2016

Hortonworks Sandbox Forum

Oozie-Sqoop job not working

  • #48673
    Ajay Chitre
    Participant

    When I run ‘Sqoop’ from command line it works fine, but when I run it via Oozie job it just keeps showing the following message:

    2014-02-12 19:04:47,854 DEBUG DefinitionXCommand:545 – USER[root] GROUP[-] TOKEN[] APP[sqoop] JOB[0000004-140211210850200-oozie-oozi-W] ACTION[-] Execute command [definition] key [0000004-140211210850200-oozie-oozi-W]

    My workflow.xml looks like this:

    <workflow-app name=”sqoop” xmlns=”uri:oozie:workflow:0.1″>
    <start to=”etl” />
    <action name=”etl”>
    <sqoop xmlns=”uri:oozie:sqoop-action:0.2″>
    <job-tracker>${jobTracker}</job-tracker>
    <name-node>${nameNode}</name-node>
    <prepare>
    <delete path=”${outputBaseDir}/${tableName}/${period}” />
    </prepare>
    <configuration>
    <property>
    <name>mapred.compress.map.output</name>
    <value>true</value>
    </property>
    </configuration>
    <arg>import</arg>
    <arg>–connect</arg>
    <arg>jdbc:mysql://${mysqlHost}/${mysqlDb}</arg>
    <arg>–username</arg>
    <arg>root</arg>
    <arg>–target-dir</arg>
    <arg>${outputBaseDir}/${tableName}/${period}</arg>
    <arg>–query</arg>
    <arg>${query}</arg>
    <arg>–split-by</arg>
    <arg>${splitBy}</arg>
    <arg>-m</arg>
    <arg>1</arg>
    </sqoop>
    <ok to=”end” />
    <error to=”fail” />
    </action>
    <kill name=”fail”>
    <message>Script failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
    </kill>
    <end name=’end’ />
    </workflow-app>

    job.properties looks like this:

    nameNode=hdfs://10.0.2.15:8020
    jobTracker=10.0.2.15:8021
    queueName=default

    mysqlHost=10.0.2.15
    mysqlDb=test

    outputBaseDir=/user/ajay
    tableName=temperatures
    period=2014010200
    query=select *, DATE_FORMAT(created_time, ‘%Y%m%d%H’) as period from ${tableName} where DATE_FORMAT(created_time, ‘%Y%m%d%H’) = ${period} and \\$CONDITIONS
    splitBy=id

    oozie.wf.application.path=${nameNode}/user/ajay/workflow.xml
    outputDir=sqoop-output

    Started the job under Sandbox like this:
    oozie job -config ./job.properties -run

    The following works from command line:
    sqoop import –connect jdbc:mysql://10.0.2.15/test –username root –target-dir $OUTPUT_DIR –query “select *, DATE_FORMAT(created_time, ‘%Y%m%d%H’) as period from $TABLE_NAME where DATE_FORMAT(created_time, ‘%Y%m%d%H’) = $PERIOD and \$CONDITIONS” –split-by id

    What am I doing wrong? Please help. Thanks.

  • Author
    Replies
  • #48674
    Ajay Chitre
    Participant

    Just to add some more info. The action remains in a ‘PREP’ status. Like this:

    Actions
    ————————————————————————————————————————————
    ID Status Ext ID Ext Status Err Code
    ————————————————————————————————————————————
    0000009-140211210850200-oozie-oozi-W@:start: OK – OK –
    ————————————————————————————————————————————
    0000009-140211210850200-oozie-oozi-W@etl PREP – – –
    ————————————————————————————————————————————

    #48738
    Ajay Chitre
    Participant

    Answering my question myself. May help someone in future. It worked when I did the following:

    1) ssh root@127.0.0.1 -p 2222 (Password: hadoop)
    2) ssh hue@sandbox (Password: hadoop)
    3) Used the following job.properties:

    user.name=hue
    nameNode=hdfs://sandbox.hortonworks.com:8020
    jobTracker=sandbox.hortonworks.com:8050
    queueName=default

    mysqlHost=10.0.2.15
    mysqlDb=test

    outputBaseDir=/user/hue/ajay
    tableName=temperatures
    period=2014010101
    query=select *, DATE_FORMAT(created_time, ‘%Y%m%d%H’) as period from ${tableName} where DATE_FORMAT(created_time, ‘%Y%m%d%H’) = ${period} and $CONDITIONS
    splitBy=id

    oozie.wf.application.path=${nameNode}/user/hue/ajay/workflows/workflow.xml
    oozie.use.system.libpath=true
    mapreduce.job.user.name=hue

    4) Added the following to workflow.xml
    <archive>/user/ajay/mysql-connector-java.jar#mysql-connector-java.jar</archive>

    So the workflow.xml looks like this:

    <workflow-app name=”sqoop” xmlns=”uri:oozie:workflow:0.1″>
    <start to=”etl” />
    <action name=”etl”>
    <sqoop xmlns=”uri:oozie:sqoop-action:0.2″>
    <job-tracker>${jobTracker}</job-tracker>
    <name-node>${nameNode}</name-node>
    <prepare>
    <delete path=”${nameNode}/${outputBaseDir}/${tableName}/${period}” />
    </prepare>
    <configuration>
    <property>
    <name>mapred.compress.map.output</name>
    <value>true</value>
    </property>
    </configuration>
    <arg>import</arg>
    <arg>–connect</arg>
    <arg>jdbc:mysql://${mysqlHost}/${mysqlDb}</arg>
    <arg>–username</arg>
    <arg>root</arg>
    <arg>–target-dir</arg>
    <arg>${nameNode}/${outputBaseDir}/${tableName}/${period}</arg>
    <arg>–query</arg>
    <arg>${query}</arg>
    <arg>–split-by</arg>
    <arg>${splitBy}</arg>
    <archive>/user/ajay/mysql-connector-java.jar#mysql-connector-java.jar</archive>
    </sqoop>
    <ok to=”end” />
    <error to=”fail” />
    </action>
    <kill name=”fail”>
    <message>Script failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
    </kill>
    <end name=’end’ />
    </workflow-app>

    5) oozie -config job.properties -run

The forum ‘Hortonworks Sandbox’ is closed to new topics and replies.

Support from the Experts

A HDP Support Subscription connects you experts with deep experience running Apache Hadoop in production, at-scale on the most demanding workloads.

Enterprise Support »

Become HDP Certified

Real world training designed by the core architects of Hadoop. Scenario-based training courses are available in-classroom or online from anywhere in the world

Training »

Hortonworks Data Platform
The Hortonworks Data Platform is a 100% open source distribution of Apache Hadoop that is truly enterprise grade having been built, tested and hardened with enterprise rigor.
Get started with Sandbox
Hortonworks Sandbox is a self-contained virtual machine with Apache Hadoop pre-configured alongside a set of hands-on, step-by-step Hadoop tutorials.
Modern Data Architecture
Tackle the challenges of big data. Hadoop integrates with existing EDW, RDBMS and MPP systems to deliver lower cost, higher capacity infrastructure.