运行sqoop导入时出错 - ERROR manager.OracleManager:无法回滚事务

时间:2016-06-01 11:04:32

标签: hadoop hive sqoop

我正在使用sqoop将数据从oracle db加载到hive

规格:

CDH-5.5.1 Sqoop 1.4.2

初始化:

    export SQOOP_HOME=/opt/cloudera/parcels/CDH-5.5.1-1.cdh5.5.1.p0.11/lib/sqoop
    export HIVE_HOME=/opt/cloudera/parcels/CDH-5.5.1-1.cdh5.5.1.p0.11/lib/hive
    export HADOOP_CLASSPATH=/opt/cloudera/parcels/CDH-5.5.1-1.cdh5.5.1.p0.11/lib/sqoop/lib/ojdbc7.jar:/opt/cloudera/parcels/CDH-5.5.1-1.cdh5.5.1.p0.11/lib/hive/lib/*
    export HADOOP_USER_NAME=hdfs
    export PATH=$PATH:$HIVE_HOME/bin

Sqoop命令:

sqoop import --connect jdbc:oracle:thin:@<host>/<pluggable DB SID> --username username --password password --table tablename -m 1 --hive-import --hive-table hivetablename

执行时,我收到以下错误

    16/06/01 16:11:37 INFO manager.SqlManager: Executing SQL statement: SELECT t.* FROM VEHICLEDETAILS t WHERE 1=0
    16/06/01 16:11:37 WARN manager.SqlManager: SQLException closing ResultSet: java.sql.SQLException: Could not commit with auto-commit set on
    16/06/01 16:11:37 ERROR manager.OracleManager: Failed to rollback transaction
    java.sql.SQLException: Could not rollback with auto-commit set on
        at oracle.jdbc.driver.PhysicalConnection.rollback(PhysicalConnection.java:2423)
        at org.apache.sqoop.manager.OracleManager.getColumnNames(OracleManager.java:767)
        at org.apache.sqoop.orm.ClassWriter.getColumnNames(ClassWriter.java:1207)
        at org.apache.sqoop.orm.ClassWriter.generate(ClassWriter.java:1062)
        at org.apache.sqoop.tool.CodeGenTool.generateORM(CodeGenTool.java:82)
        at org.apache.sqoop.tool.ImportTool.importTable(ImportTool.java:390)
        at org.apache.sqoop.tool.ImportTool.run(ImportTool.java:476)
        at org.apache.sqoop.Sqoop.run(Sqoop.java:145)
        at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
        at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:181)
        at org.apache.sqoop.Sqoop.runTool(Sqoop.java:220)
        at org.apache.sqoop.Sqoop.runTool(Sqoop.java:229)
        at org.apache.sqoop.Sqoop.main(Sqoop.java:238)
    16/06/01 16:11:37 ERROR manager.OracleManager: Failed to list columns
    java.sql.SQLException: Could not commit with auto-commit set on
        at oracle.jdbc.driver.PhysicalConnection.commit(PhysicalConnection.java:2356)
        at oracle.jdbc.driver.PhysicalConnection.commit(PhysicalConnection.java:2403)
        at org.apache.sqoop.manager.OracleManager.getColumnNames(OracleManager.java:764)
        at org.apache.sqoop.orm.ClassWriter.getColumnNames(ClassWriter.java:1207)
        at org.apache.sqoop.orm.ClassWriter.generate(ClassWriter.java:1062)
        at org.apache.sqoop.tool.CodeGenTool.generateORM(CodeGenTool.java:82)
        at org.apache.sqoop.tool.ImportTool.importTable(ImportTool.java:390)
        at org.apache.sqoop.tool.ImportTool.run(ImportTool.java:476)
        at org.apache.sqoop.Sqoop.run(Sqoop.java:145)
        at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
        at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:181)
        at org.apache.sqoop.Sqoop.runTool(Sqoop.java:220)
        at org.apache.sqoop.Sqoop.runTool(Sqoop.java:229)
        at org.apache.sqoop.Sqoop.main(Sqoop.java:238)
    16/06/01 16:11:37 INFO orm.CompilationManager: HADOOP_HOME is /opt/cloudera/parcels/CDH-5.5.1-1.cdh5.5.1.p0.11/bin/../lib/sqoop/../hadoop
    Note: /tmp/sqoop-root/compile/1d122ab0d74da045fd45da7a765f595d/VEHICLEDETAILS.java uses or overrides a deprecated API.
    Note: Recompile with -Xlint:deprecation for details.
    16/06/01 16:11:38 INFO orm.CompilationManager: Writing jar file: /tmp/sqoop-root/compile/1d122ab0d74da045fd45da7a765f595d/VEHICLEDETAILS.jar
    16/06/01 16:11:38 ERROR manager.OracleManager: Failed to rollback transaction
    java.lang.NullPointerException
        at org.apache.sqoop.manager.OracleManager.getPrimaryKey(OracleManager.java:828)
        at org.apache.sqoop.manager.SqlManager.getSplitColumn(SqlManager.java:408)
        at org.apache.sqoop.manager.SqlManager.checkTableImportOptions(SqlManager.java:427)
        at org.apache.sqoop.manager.SqlManager.importTable(SqlManager.java:462)
        at org.apache.sqoop.manager.OracleManager.importTable(OracleManager.java:380)
        at org.apache.sqoop.tool.ImportTool.importTable(ImportTool.java:403)
        at org.apache.sqoop.tool.ImportTool.run(ImportTool.java:476)
        at org.apache.sqoop.Sqoop.run(Sqoop.java:145)
        at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
        at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:181)
        at org.apache.sqoop.Sqoop.runTool(Sqoop.java:220)
        at org.apache.sqoop.Sqoop.runTool(Sqoop.java:229)
        at org.apache.sqoop.Sqoop.main(Sqoop.java:238)
    16/06/01 16:11:38 ERROR manager.OracleManager: Failed to list columns
    java.sql.SQLException: Could not rollback with auto-commit set on
        at oracle.jdbc.driver.PhysicalConnection.rollback(PhysicalConnection.java:2423)
        at org.apache.sqoop.manager.OracleManager$ConnCache.getConnection(OracleManager.java:190)
        at org.apache.sqoop.manager.OracleManager.makeConnection(OracleManager.java:283)
        at org.apache.sqoop.manager.GenericJdbcManager.getConnection(GenericJdbcManager.java:52)
        at org.apache.sqoop.manager.OracleManager.getPrimaryKey(OracleManager.java:814)
        at org.apache.sqoop.manager.SqlManager.getSplitColumn(SqlManager.java:408)
        at org.apache.sqoop.manager.SqlManager.checkTableImportOptions(SqlManager.java:427)
        at org.apache.sqoop.manager.SqlManager.importTable(SqlManager.java:462)
        at org.apache.sqoop.manager.OracleManager.importTable(OracleManager.java:380)
        at org.apache.sqoop.tool.ImportTool.importTable(ImportTool.java:403)
        at org.apache.sqoop.tool.ImportTool.run(ImportTool.java:476)
        at org.apache.sqoop.Sqoop.run(Sqoop.java:145)
        at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
        at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:181)
        at org.apache.sqoop.Sqoop.runTool(Sqoop.java:220)
        at org.apache.sqoop.Sqoop.runTool(Sqoop.java:229)
        at org.apache.sqoop.Sqoop.main(Sqoop.java:238)
    16/06/01 16:11:39 INFO manager.OracleManager: Time zone has been set to GMT
    16/06/01 16:11:39 ERROR manager.OracleManager: Failed to rollback transaction
    java.sql.SQLException: Could not rollback with auto-commit set on
        at oracle.jdbc.driver.PhysicalConnection.rollback(PhysicalConnection.java:2423)
        at org.apache.sqoop.manager.OracleManager.getPrimaryKey(OracleManager.java:828)
        at org.apache.sqoop.manager.SqlManager.getSplitColumn(SqlManager.java:408)
        at org.apache.sqoop.manager.SqlManager.importTable(SqlManager.java:464)
        at org.apache.sqoop.manager.OracleManager.importTable(OracleManager.java:380)
        at org.apache.sqoop.tool.ImportTool.importTable(ImportTool.java:403)
        at org.apache.sqoop.tool.ImportTool.run(ImportTool.java:476)
        at org.apache.sqoop.Sqoop.run(Sqoop.java:145)
        at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
        at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:181)
        at org.apache.sqoop.Sqoop.runTool(Sqoop.java:220)
        at org.apache.sqoop.Sqoop.runTool(Sqoop.java:229)
        at org.apache.sqoop.Sqoop.main(Sqoop.java:238)
    16/06/01 16:11:39 ERROR manager.OracleManager: Failed to list columns
    java.sql.SQLException: Could not commit with auto-commit set on
        at oracle.jdbc.driver.PhysicalConnection.commit(PhysicalConnection.java:2356)
        at oracle.jdbc.driver.PhysicalConnection.commit(PhysicalConnection.java:2403)
        at org.apache.sqoop.manager.OracleManager.getPrimaryKey(OracleManager.java:825)
        at org.apache.sqoop.manager.SqlManager.getSplitColumn(SqlManager.java:408)
        at org.apache.sqoop.manager.SqlManager.importTable(SqlManager.java:464)
        at org.apache.sqoop.manager.OracleManager.importTable(OracleManager.java:380)
        at org.apache.sqoop.tool.ImportTool.importTable(ImportTool.java:403)
        at org.apache.sqoop.tool.ImportTool.run(ImportTool.java:476)
        at org.apache.sqoop.Sqoop.run(Sqoop.java:145)
        at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
        at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:181)
        at org.apache.sqoop.Sqoop.runTool(Sqoop.java:220)
        at org.apache.sqoop.Sqoop.runTool(Sqoop.java:229)
        at org.apache.sqoop.Sqoop.main(Sqoop.java:238)
    16/06/01 16:11:39 INFO mapreduce.ImportJobBase: Beginning import of VEHICLEDETAILS
    16/06/01 16:11:39 INFO Configuration.deprecation: mapred.jar is deprecated. Instead, use mapreduce.job.jar
    16/06/01 16:11:39 ERROR manager.OracleManager: Failed to rollback transaction
    java.lang.NullPointerException
        at org.apache.sqoop.manager.OracleManager.getColumnNames(OracleManager.java:767)
        at org.apache.sqoop.mapreduce.DataDrivenImportJob.configureInputFormat(DataDrivenImportJob.java:164)
        at org.apache.sqoop.mapreduce.ImportJobBase.runImport(ImportJobBase.java:194)
        at org.apache.sqoop.manager.SqlManager.importTable(SqlManager.java:465)
        at org.apache.sqoop.manager.OracleManager.importTable(OracleManager.java:380)
        at org.apache.sqoop.tool.ImportTool.importTable(ImportTool.java:403)
        at org.apache.sqoop.tool.ImportTool.run(ImportTool.java:476)
        at org.apache.sqoop.Sqoop.run(Sqoop.java:145)
        at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
        at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:181)
        at org.apache.sqoop.Sqoop.runTool(Sqoop.java:220)
        at org.apache.sqoop.Sqoop.runTool(Sqoop.java:229)
        at org.apache.sqoop.Sqoop.main(Sqoop.java:238)
    16/06/01 16:11:39 ERROR manager.OracleManager: Failed to list columns
    java.sql.SQLException: Could not rollback with auto-commit set on
        at oracle.jdbc.driver.PhysicalConnection.rollback(PhysicalConnection.java:2423)
        at org.apache.sqoop.manager.OracleManager$ConnCache.getConnection(OracleManager.java:190)
        at org.apache.sqoop.manager.OracleManager.makeConnection(OracleManager.java:283)
        at org.apache.sqoop.manager.GenericJdbcManager.getConnection(GenericJdbcManager.java:52)
        at org.apache.sqoop.manager.OracleManager.getColumnNames(OracleManager.java:751)
        at org.apache.sqoop.mapreduce.DataDrivenImportJob.configureInputFormat(DataDrivenImportJob.java:164)
        at org.apache.sqoop.mapreduce.ImportJobBase.runImport(ImportJobBase.java:194)
        at org.apache.sqoop.manager.SqlManager.importTable(SqlManager.java:465)
        at org.apache.sqoop.manager.OracleManager.importTable(OracleManager.java:380)
        at org.apache.sqoop.tool.ImportTool.importTable(ImportTool.java:403)
        at org.apache.sqoop.tool.ImportTool.run(ImportTool.java:476)
        at org.apache.sqoop.Sqoop.run(Sqoop.java:145)
        at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
        at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:181)
        at org.apache.sqoop.Sqoop.runTool(Sqoop.java:220)
        at org.apache.sqoop.Sqoop.runTool(Sqoop.java:229)
        at org.apache.sqoop.Sqoop.main(Sqoop.java:238)
    16/06/01 16:11:39 INFO Configuration.deprecation: mapred.map.tasks is deprecated. Instead, use mapreduce.job.maps
    16/06/01 16:11:39 INFO Configuration.deprecation: session.id is deprecated. Instead, use dfs.metrics.session-id
    16/06/01 16:11:39 INFO jvm.JvmMetrics: Initializing JVM Metrics with processName=JobTracker, sessionId=
    16/06/01 16:11:40 INFO mapreduce.JobSubmitter: Cleaning up the staging area file:/tmp/hadoop-root/mapred/staging/hdfs1761993336/.staging/job_local1761993336_0001
    Exception in thread "main" java.lang.IncompatibleClassChangeError: Found interface org.apache.hadoop.mapreduce.JobContext, but class was expected
        at org.apache.sqoop.config.ConfigurationHelper.getJobNumMaps(ConfigurationHelper.java:53)
        at com.cloudera.sqoop.config.ConfigurationHelper.getJobNumMaps(ConfigurationHelper.java:36)
        at org.apache.sqoop.mapreduce.db.DataDrivenDBInputFormat.getSplits(DataDrivenDBInputFormat.java:121)
        at org.apache.hadoop.mapreduce.JobSubmitter.writeNewSplits(JobSubmitter.java:304)
        at org.apache.hadoop.mapreduce.JobSubmitter.writeSplits(JobSubmitter.java:321)
        at org.apache.hadoop.mapreduce.JobSubmitter.submitJobInternal(JobSubmitter.java:199)
        at org.apache.hadoop.mapreduce.Job$10.run(Job.java:1307)
        at org.apache.hadoop.mapreduce.Job$10.run(Job.java:1304)
        at java.security.AccessController.doPrivileged(Native Method)
        at javax.security.auth.Subject.doAs(Subject.java:422)
        at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1671)
        at org.apache.hadoop.mapreduce.Job.submit(Job.java:1304)
        at org.apache.hadoop.mapreduce.Job.waitForCompletion(Job.java:1325)
        at org.apache.sqoop.mapreduce.ImportJobBase.runJob(ImportJobBase.java:141)
        at org.apache.sqoop.mapreduce.ImportJobBase.runImport(ImportJobBase.java:202)
        at org.apache.sqoop.manager.SqlManager.importTable(SqlManager.java:465)
        at org.apache.sqoop.manager.OracleManager.importTable(OracleManager.java:380)
        at org.apache.sqoop.tool.ImportTool.importTable(ImportTool.java:403)
        at org.apache.sqoop.tool.ImportTool.run(ImportTool.java:476)
        at org.apache.sqoop.Sqoop.run(Sqoop.java:145)
        at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
        at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:181)
        at org.apache.sqoop.Sqoop.runTool(Sqoop.java:220)
        at org.apache.sqoop.Sqoop.runTool(Sqoop.java:229)
        at org.apache.sqoop.Sqoop.main(Sqoop.java:238)

我正在使用ojdbc 7 jar和oracle 12c数据库以及jdk 8

2 个答案:

答案 0 :(得分:1)

使用"--query select * from VEHICLEDETAILS" instead of "--table VEHICLEDETAILS"

请参阅此帖子https://discuss.zendesk.com/hc/en-us/articles/204206528-Sqoop-import-fails-to-import-oracle-table-with-Could-not-commit-with-auto-commit-set-on-

答案 1 :(得分:0)

我使用以下查询从mysql将数据导入hive表。它也应该与Oracle一起使用。只需要修改jdbc url

sqoop import --connect jdbc:mysql://localhost:3306/retail_db --username retail_dba -P --table customers --target-dir /temp1 --hive-table stackOverflow --hive-import

请让我知道它是否有用