sqoop 错误记录

来源:互联网 发布:山东省网络重点实验室 编辑:程序博客网 时间:2024/06/06 02:15

sqoop命令有点长, 我们初学者难免会犯种种错误, 以下是我遇到的和可行的解决办法

1

Error: java.io.IOException: SQLException in nextKeyValue

解决办法:
这个有可能是数据库字段语句写的有问题,如下语句就会报此错误:
sqoop import –hive-import –connect jdbc:mysql://localhost:3306/my_db –username hive –password 1234 –table t_stu –columns ‘name,sex’ -m 1 –hive-table t_stu –where ‘sex=man’;
这是将mysql表导入到hive中, 出错地方就在’sex=man’ 因为sex字段是char类型,所以应该改成”sex=’man’” 即可


2

Encountered IOException running import job: org.apache.hadoop.mapred.FileAlreadyExistsException: Output directory hdfs://localhost:9000/user/hadoop/t_stu already exists

解决办法: 在hadoop 的 /user/hadoop目录下存在t_stu, 删除掉即可


3

Encountered IOException running import job: java.io.IOException: Query [select * from t_stu where sex=’woman’ AND ] must contain ‘$CONDITIONS’ in WHERE clause.

这个错误是需要在查询语句后添加 AND$CONDITIONS如下语句(注意:当使用单引号时只需要使用AND $CONDITIONS 若是双引号则需要加个”\”, 就是这样AND \$CONDITIONS

sqoop import --hive-import --connect jdbc:mysql://localhost:3306/my_db --username hive --password 1234 -m 1 --query "select * from t_stu where sex='woman' AND \$CONDITIONS" --target-dir '/sqoop/newtable' --hive-table newtable

4

ERROR manager.SqlManager: Error reading from database: java.sql.SQLException: Streaming result set
解决办法: 将mysql连接驱动换成高版本的

原创粉丝点击