Sqoop 从 HDFS 目录导出到 sybase IQ 失败

Sqoop export from HDFS dir to sybase IQ failed

我正在尝试将 HDFS 文件从 HDFS 目录导出到 sybase IQ table。

我已将 sybase 驱动程序正确放置在 sqoop 库路径中。

sqoop 命令:

sqoop export  \
 --connect jdbc:sybase:Tds:sybasehost:port/DATABASE=OMEGA \
 --username dummy \
 --password dummy \
 --driver com.sybase.jdbc4.jdbc.SybDriver \
 --table omega_sybase_table \
 --export-dir /user/cloudera/omega/output_files/ \
 --input-fields-terminated-by ','

我收到以下错误并且导出失败。

17/04/25 16:17:07 INFO mapreduce.Job: Task Id : attempt_1489579695153_4935_m_000002_1, Status : FAILED
Error: java.io.IOException: Can't export data, please check failed map task logs
    at org.apache.sqoop.mapreduce.TextExportMapper.map(TextExportMapper.java:112)
    at org.apache.sqoop.mapreduce.TextExportMapper.map(TextExportMapper.java:39)
    at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:145)
    at org.apache.sqoop.mapreduce.AutoProgressMapper.run(AutoProgressMapper.java:64)
    at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:787)
    at org.apache.hadoop.mapred.MapTask.run(MapTask.java:341)
    at org.apache.hadoop.mapred.YarnChild.run(YarnChild.java:163)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAs(Subject.java:415)
    at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1671)
    at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:158)
Caused by: java.io.IOException: java.sql.SQLException: SQL Anywhere Error -210: User 'another user' has the row in 'omega_sybase_table' locked
    at org.apache.sqoop.mapreduce.AsyncSqlRecordWriter.write(AsyncSqlRecordWriter.java:233)
    at org.apache.sqoop.mapreduce.AsyncSqlRecordWriter.write(AsyncSqlRecordWriter.java:46)
    at org.apache.hadoop.mapred.MapTask$NewDirectOutputCollector.write(MapTask.java:658)
    at org.apache.hadoop.mapreduce.task.TaskInputOutputContextImpl.write(TaskInputOutputContextImpl.java:89)
    at org.apache.hadoop.mapreduce.lib.map.WrappedMapper$Context.write(WrappedMapper.java:112)
    at org.apache.sqoop.mapreduce.TextExportMapper.map(TextExportMapper.java:84)
    ... 10 more
Caused by: java.sql.SQLException: SQL Anywhere Error -210: User 'another user' has the row in 'omega_sybase_table' locked
    at com.sybase.jdbc4.jdbc.SybConnection.getAllExceptions(Unknown Source)

有人可以帮我解决这个问题吗?

它是因为在 sqoop export 命令中使用了多个映射器任务。

Sybase IQ 一次只允许一个连接,多个映射器任务尝试在 sybase iq table 中并行插入记录。

解决方法是在 sqoop export 命令中使用 -m 1。