📜 Sqoop Export 과정에서 발생하는 에러 해결하기
📖 Sqoop Export Error 내용
2022-05-23 02:16:34,173 INFO mapreduce.ExportJobBase: Exported 0 records.
2022-05-23 02:16:34,173 ERROR mapreduce.ExportJobBase: Export job failed!
2022-05-23 02:16:34,174 ERROR tool.ExportTool: Error during export:
Export job failed!
at org.apache.sqoop.mapreduce.ExportJobBase.runExport(ExportJobBase.java:445)
at org.apache.sqoop.manager.MySQLManager.upsertTable(MySQLManager.java:145)
at org.apache.sqoop.tool.ExportTool.exportTable(ExportTool.java:73)
at org.apache.sqoop.tool.ExportTool.run(ExportTool.java:99)
at org.apache.sqoop.Sqoop.run(Sqoop.java:147)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:76)
at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:183)
at org.apache.sqoop.Sqoop.runTool(Sqoop.java:234)
at org.apache.sqoop.Sqoop.runTool(Sqoop.java:243)
at org.apache.sqoop.Sqoop.main(Sqoop.java:252)
📖 Yarn에서 Application Id를 이용하여 로그 확인
yarn logs -applicationId application_1652259389202_0189
java.lang.RuntimeException: Can't parse input data: '\N'
at pd_analyzed_results.__loadFromFields(pd_analyzed_results.java:649)
at pd_analyzed_results.parse(pd_analyzed_results.java:521)
at org.apache.sqoop.mapreduce.TextExportMapper.map(TextExportMapper.java:89)
at org.apache.sqoop.mapreduce.TextExportMapper.map(TextExportMapper.java:39)
at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:146)
at org.apache.sqoop.mapreduce.AutoProgressMapper.run(AutoProgressMapper.java:64)
at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:799)
at org.apache.hadoop.mapred.MapTask.run(MapTask.java:347)
at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:174)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:422)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1730)
at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:168)
Caused by: java.lang.NumberFormatException: For input string: "\N"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:580)
at java.lang.Integer.valueOf(Integer.java:766)
at pd_analyzed_results.__loadFromFields(pd_analyzed_results.java:601)
... 12 more
추가 옵션은 --input-null-string
과 --input-null-non-string
이 있으며
전체적인 커맨드를 보면 다음 아래와 같이 작성됨
sqoop-export --connect jdbc:mysql://yourhost:port/yourdb \
--table your_table_name --username yourname --password yourpasswd \
--export-dir hdfs://yourhost:port/user/hive/warehouse/yourtable \
--input-fields-terminated-by '\001' \
--update-key id \
--update-mode allowinsert \
--input-null-string '\\N'
--input-null-non-string '\\N'
--columns colum1,colum2,colum3 -m 1
Sqoop으로 Export를 수행할때 --columns에 들어갈 컬럼 목록을 Hdfs에 저장된 파일의 데이터 순서에 맞게 넣어줘야 한다.