shell脚本中的sqoop语句如下:
sqoop import --connect jdbc:mysql://${database_IP}:${database_PORT}/${database_NAME}?tinyInt1isBit=false --username ${database_USER} --password ${database_PASSWORD} --query "select * from sqoop_t_recordlist00 where starttime!='0000-00-00 00:00:00' and \$CONDITIONS" --hive-import --m 1 --null-string N --null-non-string N --hive-database tmp --as-textfile --target-dir /user/hive/warehouse/tmp.db/sqoop_t_recordlist00 --hive-table sqoop_t_recordlist00 --split-by id --hive-drop-import-delims
首先遇到报错:
Error: java.io.IOException: SQLException in nextKeyValue
Caused by: java.sql.SQLException:
Value 'u0006197869 1000003110000038u00010u00011u0003381u0003102u00130000-00-00 00:00:00u00132013-07-30 16:20:06u0003340
很奇怪为什么会有这样的value值?导入的表有datetime类型,去mysql查询一下有没有value中包含的两个时间:“0000-00-00 00:00:00”和“2013-07-30 16:20:06”,果然有记录的datetime类型的值是“0000-00-00 00:00:00”,修改sqoop脚本手动过滤掉“0000-00-00 00:00:00”,问题解决。
还遇到了一个问题是:
sqoop失败了,这时候想要重新执行sqoop,查一下hive中无import的表,但是再次执行sqoop发生奇怪的事:
29: 19/11/27 11:15:58 ERROR tool.ImportTool: Import failed: org.apache.hadoop.mapred.FileAlreadyExistsException:
Output directory hdfs://emr-cluster/user/hive/warehouse/tmp.db/sqoop_t_recordlist00 already exists
报错说文件存在,但是表并不存在!执行删除表操作drop table,却是table not exist!,可能的原因是: