在运行Sqoop作业时,能否请您帮助解决以下问题: 我创建了一个Sqoop作业,如下所示:
sqoop job --create sqoop_inc_load -- import
--connect jdbc:mysql://localhost/product_schema
--username root
--password root
--table temp_value2
--split-by department_id
--target-dir /Sqoopimport/incm_load_new
--append
--incremental append
--check-column department_id
--last-value 0
创建作业后获得此输出:
19/03/16 18:27:55 INFO sqoop.Sqoop: Running Sqoop version: 1.4.7
19/03/16 18:27:56 WARN tool.BaseSqoopTool: Setting your password on the command-line is insecure. Consider using -P instead.
Exception in thread "main" java.lang.NoClassDefFoundError: org/json/JSONObject
at org.apache.sqoop.util.SqoopJsonUtil.getJsonStringforMap(SqoopJsonUtil.java:43)
at org.apache.sqoop.SqoopOptions.writeProperties(SqoopOptions.java:785)
at org.apache.sqoop.metastore.hsqldb.HsqldbJobStorage.createInternal(HsqldbJobStorage.java:399)
at org.apache.sqoop.metastore.hsqldb.HsqldbJobStorage.create(HsqldbJobStorage.java:379)
at org.apache.sqoop.tool.JobTool.createJob(JobTool.java:181)
at org.apache.sqoop.tool.JobTool.run(JobTool.java:294)
at org.apache.sqoop.Sqoop.run(Sqoop.java:147)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:76)
at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:183)
at org.apache.sqoop.Sqoop.runTool(Sqoop.java:234)
at org.apache.sqoop.Sqoop.runTool(Sqoop.java:243)
at org.apache.sqoop.Sqoop.main(Sqoop.java:252)
Caused by: java.lang.ClassNotFoundException: org.json.JSONObject
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)
然后,我已按以下步骤执行了工作:
$ sqoop job --exec sqoop_inc_load
Warning: /usr/local/hadoop-env/sqoop-1.4.7/../hbase does not exist! HBase imports will fail.
Please set $HBASE_HOME to the root of your HBase installation.
Warning: /usr/local/hadoop-env/sqoop-1.4.7/../hcatalog does not exist! HCatalog jobs will fail.
Please set $HCAT_HOME to the root of your HCatalog installation.
Warning: /usr/local/hadoop-env/sqoop-1.4.7/../accumulo does not exist! Accumulo imports will fail.
Please set $ACCUMULO_HOME to the root of your Accumulo installation.
Warning: /usr/local/hadoop-env/sqoop-1.4.7/../zookeeper does not exist! Accumulo imports will fail.
Please set $ZOOKEEPER_HOME to the root of your Zookeeper installation.
19/03/16 18:31:33 INFO sqoop.Sqoop: Running Sqoop version: 1.4.7
--table or --query is required for import. (Or use sqoop import-all-tables.)
Try --help for usage instructions.
收到上述消息后,您能检查一下并让我知道我在哪里做错了吗?
答案 0 :(得分:0)
在使用增量追加时,我们遇到了相同的错误。默认情况下,类名与表名相同。 添加以下参数。
--class-name {table_name}
对于您而言,可以这样做。
--class-name temp_value2
更多详细信息,请here
答案 1 :(得分:0)
解决方案
下载Java-json jar文件并保存在/ var / lib / sqoop目录中。 然后运行您的sqoop命令。
对于jar,请使用下面的链接 http://www.java2s.com/Code/Jar/j/Downloadjavajsonjar.htm