Sqoop v1.1
Sqoop v1.1
Sqoop v1.1
Karthikeyan
Sanjai
1
INTRODUCTION
To import and export data from a relational database into Hadoop for
processing
command-line tool
SQOOP ARCHITECTURE
FILE FORMATS
SequenceFiles
Default delimiters are comma(,) for fields , a newline (\n) for records.
SUPPORTED DATABASES
MS SQL
PostgreSQL
Oracle
INSTALLATION
Download Sqoop-*.tar.gz
export HADOOP_HOME=/some/path/hadoop-dir
/sqoop help
SQOOP COMMANDS
sqoop help
Or We can use: sqoop COMMAND [ARGS]
Available commands:
codegen
create-hive-table
list-databases
import-all-tables
import
export
eval
list-tables
MYSQL CONNECTIVITY
mysql u root p
Enter password:root
show databases;
use test;
SQOOP EVALUATE
Evaluate a SQL statement
bin/sqoop eval --connect jdbc:mysql://localhost/test -username root password root --query "SELECT * FROM patient LIMIT 2"
bin/sqoop eval --connect jdbc:mysql://localhost/test -username root password root --query "INSERT INTO patient VALUES(4,
amudhan,'avil',400)"
SQOOP LIST
Sqoop-list-databases
Sqoop-list-tables
bin/sqoop list-tables --connect jdbc:mysql://localhost/test username root password root
10
11
SQOOP IMPORT(CONTD)
target-directory
bin/sqoop import -connect jdbc:mysql://localhost/test -username root password root --table patient --target-dir /user/output -m 1
12
HIVE INTEGRATION
bin/sqoop-import --connect jdbc:mysql://localhost/test -username root password root --table patient --hive-table patientthive --create-hive-table [email protected]
-hive-import -m 1
13
14
HBASE
15
16
SQOOP EXPORT
The input files are read and parsed into a set of records according to the
hdfs to mysql
bin/sqoop export --connect jdbc:mysql://localhost/test - username root password root --table patient --export-dir /user/amudhan/patient
hive to mysql:
user-specified delimiters.
bin/sqoop export --connect jdbc:mysql://localhost/test --table patient -export-dir /user/hive/warehouse/patient --username root -- password
root -m 1
17
THANK YOU!
18