Community Articles
Find and share helpful community-sourced technical articles
Labels (2)
Rising Star


I've compiled this article after I struggled quiet a bit to have the ingestion working.

Credits to @Kuldeep Kulkarni, @Rahul Pathak and @awhitter for helping me figuring out these steps.

Feel free to contact me. I'll make sure to keep this up-to-date.

Sqoop is the tool of choice for ingesting OLTP data to HDFS of Hive. Incremental ingestion requires to keep track of the last row ingested in order to know where to start the next round from. Using a shared Sqoop metastore and sqoop job will let sqoop take care of keeping track of the ingestion.

Oozie will be setup to call the sqoop job at the required interval of time. For this a coordinator will be required,

1 Sqoop

1a. Shared Metastore

Create a Sqoop metastore on a node (preferably not on a data/worker node).

- Create a folder to save the metastore DB file (e.g. "/var/lib/sqoop/metastore)

- configure the Metastore from Ambari > Sqoop > Configs

sqoop.metastore.server.location "/var/lib/sqoop/metastore/shared.db"
sqoop.metastore.client.record.password "true" 
sqoop.metastore.server.port "17000"
sqoop.metastore.client.autoconnect.url "jdbc:hsqldb:hsql://<Metastore_node>:17000/sqoop

Start the Sqoop-Metastore process

"nohup sqoop-metastore &>>/var/log/sqoop-metastore.log &"

Sqoop unfortunately does not offer OS Service (yet). So ensure that the metastore startup command is added to your startup scripts

1b. Sqoop job


Active directory authentication is not support yet. The user must be a SQL user.

As Sqoop will store the credentails in clear, the user must be created with the least privileges possible and monitored accordingly

while testing using AD integratio (";Integrated Security=SSPI" in the connection string), connection has been successful, however it's not (yet) a HWX supported situation

sqoop-job --create <JobName>  \
--meta-connect jdbc:hsqldb:hsql://<metastore_node>:17000/sqoop \
-- import \
--connect "jdbc:sqlserver://<SQLSERVER>:1433;database=<SQLDB>;" \
--username <username>  \
--password <password> \
--num-mappers 5 \
--table <SQL TableName>\
--append \
--incremental append \
--check-column <Base Column for incremental>\
--hive-import \
--hive-table <Hive DB>.<Hive Table> \
-- -- --schema <MSSQL Schema>
-- -- --table-hints NOLOCK

The job will now appear in the job list

sqoop-job --list

and can be run manually

sqoop-job --exec <JobName>

2 Oozie

2a <application>-Site.xml files

If not already available in HDFS, copy core-site.xml files to HDFS


Copy hive-site.xml to a temp location for editing

cp /usr/hdp/current/hive-server2/conf/hive-site.xml /tmp

Edit /tmp/hive-site.xml, locate the property

remove the value if any present

The result in the file:


Save the change and copy the modified /tmp/hive-site.xml to HDFS

Note #1: if the file sqoop-site.xml is not reachable to Oozie/Sqoop, the Sqoop job will run once and fail subsequent runs logging the following entries

17/01/17 16:30:32 INFO sqoop.Sqoop: Running Sqoop version: 
17/01/17 16:30:33 ERROR sqoop.SqoopOptions: It seems that you have launched a Sqoop metastore job via 
17/01/17 16:30:33 ERROR sqoop.SqoopOptions: Oozie with sqoop.metastore.client.record.password disabled. 
17/01/17 16:30:33 ERROR sqoop.SqoopOptions: But this configuration is not supported because Sqoop can't 
17/01/17 16:30:33 ERROR sqoop.SqoopOptions: prompt the user to enter the password while being executed 
17/01/17 16:30:33 ERROR sqoop.SqoopOptions: as Oozie tasks. Please enable sqoop.metastore.client.record 
17/01/17 16:30:33 ERROR sqoop.SqoopOptions: .password in sqoop-site.xml, or provide the password 
17/01/17 16:30:33 ERROR sqoop.SqoopOptions: explicitly using --password in the command tag of the Oozie 
17/01/17 16:30:33 ERROR sqoop.SqoopOptions: workflow file. 

Note #2 : When are set, I have seen the workflow execution failing with a rate of 50-60%, after the data is ingested to Hive and beforethe Sqoop Metastore is updated. Generating duplicate ingestion in the Hive table

2b Update the Oozie share lib with the required jar files

/usr/hdp/current/hive-server2/lib/hive-shims-* to hdfs://user/oozie/share/lib/ lib_<timestamp>/hive/
/usr/hdp/current/atlas-server/hook/hive/*.jar to hdfs://user/oozie/share/lib/lib_<timestamp>/hive/ 

run the following command after having created a Kerberos ticket with Oozie keytab

oozie admin -oozie https://<oozie_server>:11443/oozie -sharelibupdate 

2c Copy required jar files to HDFS

(Microsoft) sqljdbc.jar  to <HDFS_PATH>/jars/sqljdbc.jar
/usr/hdp/ to  <HDFS_PATH>/jars/sqljdbc.jar

2d Create the workflow

File : workflow.xml

<global> </global> passed the required -site.xml to all the actions defined

<archive> </archive> lists the jar file required by Sqoop. (It seems that Sqoop will not parse the CLASS_PATH)

<workflow-app xmlns="uri:oozie:workflow:0.4" name="Worklow Sqoop Incremental">
        <job-xml>/<HDFS_PATH>/sqoop-site.xml </job-xml>
         <job-xml>/<HDFS_PATH>/sqoop/hive-site.xml </job-xml>

        <credential name='hive_creds' type='hcat'>
          	 <value>thrift://<hive thrift URI>:9083</value>
<start to="SqoopStep"/>

<action name="SqoopStep" cred="hive_creds">
	<sqoop xmlns="uri:oozie:sqoop-action:0.3">
                 <command>job --meta-connect jdbc:hsqldb:hsql://<metastorenode>:17000/sqoop --exec <SqoopJobname></command>
         <ok to="end"/>
         <error to="fail"/>

     <kill name="fail">
      <message>Map/Reduce failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>

       <end name = "end"/>

2e Create the coordinator

File : coordinator.xml

<coordinator-app name="Sqoop Incremental Ingestion Scheduler" frequency="${coord:minutes(5)}"
                  start="${start}" end="2100-01-01T08:00Z" timezone="UTC"


2f Edit

File :


Keys setting :

oozie.action.sharelib.for.sqoop must be set to at least "sqoop, hive"

2g submitting

Copy both coordinator.xml & workflow.xml to HDFS (make sure to reflect the right paths in both & coordinator.xml)

submit the job to oozie (with a kerberos ticket generated with Oozie keytab)

oozie job -oozie https://<oozieserver>:11443/oozie -config <localpath>/ -submit

Hopefully this will prove useful.


what changes will be made if I'm importing from MySQL RDMS to hive by incremental importation?

Don't have an account?
Version history
Revision #:
1 of 1
Last update:
‎02-23-2017 12:41 PM
Updated by:
Top Kudoed Authors