Sqoop Export数据到本地数据库时出现错误,命令如下:
sqoop export \
--connect 'jdbc:mysql://202.193.60.117/dataweb?useUnicode=true&characterEncoding=utf-8' \
--username root \
--password-file /user/hadoop/.password \
--table user_info_copy \
--export-dir /user/hadoop/user_info \
--input-fields-terminated-by "@"
错误日志如下:
Error: java.io.IOException: Can't export data, please check failed map task logs
at org.apache.sqoop.mapreduce.TextExportMapper.map(TextExportMapper.java:)
at org.apache.sqoop.mapreduce.TextExportMapper.map(TextExportMapper.java:)
at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:)
at org.apache.sqoop.mapreduce.AutoProgressMapper.run(AutoProgressMapper.java:)
at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:)
at org.apache.hadoop.mapred.MapTask.run(MapTask.java:)
at org.apache.hadoop.mapred.YarnChild$.run(YarnChild.java:)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:)
at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:)
Caused by: java.lang.RuntimeException: Can't parse input data: '2,hello,456,0'
at user_info_copy.__loadFromFields(user_info_copy.java:)
at user_info_copy.parse(user_info_copy.java:)
at org.apache.sqoop.mapreduce.TextExportMapper.map(TextExportMapper.java:)
... more
Caused by: java.lang.NumberFormatException: For input string: "2,hello,456,0"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:)
at java.lang.Integer.parseInt(Integer.java:)
at java.lang.Integer.valueOf(Integer.java:)
at user_info_copy.__loadFromFields(user_info_copy.java:)
... more
该错误的问题在于分隔符,因为您没有在配置单元表中指定分隔符,默认的配置单元分隔符是:
'\ 001'字段终止
'\ 002'的收藏品终止
'\ 003'终止的地图密钥
LINES终止于'\ n'
所以要解决问题,就需要更改配置单元创建或sqoop作业中的分隔符来解决问题。在本问题中,我的表示在本地通过界面化管理工具创建的,分隔符换成“,”就能解决问题了,若是其他分隔符则对应改变就行;或者,使用以下语句重新创建表格并指定分隔符来解决。
ROW FORMAT DELIMITED FIELDS TERMINATED BY '分隔符'
以上就是博主为大家介绍的这一板块的主要内容,这都是博主自己的学习过程,希望能给大家带来一定的指导作用,有用的还望大家点个支持,如果对你没用也望包涵,有错误烦请指出。如有期待可关注博主以第一时间获取更新哦,谢谢!