hive向mysql导入数据sqoop命令出错
报错信息:
java.lang.Exception: java.io.IOException: java.lang.ClassNotFoundException: info
at org.apache.hadoop.mapred.LocalJobRunner$Job.runTasks(LocalJobRunner.java:492)
at org.apache.hadoop.mapred.LocalJobRunner$Job.run(LocalJobRunner.java:552)
Caused by: java.io.IOException: java.lang.ClassNotFoundException: info
at org.apache.sqoop.mapreduce.TextExportMapper.setup(TextExportMapper.java:70)
at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:143)
at org.apache.sqoop.mapreduce.AutoProgressMapper.run(AutoProgressMapper.java:64)
at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:799)
at org.apache.hadoop.mapred.MapTask.run(MapTask.java:347)
at org.apache.hadoop.mapred.LocalJobRunner$Job$MapTaskRunnable.run(LocalJobRunner.java:271)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassNotFoundException: info
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at org.apache.sqoop.mapreduce.TextExportMapper.setup(TextExportMapper.java:66)
... 10 more
2021-09-30 12:12:25,768 INFO mapreduce.Job: Job job_local1274913908_0001 running in uber mode : false
2021-09-30 12:12:25,777 INFO mapreduce.Job: map 0% reduce 0%
2021-09-30 12:12:25,778 INFO mapreduce.Job: Job job_local1274913908_0001 failed with state FAILED due to: NA
2021-09-30 12:12:25,791 INFO mapreduce.Job: Counters: 0
2021-09-30 12:12:25,799 WARN mapreduce.Counters: Group FileSystemCounters is deprecated. Use org.apache.hadoop.mapreduce.FileSystemCounter instead
2021-09-30 12:12:25,801 INFO mapreduce.ExportJobBase: Transferred 0 bytes in 2.1514 seconds (0 bytes
c)
2021-09-30 12:12:25,802 WARN mapreduce.Counters: Group org.apache.hadoop.mapred.Task$Counter is deprecated. Use org.apache.hadoop.mapreduce.TaskCounter instead
2021-09-30 12:12:25,802 INFO mapreduce.ExportJobBase: Exported 0 records.
2021-09-30 12:12:25,802 ERROR tool.ExportTool: Error during export: Export job failed!
at org.apache.hadoop.mapred.LocalJobRunner$Job.runTasks(LocalJobRunner.java:492)
at org.apache.hadoop.mapred.LocalJobRunner$Job.run(LocalJobRunner.java:552)
Caused by: java.io.IOException: java.lang.ClassNotFoundException: info
at org.apache.sqoop.mapreduce.TextExportMapper.setup(TextExportMapper.java:70)
at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:143)
at org.apache.sqoop.mapreduce.AutoProgressMapper.run(AutoProgressMapper.java:64)
at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:799)
at org.apache.hadoop.mapred.MapTask.run(MapTask.java:347)
at org.apache.hadoop.mapred.LocalJobRunner$Job$MapTaskRunnable.run(LocalJobRunner.java:271)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ClassNotFoundException: info
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at org.apache.sqoop.mapreduce.TextExportMapper.setup(TextExportMapper.java:66)
... 10 more
2021-09-30 12:12:25,768 INFO mapreduce.Job: Job job_local1274913908_0001 running in uber mode : false
2021-09-30 12:12:25,777 INFO mapreduce.Job: map 0% reduce 0%
2021-09-30 12:12:25,778 INFO mapreduce.Job: Job job_local1274913908_0001 failed with state FAILED due to: NA
2021-09-30 12:12:25,791 INFO mapreduce.Job: Counters: 0
2021-09-30 12:12:25,799 WARN mapreduce.Counters: Group FileSystemCounters is deprecated. Use org.apache.hadoop.mapreduce.FileSystemCounter instead
2021-09-30 12:12:25,801 INFO mapreduce.ExportJobBase: Transferred 0 bytes in 2.1514 seconds (0 bytes
2021-09-30 12:12:25,802 WARN mapreduce.Counters: Group org.apache.hadoop.mapred.Task$Counter is deprecated. Use org.apache.hadoop.mapreduce.TaskCounter instead
2021-09-30 12:12:25,802 INFO mapreduce.ExportJobBase: Exported 0 records.
2021-09-30 12:12:25,802 ERROR tool.ExportTool: Error during export: Export job failed!
解决方法:
解决方法:
当你每次执行失败后,其实在/tmp/sqoop-你的用户名/compile(或者是/tmp/sqoop/compile,可以找找看)文件夹下有许多临时文件夹,文件夹名称为一大串字符,每个文件夹内有对应表名生成的.jar包、.java和.class文件。将这三个文件拷贝到你的sqoop安装目录
b文件夹下即可解决。
PS:如果你不知道哪个文件夹下是你这次执行任务产生到文件有两种解决方法:
把文件夹按时间排序,找最新到一个,或者把全部文件夹删除重新执行一遍命令也行(删除文件总有一丝丝风险)。
在执行命令时加上--blind yourdirectory参数,指定生成文件的位置,移动完成后重新执行命令——当然,如果有权限的话可以直接写到你的sqoop安装目录
b下,这样可以省去移文件的麻烦。
示例
sqoop export --connect jdbc:mysql://localhost:3306
taobao --username root --password 123456 --table user_log --export-dir
'/user/hive/warehouse
taobao.db/inner_user_log'
--bindir ./ --fields-terminated-by ',';
1
2
3
还有一个错误,可能会遇到:
ERROR tool.ExportTool: Encountered IOException running export job: java.io.IOException: No columns to generate for ClassWriter
原因:多半儿是因为mysql的链接问题,可以看看是不是密码输入错误。
注意
hive表和mysql表字段类型和数量要一致,mysql表编码要指定utf8。
可以暂时不需要安装Zokeeper。
参考:
link1
link2
link3
link4
————————————————
原文链接:https://blog.csdn.net/mbest6/article/details/105606166
当你每次执行失败后,其实在/tmp/sqoop-你的用户名/compile(或者是/tmp/sqoop/compile,可以找找看)文件夹下有许多临时文件夹,文件夹名称为一大串字符,每个文件夹内有对应表名生成的.jar包、.java和.class文件。将这三个文件拷贝到你的sqoop安装目录
PS:如果你不知道哪个文件夹下是你这次执行任务产生到文件有两种解决方法:
把文件夹按时间排序,找最新到一个,或者把全部文件夹删除重新执行一遍命令也行(删除文件总有一丝丝风险)。
在执行命令时加上--blind yourdirectory参数,指定生成文件的位置,移动完成后重新执行命令——当然,如果有权限的话可以直接写到你的sqoop安装目录
示例
sqoop export --connect jdbc:mysql://localhost:3306
'/user/hive/warehouse
--bindir ./ --fields-terminated-by ',';
1
2
3
还有一个错误,可能会遇到:
ERROR tool.ExportTool: Encountered IOException running export job: java.io.IOException: No columns to generate for ClassWriter
原因:多半儿是因为mysql的链接问题,可以看看是不是密码输入错误。
注意
hive表和mysql表字段类型和数量要一致,mysql表编码要指定utf8。
可以暂时不需要安装Zokeeper。
参考:
link1
link2
link3
link4
————————————————
原文链接:https://blog.csdn.net/mbest6/article/details/105606166