Sqoop导入数据到MySql时的java.util.NoSuchElementException错误

应用场景为导出HDFS的数据到MySql数据库中。HDFS中的文件和MySql字段一一对应,但是每次执行的时候就报错。

 

执行命令:

./sqoop export --connect jdbc:mysql://10.0.0.0:3306/datacenter --username root --password admin --table uv_info --export-dir /user/hive/warehouse/uv/dt=2011-08-03

 

报错信息:

11/08/05 10:51:22 INFO mapred.JobClient: Running job: job_201108051007_0010
11/08/05 10:51:23 INFO mapred.JobClient:  map 0% reduce 0%
11/08/05 10:51:36 INFO mapred.JobClient: Task Id : attempt_201108051007_0010_m_000000_0, Status : FAILED
java.util.NoSuchElementException
        at java.util.AbstractList$Itr.next(AbstractList.java:350)
        at uv_info.__loadFromFields(uv_info.java:194)
        at uv_info.parse(uv_info.java:143)
        at com.cloudera.sqoop.mapreduce.TextExportMapper.map(TextExportMapper.java:79)
        at com.cloudera.sqoop.mapreduce.TextExportMapper.map(TextExportMapper.java:38)
        at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:144)
        at com.cloudera.sqoop.mapreduce.AutoProgressMapper.run(AutoProgressMapper.java:187)
        at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:647)
        at org.apache.hadoop.mapred.MapTask.run(MapTask.java:323)
        at org.apache.hadoop.mapred.Child$4.run(Child.java:270)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.security.auth.Subject.doAs(Subject.java:396)
        at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1127)
        at org.apache.hadoop.mapred.Child.main(Child.java:264)

 

此错误的原因为sqoop解析文件的字段与MySql数据库的表的字段对应不上造成的。因此需要在执行的时候给sqoop增加参数,告诉sqoop文件的分隔符,使它能够正确的解析文件字段。

./sqoop export --connect jdbc:mysql://10.0.0.0:3306/datacenter --username root --password admin --table uv_info --export-dir /user/hive/warehouse/uv/dt=2011-08-03 --input-fields-terminated-by '\t'
 

 

你可能感兴趣的:(exception)