Hadoop: Sqoop Contoh Import dari MySQL ke Hadoop

From OnnoWiki
Jump to navigation Jump to search

IMPORTING DATA FROM HADOOP TO MYSQL Steps to install mysql

   Run the command :sudo apt-get install mysql-server and give appropriate username and password.

Using sqoop to perform import to hadoop from sql

   Download mysql-connector-java-5.1.28-bin.jar and move to /usr/lib/sqoop/lib using command
   user@ubuntu:~$ sudo cp mysql-connnectpr-java-5.1.28-bin.jar /usr/lib/sqoop/lib/
   Login to mysql using command
   user@ubuntu:~$   mysql -u root -p
   Login to secure shell using command
   user@ubuntu:~$  ssh localhost
   Start hadoop using the command
   user@ubuntu:~$  bin/hadoop start-all.sh
   Run the command
   user@ubuntu:~$ sqoop import -connect jdbc:mysql://localhost:3306/sqoop -username root -pasword abc -table employees -m

This command imports the employees table from the sqoop directory of myql to hdfs. Error points

   Do check if the hadoop is in safe mode using command
   user@ubuntu:~$hadoop dfsadmin -safemode get

If you are getting safemode is on, run the command

user@ubuntu:~$hadoop dfsadmin -safemode leave

and again run the command

user@ubuntu:~$hadoop dfsadmin -safemode get

and confirm that you are getting safemode is off.

   Do make sure that haoop is running before performing the import action.