Sunteți pe pagina 1din 7

Task3:

Table in SQL:

CREATE TABLE student (Rollno int,Name varchar(20),Department varchar(20),Grade varchar(20));insert


into student values(101,'Anuratna','CSE','A');
insert into student values(102,'Bharani','CSE','D');
insert into student values(103,'Chithra','CSE','B');
insert into student values(104,'Divya','CSE','A');
insert into student values(105,'Eswar','CSE','B');

Imported record in HDFS :

sqoop import --connect jdbc:mysql://localhost/zeyotime --username root --password cloudera --table


student --m 1 --target-dir /user/cloudera/targetdir

Export HDFS data to the different table:

sqoop export --connect jdbc:mysql://localhost/zeyotime --username root --password cloudera --table


studentexpo --m 1 --export-dir /user/cloudera/studentdir
Export HDFS data to the same table:

sqoop export --connect jdbc:mysql://localhost/zeyotime --username root --password cloudera --table


student --m 1 --export-dir /user/cloudera/studentdir

Export HDFS data to the different schema table:

ERROR:
TASK 1:
Create a table in SQL with timestamp

CREATE TABLE usertime1(userid INT,firstname VARCHAR(20),lastname VARCHAR(20),city


varchar(50),age int,createdt timestamp,transactamt int);
insert into usertime1 values(1,'Arun','Kumar','chennai',33,now(),100000);
insert into usertime1 values(2,'srini','vasan','chennai',33, now(),10000);
insert into usertime1 values(3,'vasu','devan','banglore',39, now(),90000);
insert into usertime1 values(4,'mohamed','imran','hyderabad',33, now(),1000);
insert into usertime1 values(5,'arun','basker','chennai',23, now(),200000);

Create sqoop job to do incremental append with timestamp

sqoop job --create jobtime2 -- import --connect jdbc:mysql://localhost/zeyotime --username root --


password cloudera --table usertime 1 --m 1 --incremental append --check-column createdt --last-value
0000-00-00-00:00:00.0 --target-dir /user/cloudera/usertime2dir

incremental append job(jobtime2) result:


added two additional record to the sql table

insert into usertime1 values(8,'vasu','devan','banglore',39, now(),90000);


insert into usertime1 values(9,'vasu','devan','banglore',39, now(),90000);

retrieved only the recent record in the second partfile(part-m-00001)

Import result after changing the lastvalue (metastore.db.scribt) -0000-00-00-00:00:00.0

Retrieved all the records in the third partfile(part-m-00002)

Task2:
SQL table with timestamp
Imported data in HDFS with four mappers

Changed 4-5 records in SQL table(1,6,11,16)


Achieved the changes in HDFS using incremental last modified

Sqoop import –connect jdbc:mysql://localhost/zeyotime –username root –password cloudera –table


customer1 –m 4 –split-by custid –incremental lastmodified –check-column time –last-value ‘2019-07-15
07:13:53’ –target-dir /user/cloudera/timedir

S-ar putea să vă placă și