更新时间:2022-12-14 GMT+08:00

Sqoop从hive到mysql8.0报格式错误

本章节仅适用于MRS 3.1.0版本集群。

用户问题

310集群Sqoop从hive到mysql8.0报格式错误。

问题现象

原因分析

通过日志判断得知是格式异常。

处理步骤

确认分隔符、表字段的格式无问题,在sqoop语句中添加--columns绑定对应字段。

sqoop export --connect jdbc:mysql://IP:端口号/数据库名 --username 用户名 --password 密码 --table 表名 --columns 列字段(多个列用英文逗号分开) -export-dir 导出地址 --fields-terminated-by 分隔符 --input-null-string '\\N' --input-null-non-string '\\N' -m 1

样例:

sqoop export --connect jdbc:mysql://172.16.0.6:3306/lidengpeng --username root --password Mrs@2021 --table hkatg_agr_prod_city_summ --columns year,city_name,city_code,prod_code,prod_name,prod_type,sown_area,area_unit,yield_wegt,yield_unit,total_wegt,total_wegt_unit,data_sorc_code,etl_time -export-dir hdfs://hacluster/user/hive/warehouse/dm_agr_prod_city_summ02 --fields-terminated-by ',' --input-null-string '\\N' --input-null-non-string '\\N' -m 1