使用 SQOOP 导入 SQL SERVER 2008 R2 数据出错
出现如下错误:
[root@hserver ~]# sqoop-1.2.0/bin/sqoop import-all-tables --connect 'jdbc:sqlserver://192.168.1.246;username=sa;password=sssss;database=sssssss'
11/10/25 01:30:21 INFO tool.CodeGenTool: Beginning code generation
11/10/25 01:30:21 INFO manager.SqlManager: Executing SQL statement: SELECT TOP 1 * FROM [blacklist]
11/10/25 01:30:21 INFO manager.SqlManager: Executing SQL statement: SELECT TOP 1 * FROM [blacklist]
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/mapreduce/lib/db/DBWritable
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
at com.cloudera.sqoop.orm.ClassWriter.generateClassForColumns(ClassWriter.java:1091)
at com.cloudera.sqoop.orm.ClassWriter.generate(ClassWriter.java:990)
at com.cloudera.sqoop.tool.CodeGenTool.generateORM(CodeGenTool.java:82)
at com.cloudera.sqoop.tool.ImportTool.importTable(ImportTool.java:337)
at com.cloudera.sqoop.tool.ImportAllTablesTool.run(ImportAllTablesTool.java:64)
at com.cloudera.sqoop.Sqoop.run(Sqoop.java:144)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:65)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:79)
at com.cloudera.sqoop.Sqoop.runSqoop(Sqoop.java:180)
at com.cloudera.sqoop.Sqoop.runTool(Sqoop.java:218)
at com.cloudera.sqoop.Sqoop.main(Sqoop.java:228)
Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.mapreduce.lib.db.DBWritable
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 23 more
环境 : linux + hadoop 0.20.2 + Hive 0.90.4 + sqoop 1.2.0
原因分析 : sqoop 为 Clouder 公司开发的,好像跟原生的hadoop 有点不兼容的意思,下载 cloudera CDH3U0 ,(只试了这一个,u1,u2,u3应该也是可以的),解压 hadoop-0.20.2-cdh3u0,取出 hadoop-core-0.20.2-cdh3u0.jar,hadoop-tools-0.20.2-cdh3u0.jar,放于 sqoop1.2.0 的lib 目录下,然后就可以了。
结论: 开源是好东西,但是sqoop 这样的工具是某公司的,它会优先兼容自己的产品线,对于原生产品线可能不太兼容。虽然解决了这个问题,可能还会有其它一些未知的问题出现。
相关的一些图:
可以运行了。
JOB WEB
从 Eclise 插件中看到的DFS
数据