无法使用 Sqoop 将数据从 Oracle 导入到 HDFS

Unable to import data from Oracle to HDFS using Sqoop

我正在尝试使用以下命令将数据从 oracle XE 数据库导入 HDFS :

sudo sqoop import -connect jdbc:oracle:thin:system/system@192.xxx.xx.x:1521:xe -username system -P -table employee -columns "ID" -target-dir sqoopoutput1 -m 1

但是它抛出异常说 table 未找到。

Warning: /usr/lib/sqoop/../accumulo does not exist! Accumulo imports will fail.
Please set $ACCUMULO_HOME to the root of your Accumulo installation.
17/08/28 00:05:41 INFO sqoop.Sqoop: Running Sqoop version: 1.4.6-cdh5.8.0
Enter password: 
17/08/28 00:05:44 INFO oracle.OraOopManagerFactory: Data Connector for Oracle and Hadoop is disabled.
17/08/28 00:05:44 INFO manager.SqlManager: Using default fetchSize of 1000
17/08/28 00:05:44 INFO tool.CodeGenTool: Beginning code generation
17/08/28 00:05:48 INFO manager.OracleManager: Time zone has been set to GMT
17/08/28 00:05:49 INFO manager.SqlManager: Executing SQL statement: SELECT t.* FROM "employee" t WHERE 1=0
17/08/28 00:05:49 ERROR manager.SqlManager: Error executing statement: java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist

java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist

    at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:221)
    at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:118)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:224)
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:468)
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:418)
    at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:1085)
    at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:216)
    at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:1033)
    at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:1140)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1472)
    at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3875)
    at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3945)
    at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:4514)
    at org.apache.sqoop.manager.SqlManager.execute(SqlManager.java:777)
    at org.apache.sqoop.manager.SqlManager.execute(SqlManager.java:786)
    at org.apache.sqoop.manager.SqlManager.getColumnInfoForRawQuery(SqlManager.java:289)
    at org.apache.sqoop.manager.SqlManager.getColumnTypesForRawQuery(SqlManager.java:260)
    at org.apache.sqoop.manager.SqlManager.getColumnTypes(SqlManager.java:246)
    at org.apache.sqoop.manager.ConnManager.getColumnTypes(ConnManager.java:327)
    at org.apache.sqoop.orm.ClassWriter.getColumnTypes(ClassWriter.java:1861)
    at org.apache.sqoop.orm.ClassWriter.generate(ClassWriter.java:1661)
    at org.apache.sqoop.tool.CodeGenTool.generateORM(CodeGenTool.java:107)
    at org.apache.sqoop.tool.ImportTool.importTable(ImportTool.java:488)
    at org.apache.sqoop.tool.ImportTool.run(ImportTool.java:615)
    at org.apache.sqoop.Sqoop.run(Sqoop.java:143)
    at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
    at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:179)
    at org.apache.sqoop.Sqoop.runTool(Sqoop.java:218)
    at org.apache.sqoop.Sqoop.runTool(Sqoop.java:227)
    at org.apache.sqoop.Sqoop.main(Sqoop.java:236)
17/08/28 00:05:49 ERROR tool.ImportTool: Encountered IOException running import job: java.io.IOException: No columns to generate for ClassWriter
    at org.apache.sqoop.orm.ClassWriter.generate(ClassWriter.java:1667)
    at org.apache.sqoop.tool.CodeGenTool.generateORM(CodeGenTool.java:107)
    at org.apache.sqoop.tool.ImportTool.importTable(ImportTool.java:488)
    at org.apache.sqoop.tool.ImportTool.run(ImportTool.java:615)
    at org.apache.sqoop.Sqoop.run(Sqoop.java:143)
    at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
    at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:179)
    at org.apache.sqoop.Sqoop.runTool(Sqoop.java:218)
    at org.apache.sqoop.Sqoop.runTool(Sqoop.java:227)
    at org.apache.sqoop.Sqoop.main(Sqoop.java:236)

Table 存在于 XE 数据库中(我尝试使用不带引号的 table 名称,这与 sqoop 尝试查询的方式不同)

select * from employee

请帮忙。

使用大写的 table 名称。

sqoop import -connect jdbc:oracle:thin:system/system@192.xxx.xx.x:1521:xe -username system -P -table EMPLOYEE -columns "ID" -target-dir sqoopoutput1 -m