Guest User

Untitled

a guest
Jun 11th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.48 KB | None | 0 0
  1. Control arguments
  2.  
  3. ---------------------append------------------------------------------------------------------------------
  4.  
  5. sqoop import --connect "jdbc:mysql://nn01.itversity.com:3306/retail_db" --username retail_dba \
  6. --password itversity --warehouse-dir "/user/krishnatejathatavarthi/retail_db" --table order_items --append;
  7.  
  8. ---------------------file format----------------------------------------------------------------
  9. a) sequence file
  10. sqoop import --connect "jdbc:mysql://nn01.itversity.com:3306/retail_db" --username retail_dba \
  11. --password itversity --target-dir "/user/krishnatejathatavarthi/retail_db/order_items_seq" --table order_items --as-sequencefile
  12.  
  13. b) avrodatafile
  14.  
  15. sqoop import --connect "jdbc:mysql://nn01.itversity.com:3306/retail_db" --username retail_dba \
  16. --password itversity --target-dir "/user/krishnatejathatavarthi/retail_db/order_items_avro" \
  17. --table order_items --as-avrodatafile
  18.  
  19. --------------------------------------NO PK-----------------------------------------------------
  20. sqoop import --connect "jdbc:mysql://nn01.itversity.com:3306/retail_import" --username retail_dba \
  21. --password itversity --target-dir "/user/krishnatejathatavarthi/retail_db/order_items_no_pk" \
  22. --table tb_order_items_no_pk -- till through error
  23.  
  24. sqoop import --connect "jdbc:mysql://nn01.itversity.com:3306/retail_import" --username retail_dba \
  25. --password itversity --target-dir "/user/krishnatejathatavarthi/retail_db/order_items_no_pk_mappers" \
  26. --table tb_order_items_no_pk --num-mappers 1
  27.  
  28. sqoop import --connect "jdbc:mysql://nn01.itversity.com:3306/retail_import" --username retail_dba \
  29. --password itversity --target-dir "/user/krishnatejathatavarthi/retail_db/order_items_no_pk_mappers" \
  30. --table tb_order_items_no_pk --split-by order_item_id \
  31. --boundary-query "select min(order_item_id), max(order_item_id) from tb_order_item_no_pk where order_item_id not in (1000000)"
  32.  
  33.  
  34.  
  35.  
  36. ---------------------------------work shop 7------------------------------------------------------------------------
  37. sqoop import --connect "jdbc:mysql://nn01.itversity.com:3306/retail_db" --username retail_dba \
  38. --password itversity \
  39. --table order_items \
  40. --columns "order_item_id,order_item_order_id,order_item_product_id" \
  41. --hive-import \
  42. --create-hive-table \
  43. --hive-overwrite \
  44. --hive-database db_krishna \
  45. --hive-table order_items_sqoop \
  46. --map-column-hive order_item_id=bigint
  47. --target-dir "/user/krishnatejathatavarthi/retail_db/order_items_no_pk_mappers" \
  48.  
  49. ----------------------------------------------------workshop 8------------------------------------------------------
  50.  
  51. create table orders_sqoop(
  52. order_id int,
  53. order_date timestamp,
  54. order_customer_id int,
  55. order_status varchar(45));
  56. );
  57.  
  58. -------with hive import
  59.  
  60. sqoop import --connect "jdbc:mysql://nn01.itversity.com:3306/retail_db" --username retail_dba \
  61. --password itversity \
  62. --table orders \
  63. --hive-import \
  64. --hive-database db_krishna \
  65. --hive-table orders_sqoop
  66.  
  67.  
  68. ---without hive import
  69. sqoop import --connect "jdbc:mysql://nn01.itversity.com:3306/retail_db" --username retail_dba \
  70. --password itversity \
  71. --table orders \
  72. --target-dir hdfs://nn01.itversity.com:8020/apps/hive/warehouse/db_krishna.db/orders_sqoop \
  73. --append
  74. --------------------------
  75.  
  76. create table orders_sqoop(
  77. order_id int,
  78. order_date timestamp,
  79. order_customer_id int,
  80. order_status varchar(45))
  81. row format delimited fields terminated by "|";
  82.  
  83.  
  84. sqoop import --connect "jdbc:mysql://nn01.itversity.com:3306/retail_db" --username retail_dba \
  85. --password itversity \
  86. --table orders \
  87. --target-dir hdfs://nn01.itversity.com:8020/apps/hive/warehouse/db_krishna.db/orders_sqoop \
  88. --append \
  89. --fields-terminated-by '|'
  90.  
  91.  
  92.  
  93. -------------------------
  94. sqoop import --connect "jdbc:mysql://nn01.itversity.com:3306/retail_db" --username retail_dba --password itversity \
  95. --table orders --target-dir hdfs://nn01.itversity.com:8020/user/krishnatejathatavarthi/db_krishna.db/orders \
  96. --append --fields-terminated-by '|' --check-column order_id --incremental append --last-value 60000
  97.  
  98.  
  99.  
  100. ---------------------workshp 9------import all tables----------------------------------------------------------
  101.  
  102. sqoop import-all-tables --connect "jdbc:mysql://nn01.itversity.com:3306/retail_db" \
  103. --username retail_dba --password itversity \
  104. --warehouse-dir /user/krishnatejathatavarthi/import_all_tables \
  105. --exclude-tables "departments,categories" \
  106. -as-avrodatafile
  107.  
  108.  
  109. ---------hive import --------------
  110. sqoop import-all-tables --connect "jdbc:mysql://nn01.itversity.com:3306/retail_db" \
  111. --username retail_dba --password itversity \
  112. --exclude-tables "orders" \
  113. --hive-import --hive-database db_krishna
  114.  
  115.  
  116.  
  117. -----------------------------Exercise import-----------------------------------------
  118.  
  119. sqoop list-databases --connect "jdbc:mysql://nn01.itversity.com:3306" --username retail_dba --password itversity
  120.  
  121. sqoop list-tables --connect "jdbc:mysql://nn01.itversity.com:3306/retail_db" --username retail_dba --password itversity
  122.  
  123. sqoop eval --connect "jdbc:mysql://nn01.itversity.com:3306/retail_db" --username retail_dba --password itversity \
  124. --query "select * from order_items limit 10"
  125. --table order_items --where order_items_id < 10
  126.  
  127. hadoop fs -mkdir /user/krishnatejathatavarthi/sqoop_exer_12
  128.  
  129. sqoop import --connect "jdbc:mysql://nn01.itversity.com:3306/retail_db" --username retail_dba --password itversity \
  130. --table orders --columns "order_customer_id,order_status" --warehouse-dir "/user/krishnatejathatavarthi/sqoop_exer_12" \
  131. --as-avrodatafile
  132.  
  133. sqoop import-all-tables --connect "jdbc:mysql://nn01.itversity.com:3306/retail_db" --username retail_dba --password itversity \
  134. --warehouse-dir "/user/krishnatejathatavarthi/sqoop_exer_12" \
  135. --as-avrodatafile --exclude-tables orders
  136.  
  137. sqoop import --connect "jdbc:mysql://nn01.itversity.com:3306/retail_db" --username retail_dba --password itversity \
  138. --table orders --warehouse-dir "/user/krishnatejathatavarthi/sqoop_exer_12" \
  139. --as-avrodatafile
  140.  
  141. sqoop eval --connect "jdbc:mysql://nn01.itversity.com:3306/nyse" --username nyse_ro --password itversity \
  142. --query "describe stocks_eod"
  143.  
  144. sqoop import --connect "jdbc:mysql://nn01.itversity.com:3306/nyse" --username nyse_ro --password itversity \
  145. --warehouse-dir "/user/krishnatejathatavarthi/sqoop_exer_12" \
  146. --table stocks_eod \
  147. --compression-codec org.apache.hadoop.io.compress.SnappyCodec --m 8
  148.  
  149. sqoop import-all-tables --connect "jdbc:mysql://nn01.itversity.com:3306/retail_db" --username retail_dba --password itversity \
  150. --hive-import \
  151. --hive-overwrite --create-hive-table \
  152. --hive-database db_krishna_sqoop \
  153. --fields-terminated-by '|' \
  154. --warehouse-dir "/user/krishnatejathatavarthi/sqoop_exer_hive"
Add Comment
Please, Sign In to add comment