929 5555 929 Online | 929 5555 929 Classroom hadoopwebmasters@gmail.com



1. download sqoop-1.4.4.bin__hadoop-1.0.0.tar.gz
2. sudo tar -xvf sqoop-1.4.4.bin__hadoop-1.0.0.tar.gz
3. sudo mv sqoop-1.4.4 /usr/local/sqoop
4. sudo chmod a+x /usr/local/sqoop
5. sudo chown -R <userName>:<userName>
6. download and copy mysql-connector-java-5.1.22.jar into /usr/local/sqoop/lib
7. Atl + F2 and gksudo gedit .bashrc and add the below lines
export SQOOP_HOME=/usr/local/sqoop
8. Install MySQL
Sudo apt-get install mysql-server-5.6
Sudo apt-get install mysql-client-5.6
9. copy the sqoop-1.4.4.jar and sqoop-test-1.4.4.jar into /usr/local/sqoop/
IMP points:–
1. by default sqoop will execute 4 mappers
2. if there is no primary key on table, need mention -m <noMapper> mandatory
3. import with –query with only possible \$CONDITIONS
4. in general, where importing data with joins need to implement import with –query.
5. –target-dir
6. –fields-terminated-by ‘<del>’
7. –append
8. –lines-terminated-by ‘<del>’
9. –where ‘<condition>’
10. –export-dir


$ sqoop import — RDBMS to HDFS
eval — RDBMS data exe
export — HDFS to RDBMS
$ sqoop import –connect <driverName://<hostName:portNo>/<dataBaseName> –table <tableName>
Default Port no for mySql is 3306

$ sqoop import –connect jdbc:mysql://localhost/Batch16 –table empPrim -m 1 –target-dir /Praveen/SQOOP
–fields-terminated-by ‘\t’ –append;


$ sqoop eval –connect jdbc:mysql://localhost/Batch16 –query “select * from empPrim”;

IMPORT with –query:

$ sqoop import –connect jdbc:mysql://localhost/Batch16 –query “select * from empPrim where eSal<=40000 and \$CONDITIONS” -m 1 –target-dir /Praveen/SQOOP/cond;

import with –table
eval with –query

import with –table and –where ‘eSal <= 40000’
import with –query and where eSal <= 40000 and \$CONDITIONS

import with data from multiple tables(JOIN) and — query where \$CONDITIONS
import with –query is not possible directly, but we can do with WHERE \$CONDITIONS

sqoop import –connect jdbc:mysql://localhost/Batch16 –query “select e.eId,e.eName,e.eSal,d.dName from empPrim e JOIN dept d ON (e.eId = d.eId) where \$CONDITIONS” -m 1 –target-dir /Praveen/SQOOP/Batch16/join;

sqoop export –connect jdbc:mysql://localhost/Batch16 –table exEmp –export-dir /Praveen/SQOOP/Batch16/join/part-m-00000 –username root –password root -m 1 –input-fields-terminated-by ‘,’;