Advertisement
Guest User

Untitled

a guest
Oct 17th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.52 KB | None | 0 0
  1. Sqoop import from mysql:
  2.  
  3. Commands to validate connection from sqoop to mysql
  4.  
  5. Listing the databases:
  6.  
  7. sqoop list-databases --connect jdbc:mysql://localhost --username retail_dba --password cloudera
  8.  
  9.  
  10. Listing the tables from Database;
  11.  
  12. sqoop list-tables --connect jdbc:mysql://localhost/retail_db --username retail_dba --password cloudera
  13.  
  14. Sqoop eval command:
  15.  
  16. sqoop eval --connect jdbc:mysql://localhost/retail_db --username retail_dba --password cloudera --query "select *from departments";
  17.  
  18.  
  19. Simple import with target-dir
  20.  
  21. sqoop import --connect jdbc:mysql://localhost/retail_db --username retail_dba --password cloudera --table departments --target-dir department
  22.  
  23.  
  24. Target-dir with --append option
  25.  
  26. sqoop import --connect jdbc:mysql://localhost --username retail_dba --password cloudera --table departments --target-dir department --append
  27.  
  28.  
  29. Import as avro data file
  30.  
  31. sqoop import --connect jdbc:mysql://localhost/retail_db --username retail_dba --password cloudera --table departments --target-dir department --as-avrodatafile
  32.  
  33.  
  34. Import as sequence file
  35.  
  36. sqoop import --connect jdbc:mysql://localhost/retail_db --username retail_dba --password cloudera --table departments --target-dir department --as-sequencefile
  37.  
  38.  
  39. Import with bopundary Query
  40.  
  41. sqoop import --connect jdbc:mysql://localhost/retail_db --username retail_dba --password cloudera --table departments --target-dir department -m 2 --boundary-query "select 2,8 from departments"
  42.  
  43. Split-by and selecting specific columns
  44.  
  45. sqoop import --connect jdbc:mysql://localhost/retail_db --username retail_dba --password cloudera --table departments --target-dir department -m 2 --split-by department_id --columns department_name
  46.  
  47.  
  48. Sqoop import-all-tables
  49.  
  50. sqoop import-all-tables --connect jdbc:mysql://localhost/retail_db --username retail_dba --password cloudera --warehouse-dir /user/cloudera/sqoop_import_all/
  51.  
  52.  
  53. Sqoop import all to hive with commpression
  54.  
  55. sqoop import-all-tables --connect jdbc:mysql://localhost/retail_db --username retail_dba --password cloudera --hive-import --hive-overwrite --create-hive-table --compress --compression-codec org.apache.hadoop.io.compress.SnappyCodec -num-mappers 1
  56.  
  57. Sqoop import split-by and query options
  58.  
  59. sqoop import --connect jdbc:mysql://quickstart.cloudera/retail_db --username retail_dba --password cloudera --e "select *from departments where \$CONDITIONS" --target-dir /user/cloudera/dep --split-by department_id
  60.  
  61. sqoop import --connect jdbc:mysql://quickstart.cloudera/retail_db --username retail_dba --password cloudera --query "select *from orders join order_items on orders.order_id=order_items.order_item_order_id where \$CONDITIONS" --target-dir /user/cloudera/dep --split-by order_id
  62.  
  63. Sqoop import to existing hive table
  64.  
  65. sqoop import --connect jdbc:mysql://localhost/retail_db --username retail_dba --password cloudera --table departments --hive-import --hive-overwrite --hive-table departments
  66.  
  67. Sqoop incremental import
  68.  
  69. sqoop import --connect jdbc:mysql://localhost/retail_db --username retail_dba --password cloudera --table departments --target-dir depart --incremental append --check-column "department_id" --last-value 9
  70.  
  71. import with delimiters
  72.  
  73. sqoop import --connect jdbc:mysql://localhost/retail_db --username retail_dba --password cloudera --table dep --hive-import --hive-table departmet1 --null-string NA --null-non-string -1 -m 1
  74.  
  75.  
  76. Changing delimiters
  77.  
  78. sqoop import --connect jdbc:mysql://localhost/retail_db --username retail_dba --password cloudera --table departments --target-dir dep2 --enclosed-by \" --fields-terminated-by \| --lines-terminated-by \]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement