Sqoop操作前提:关闭防火墙+开启集群保证其正常。
!!如果第一次输入命令失败,我建议再试一次,手动输入不要直接粘贴。
1.Exception:找不到 class allclo
百度了很久才找到解决办法
即在sqoop的安装目录下执行这句话
./bin/sqoop export --connect jdbc:mysql://localhost:3306/clothing --username root --password Root123! --table allclo --m 1 --export-dir /clo_res.txt --input-fields-terminated-by " " --bindir ./
代码解释
./bin/sqoop export \
--connect jdbc:mysql://localhost:3306/clothing \ # localhost可换,看自己MySQL的权限,一般是这个;我的数据库为clothing
--username root --password Root123! \ #填写自己的密码
--table allclo \ # 我的表为allclo
--m 1 \
--export-dir /clo_res.txt \ # 从HDFS上哪个文件导出数据
--input-fields-terminated-by " " \ # 分隔符为空格,可修改为自己的分隔符
--bindir ./
2.主键报错MySQLIntegrityConstraintViolationException: Duplicate entry ‘100’ for key 'PRIMARY’
在MySQL中建立表的时候
同样也是执行这句话
./bin/sqoop export --connect jdbc:mysql://localhost:3306/clothing --username root --password Root123! --table allclo --m 1 --export-dir /clo_res.txt --input-fields-terminated-by " " --bindir ./