Halloween Sale: Flat 70% + Addl. 25% Off + 30 Days Extra Lab on all Courses | Use Coupon HS25 in Checkout | Offer Expires In

  Enroll Now

Sqoop Import - MySQL to HDFS

Start MySQL prompt: (Get the details from My Lab - SQL Credentials)

NOTE: The mysql host used in video is old. Please use the most recent host listed in "My Lab".

(you will have to specify password)

mysql -h 10.142.1.2 -u sqoopuser -pNHkkP876rp

On mysql prompt, take a look at data:

use sqoopex
select * from widgets;

If the widgets table does not exist, please create it using:

CREATE TABLE IF NOT EXISTS widgets(
  id int(11) NOT NULL AUTO_INCREMENT,
  widget_name varchar(64) NOT NULL,
  price decimal(10,2) DEFAULT NULL,
  design_date date DEFAULT NULL,
  version int(11) DEFAULT NULL,
  design_comment varchar(100) DEFAULT NULL,
  PRIMARY KEY (id)
);

If the widgets table did not have any data, please use the following to popular it:

INSERT INTO widgets VALUES (1,'sprocket',0.25,'2010-02-10',1,'Connects two \n\ngizmos'),(2,'gizmo',4.00,'2009-11-30',4,NULL),(3,'gadget',99.99,'1983-08-13',13,'Our flagship \n\nproduct');

Now, exit the mysql prompt using exit

Delete the folder if exists in HDFS: hadoop fs -rmr widgets

Run the following to import: sqoop import --connect jdbc:mysql://10.142.1.2/sqoopex --table widgets -m 2 --username sqoopuser --password NHkkP876rp --split-by id

Check the content of the imported File: hadoop fs -cat widgets/part-m-*

NOTE: The mysql host used in video is old. Please use the most recent host listed in "My Lab".


No hints are availble for this assesment

Answer is not availble for this assesment

Loading comments...