Facebook
From 4, 4 Months ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 234
  1. Step1: $mysql -uroot -pcloudera
  2. Step 2: show Databases;
  3. Step 3: Use retail_db;
  4. Step4: Show Tables;
  5. Step 5: Choose Table departments
  6.  select * From departments;
  7.  Step 6: Open New Terminal and Write import command.
  8. Step 7: import command from mysql to HDFS
  9.  $ sqoop import --connect jdbc:mysql://localhost:3306/retail_db --username root --
  10. password cloudera --table departments;
  11. This will take sometime to process
  12.  
  13. Step 8: To check file imported in HDFS use below command
  14.  $ hadoop fs -ls /user/cloudera;
  15. Step 9: To check the content of the file
  16.  $ hadoop fs -cat /user/cloudera/departments/part*
  17.  
  18.  step10: Create New Table in Mysql (Terminal 1)
  19. Create Table departments_hdfs(deptid INT, deptName Varchar(20));
  20. This will create new table in mysql
  21. Verify: show Tables;
  22. step 11: Open New Terminal and Write export command.
  23. Step 12. Export Command HDFS TO Mysql.
  24. $ sqoop export --connect jdbc:mysql://localhost:3306/retail_db --username root --
  25. password cloudera --table departments_hdfs --export-dir
  26. /user/cloudera/departments/part*
  27.  
  28. Step 13. In First cmd
  29. Select * From departments_hdfs;