Sqoop Job Command With Example
Apache Sqoop Job Command With Example
This post describes how to create and maintain the Sqoop jobs. Sqoop job creates and saves the import and export commands. It specifies parameters to identify and recall the saved job. This re-calling or re-executing is used in the incremental import, which can import the updated rows from RDBMS table to HDFS.
Step 1 - Change the directory to /usr/local/hadoop/sbin
$ cd /usr/local/hadoop/sbin
Step 2 - Start all hadoop daemons.
Step 3 - The JPS (Java Virtual Machine Process Status Tool) tool is limited to reporting information on JVMs for which it has the access permissions.
Step 4 - Change the directory to /usr/local/sqoop/bin
$ cd /usr/local/sqoop/bin
Create Job (--create)
Here we are creating a job with the name myjob, which can import the table data from RDBMS table to HDFS. The following command is used to create a job that is importing data from the employee table in the db database to the HDFS file.
$ sqoop job --create myjob \
-- import \
--connect jdbc:mysql://localhost/userdb \
--username root \
--password root \
--table employee \
--m 1 \
Verify Job (--list)
'--list' argument is used to verify the saved jobs. The following command is used to verify the list of saved Sqoop jobs.
$ sqoop job --list
Inspect Job (--show)
'--show' argument is used to inspect or verify particular jobs and their details. The following command and sample output is used to verify a job called myjob.
$ sqoop job --show myjob
Execute Job (--exec)
'--exec' option is used to execute a saved job. The following command is used to execute a saved job called myjob.
$ sqoop job --exec myjob
Verify after executing.
$ hdfs dfs -cat /user/hduser/targetfolder/part-m-00000