当我们想要借助kettle将MySQL表数据导入HDFS上时,报如下错误:
2024/09/12 19:40:25 - mysql2hsfs - 为了转换解除补丁开始 [mysql2hsfs]
2024/09/12 19:40:25 - Hadoop file output.0 - ERROR (version 9.1.0.0-324, build 9.1.0.0-324 from 2020-09-07 05.09.05 by buildguy) : Couldn't open file hdfs://bigdata01:9820/aa/aaa.txt
2024/09/12 19:40:25 - Hadoop file output.0 - ERROR (version 9.1.0.0-324, build 9.1.0.0-324 from 2020-09-07 05.09.05 by buildguy) : org.pentaho.di.core.exception.KettleException:
2024/09/12 19:40:25 - Hadoop file output.0 - Error opening new file : java.lang.RuntimeException: com.ctc.wstx.exc.WstxIOException: Invalid UTF-8 middle byte 0x3f (at char #1687, byte #20)
此时,猜想可能为字符集的问题
解决方案:
进入kettle安装目录,用编辑器打开spoon.bat文件并修改:
"-Dfile.encoding=UTF-8"
保存后重启kettle
在Hadoop file output中我们可以浏览到hdfs文件系统,大概率有戏。
重新执行转换,错误得到解决!!
去hdfs看一下,数据是否导入成功:
数据导入成功,问题完美解决!!!!