Apache Sqoop Export Command Usage
Apache Sqoop is a command-line interface application for transferring data between relational databases and Hadoop. It supports incremental loads of a single table or a free form SQL query as well as saved jobs which can be run multiple times to import updates made to a database since the last import. Imports can also be used to populate tables in Hive or HBase. Exports can be used to put data from Hadoop into a relational database. Sqoop got the name from sql+hadoop. Sqoop became a top-level Apache project in March 2012.
1) A machine with Ubuntu 14.04 LTS operating system.
2) Apache Hadoop pre installed (How to install Hadoop on Ubuntu 14.04)
3) MySQL Database pre installed (How to install MySQL Database on Ubuntu 14.04)
4) Apache Sqoop pre installed (How to install Sqoop on Ubuntu 14.04)
Sqoop Export to MySQL database from HDFS
Export data back from the HDFS to the RDBMS database. The target table must exist in the target database. The files which are given as input to the Sqoop contain records, which are called rows in table. Those are read and parsed into a set of records and delimited with user-specified delimiter.
The default operation is to insert all the record from the input files to the database table using the INSERT statement. In update mode, Sqoop generates the UPDATE statement that replaces the existing record into the database.
Step 1 - Change the directory to /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 - Create a emp.txt file.
Step 5 - Add these following lines to emp.txt file.
Step 6 - Create a emp_add.txt file.
Step 7 - Add these following lines to emp_add.txt file.
Step 8 - Create a emp_cnt.txt file.
Step 9 - Add these following lines to emp_cnt.txt file.
Step 10 - Copy all these text files in HDFS. In my case all these text files are saved in /home/hduser/Desktop/SQOOP/ directory.
Step 11 - Enter into MySQL command line inteface(CLI). Open a terminal (CTRL + ALT + T) and type the following command.
Step 12 - Create a new database 'userdb'
Step 13 - Use database 'userdb'
Step 14 - Create a new table 'employee'
Step 15 - Change the directory to /usr/local/sqoop/bin
Step 16 - The following command is used to export the table data (which is in emp.txt file on HDFS) to the employee table in db database of Mysql database server.
Step 17 - Verify
Step 18 - Create a new table 'employee_address'
Step 19 - The following command is used to export the table data (which is in emp_add.txt file on HDFS) to the employee table in db database of Mysql database server.
Step 20 - Verify
Step 21 - Create a new table 'employee_contact'
Step 22 - The following command is used to export the table data (which is in emp_cnt.txt file on HDFS) to the employee table in db database of Mysql database server.
Step 23 - Verify
Please share this blog post and follow me for latest updates on
Labels : Apache Sqoop Installation on Ubuntu Apache Sqoop Import Command Example Apache Sqoop Job Command Example Apache Sqoop Codegen Command Example Apache Sqoop Eval Command Example Apache Sqoop List-tables Command Example Apache Sqoop List-tables Command Example