我尝试使用sqoop将文件从hdfs插入Oracle数据库。 文件看起来像这样:
-bash-4.1$ hadoop fs -cat ./hdpcd/osoba_hdfs.txt
1,pawel,kowalski,36
2,john,smith,55
3,paul,psmithski,44
4,jakub,kowalski,70
5,scott,tiger,70
目的地表尽可能简单:
CREATE TABLE OSOBA_HDFS
( ID NUMBER,
IMIE VARCHAR2(100 BYTE),
NAZWISKO VARCHAR2(100 BYTE),
WIEK NUMBER)
当我像这样使用sqoop导出时:
sqoop export --connect "jdbc:oracle:thin:@localhost:1521/ora_db" --username "pkowalski5" --password "password" \
--table osoba_hdfs --export-dir ./hdpcd
它工作正常。
但是当我尝试使用--update-key参数时:
sqoop export --connect "jdbc:oracle:thin:@localhost:1521/ora_db" --username "pkowalski5" --password "password" \
--table osoba_hdfs --export-dir ./hdpcd --update-key id
我得到例外:
-bash-4.1$ sqoop export --connect "jdbc:oracle:thin:@localhost:1521/ora_db" --username "pkowalski5" --password "password" \
> --table osoba_hdfs --export-dir ./hdpcd --update-key id
Warning: /usr/lib/sqoop/../accumulo does not exist! Accumulo imports will fail.
Please set $ACCUMULO_HOME to the root of your Accumulo installation.
15/05/06 14:37:41 INFO sqoop.Sqoop: Running Sqoop version: 1.4.4.2.1.1.0-385
15/05/06 14:37:41 WARN tool.BaseSqoopTool: Setting your password on the command-line is insecure. Consider using -P instead.
15/05/06 14:37:42 INFO manager.SqlManager: Using default fetchSize of 1000
15/05/06 14:37:43 INFO oraoop.OraOopOracleQueries: Current schema is: PKOWALSKI5
15/05/06 14:37:43 INFO oraoop.OraOopManagerFactory:
***********************************************************************************
*** Using Quest® Data Connector for Oracle and Hadoop 1.7.0.2.1.1.0-385-hdp-385 ***
*** Copyright 2012 Quest Software, Inc. ***
*** ALL RIGHTS RESERVED. ***
***********************************************************************************
15/05/06 14:37:43 INFO oraoop.OraOopManagerFactory: Oracle Database version: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
(...)
15/05/06 14:37:44 INFO Configuration.deprecation: mapred.map.max.attempts is deprecated. Instead, use mapreduce.map.maxattempts
15/05/06 14:37:44 INFO manager.SqlManager: Executing SQL statement: SELECT ID,IMIE,NAZWISKO,WIEK FROM osoba_hdfs WHERE 1=0
15/05/06 14:37:44 INFO tool.CodeGenTool: Beginning code generation
15/05/06 14:37:44 INFO manager.SqlManager: Executing SQL statement: SELECT "ID","IMIE","NAZWISKO","WIEK" FROM osoba_hdfs WHERE 0=1
15/05/06 14:37:44 INFO manager.SqlManager: Executing SQL statement: SELECT ID,IMIE,NAZWISKO,WIEK FROM osoba_hdfs WHERE 1=0
15/05/06 14:37:45 ERROR sqoop.Sqoop: Got exception running Sqoop: java.lang.NullPointerException
java.lang.NullPointerException
at org.apache.sqoop.orm.ClassWriter.generateDbWrite(ClassWriter.java:668)
at org.apache.sqoop.orm.ClassWriter.generateClassForColumns(ClassWriter.java:1381)
at org.apache.sqoop.orm.ClassWriter.generate(ClassWriter.java:1197)
at org.apache.sqoop.tool.CodeGenTool.generateORM(CodeGenTool.java:96)
at org.apache.sqoop.tool.ExportTool.exportTable(ExportTool.java:64)
at org.apache.sqoop.tool.ExportTool.run(ExportTool.java:100)
at org.apache.sqoop.Sqoop.run(Sqoop.java:147)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:183)
at org.apache.sqoop.Sqoop.runTool(Sqoop.java:222)
at org.apache.sqoop.Sqoop.runTool(Sqoop.java:231)
at org.apache.sqoop.Sqoop.main(Sqoop.java:240)
您是否知道可能导致此错误的原因是什么?
此致
的Pawel