Day: March 16, 2023

176.Sqoop Import – Specifying Number of Mappers

Command to import table and customize the number of mappers: sqoop import –connect jdbc:mysql://ms.itversity.com:3306/retail_db –username retail_user –password itversity –table order_items –warehouse-dir /user/training/sqoop_import/retail_db –delete-target-dir –num-mappers 8 To validate: hadoop fs -ls /user/training/sqoop_import/retail_db/order_items

175.Reviewing logs of Sqoop Import

To redirect log messages to other files sqoop import –connect jdbc:mysql://ms.itversity.com:3306/retail_db –username retail_user –password itversity –table order_items –warehouse-dir /user/training/sqoop_import/retail_db –delete-target-dir 1>import.out 2>import.err To view the import.out file: view import.out To view the import.err file: view import.err Command to get status of the job: mapred job -status job_id

174.Sqoop Import – Execution Flow

Command to import order_items table and overwrite the directory if exists: sqoop import –connect jdbc:mysql://ms.itversity.com:3306/retail_db –username retail_user –password itversity –table order_items –warehouse-dir /user/training/sqoop_import/retail_db –delete-target-dir To validate: sqoop eval –connect jdbc:mysql://ms.itversity.com:3306/retail_db –username retail_user –password itversity -e “DESCRIBE order_items”

173.Sqoop Import – Managing HDFS Directories – append or overwrite or fail

Command to import order_items table and overwrite the directory if exists: sqoop import –connect jdbc:mysql://ms.itversity.com:3306/retail_db –username retail_user –password itversity –table order_items –warehouse-dir /user/training/sqoop_import/retail_db –delete-target-dir To append to the existing directory use –append in place of –delete-target-dir.