Sqoop匯入資料異常處理

z597011036發表於2019-01-30

1.錯誤提示(沒有json.jar包)

19/01/30 11:59:48 INFO manager.DirectMySQLManager: Beginning mysqldump fast path import

19/01/30 11:59:48 INFO mapreduce.ImportJobBase: Beginning import of t3

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:780)

at org.apache.sqoop.mapreduce.JobBase.putSqoopOptionsToConfiguration(JobBase.java:392)

at org.apache.sqoop.mapreduce.JobBase.createJob(JobBase.java:378)

at org.apache.sqoop.mapreduce.ImportJobBase.runImport(ImportJobBase.java:256)

at org.apache.sqoop.manager.DirectMySQLManager.importTable(DirectMySQLManager.java:92)

at org.apache.sqoop.tool.ImportTool.importTable(ImportTool.java:513)

at org.apache.sqoop.tool.ImportTool.run(ImportTool.java:621)

at org.apache.sqoop.Sqoop.run(Sqoop.java:147)


解決方法:

參考文件:

下載json包:

將下載的json.tar包上傳到/opt/cloudera/parcels/CDH/lib/sqoop/lib中。


2.其它CDH節點沒有mysqldump命令(因為匯入時加了--direct引數)

19/01/30 13:59:29 INFO mapreduce.Job:  map 0% reduce 0%

19/01/30 13:59:33 INFO mapreduce.Job: Task Id : attempt_1545874390047_0006_m_000000_0, Status : FAILED

Error: java.io.IOException: Cannot run program "mysqldump": error=2, 沒有那個檔案或目錄

at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)

at java.lang.Runtime.exec(Runtime.java:620)

at java.lang.Runtime.exec(Runtime.java:485)

at org.apache.sqoop.mapreduce.MySQLDumpMapper.map(MySQLDumpMapper.java:405)

at org.apache.sqoop.mapreduce.MySQLDumpMapper.map(MySQLDumpMapper.java:49)

at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:145)

at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:793)


解決方法:

[root@jingong01 ~]# scp /usr/bin/mysqldump root@192.168.7.32:/usr/bin/

mysqldump                                        100% 3102KB   3.0MB/s   00:00    

[root@jingong01 ~]#


3.Sqoop缺少hive包

19/01/30 14:15:50 WARN hive.TableDefWriter: Column CREATETIME had to be cast to a less precise type in Hive

19/01/30 14:15:50 WARN hive.TableDefWriter: Column UPDATETIME had to be cast to a less precise type in Hive

19/01/30 14:15:50 INFO hive.HiveImport: Loading uploaded data into Hive

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/hive/shims/ShimLoader

at org.apache.hadoop.hive.conf.HiveConf$ConfVars.<clinit>(HiveConf.java:370)

at org.apache.hadoop.hive.conf.HiveConf.<clinit>(HiveConf.java:108)

at java.lang.Class.forName0(Native Method)

at java.lang.Class.forName(Class.java:264)

at org.apache.sqoop.hive.HiveConfig.getHiveConf(HiveConfig.java:44)

at org.apache.sqoop.hive.HiveImport.getHiveArgs(HiveImport.java:392)

at org.apache.sqoop.hive.HiveImport.executeExternalHiveScript(HiveImport.java:379)

at org.apache.sqoop.hive.HiveImport.executeScript(HiveImport.java:337)

at org.apache.sqoop.hive.HiveImport.importTable(HiveImport.java:241)

at org.apache.sqoop.tool.ImportTool.importTable(ImportTool.java:530)

at org.apache.sqoop.tool.ImportTool.run(ImportTool.java:621)

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:234)


解決方法:

[root@jingong01 ~]# cp -a  /opt/cloudera/parcels/CDH/lib/hive/lib/hive-shims* /opt/cloudera/parcels/CDH/lib/sqoop/lib/              --將hive下面的hive-shims包全部考到sqoop下面。


4.在hive中已建立表,在匯入時加了建立表引數

19/01/30 14:30:20 INFO hive.HiveImport: WARN: The method class org.apache.commons.logging.impl.SLF4JLogFactory#release() was invoked.

19/01/30 14:30:20 INFO hive.HiveImport: WARN: Please see for an explanation.

19/01/30 14:30:21 ERROR tool.ImportTool: Import failed: java.io.IOException: Hive exited with status 64

at org.apache.sqoop.hive.HiveImport.executeExternalHiveScript(HiveImport.java:384)

at org.apache.sqoop.hive.HiveImport.executeScript(HiveImport.java:337)

at org.apache.sqoop.hive.HiveImport.importTable(HiveImport.java:241)

at org.apache.sqoop.tool.ImportTool.importTable(ImportTool.java:530)

at org.apache.sqoop.tool.ImportTool.run(ImportTool.java:621)

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)


解決方法:

[hdfs@jingong01 ~]$ sqoop import --connect jdbc:mysql://172.16.8.93:3306/db_stktag --username wangying --password wangying --table t3 --target-dir /user/tong/123 --hive-import --create-hive-table --num-mappers 1 --hive-table TT3 -m 1 --split-by date --direct        --去掉紅色引數


5.使用sqoop抽取資料時,提示8032埠拒絕連線

19/03/19 10:22:42 INFO ipc.Client: Retrying connect to server: 0.0.0.0/0.0.0.0:8032. Already tried 9 time(s); retry policy is RetryUpToMaximumCountWithFixedSleep(maxRetries=10, sleepTime=1000 MILLISECONDS)

19/03/19 10:22:42 WARN ipc.Client: Failed to connect to server: 0.0.0.0/0.0.0.0:8032: retries get failed due to exceeded maximum allowed retries number: 10

java.net.ConnectException: 拒絕連線

at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)

at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)

at org.apache.hadoop.net.SocketIOWithTimeout.connect(SocketIOWithTimeout.java:206)

at org.apache.hadoop.net.NetUtils.connect(NetUtils.java:531)

at org.apache.hadoop.ipc.Client$Connection.setupConnection(Client.java:685)

at org.apache.hadoop.ipc.Client$Connection.setupIOstreams(Client.java:788)

at org.apache.hadoop.ipc.Client$Connection.access$3500(Client.java:410)

at org.apache.hadoop.ipc.Client.getConnection(Client.java:1550)


解決方法:

[root@node1 ~]# vim /opt/hadoop-2.8.5/etc/hadoop/yarn-site.xml 

    <property>
        <name>yarn.resourcemanager.address</name>
        <value>node1:8032</value>
    </property>
    <property>
        <name>yarn.resourcemanager.scheduler.address</name>
        <value>node1:8030</value>
    </property>
    <property>
        <name>yarn.resourcemanager.resource-tracker.address</name>
        <value>node1:8031</value>
    </property>

[root@node1 ~]# 


6.使用hbase和hive時老卡在Running job不動,不向下執行

19/03/19 11:20:09 INFO mapreduce.JobSubmitter: Submitting tokens for job: job_1552965562217_0001

19/03/19 11:20:10 INFO impl.YarnClientImpl: Submitted application application_1552965562217_0001

19/03/19 11:20:10 INFO mapreduce.Job: The url to track the job:

19/03/19 11:20:10 INFO mapreduce.Job: Running job: job_1552965562217_0001


解決方法:

[root@node1 ~]# vim /opt/hadoop-2.8.5/etc/hadoop/yarn-site.xml   --限制記憶體,cpu的資源,並將配置檔案同步到其它node,重啟hadoop服務

    <property>
        <name>yarn.nodemanager.resource.memory-mb</name>
        <value>2048</value>
    </property>
    <property>
        <name>yarn.nodemanager.resource.cpu-vcores</name>
        <value>2</value>
    </property>

[root@node1 ~]# 


7.將mysql資料匯入到hive中報找不到hive包

19/03/19 14:34:25 INFO hive.HiveImport: Loading uploaded data into Hive

19/03/19 14:34:25 ERROR hive.HiveConfig: Could not load org.apache.hadoop.hive.conf.HiveConf. Make sure HIVE_CONF_DIR is set correctly.

19/03/19 14:34:25 ERROR tool.ImportTool: Import failed: java.io.IOException: java.lang.ClassNotFoundException: org.apache.hadoop.hive.conf.HiveConf

at org.apache.sqoop.hive.HiveConfig.getHiveConf(HiveConfig.java:50)

at org.apache.sqoop.hive.HiveImport.getHiveArgs(HiveImport.java:392)

at org.apache.sqoop.hive.HiveImport.executeExternalHiveScript(HiveImport.java:379)


解決方法:

[root@node1 ~]# vim /etc/profile    --新增lib變數

export HADOOP_CLASSPATH=/opt/hive-2.3.4/lib/*

[root@node1 ~]# source /etc/profile


8.使用sqoop匯入hive時提示jackson包衝突

19/03/19 15:32:11 INFO ql.Driver: Concurrency mode is disabled, not creating a lock manager

19/03/19 15:32:11 INFO ql.Driver: Executing command(queryId=root_20190319153153_63feddd9-a2c8-4217-97d4-23dd9840a54b): CREATE TABLE `tt` ( `TBL_GRANT_ID` BIGINT, `CREATE_TIME` INT, 

`GRANT_OPTION` INT, `GRANTOR` STRING, `GRANTOR_TYPE` STRING, `PRINCIPAL_NAME` STRING, `PRINCIPAL_TYPE` STRING, `TBL_PRIV` STRING, `TBL_ID` BIGINT) COMMENT 'Imported by sqoop on 2019/03/19 

15:31:49' ROW FORMAT DELIMITED FIELDS TERMINATED BY '\001' LINES TERMINATED BY '\012' STORED AS TEXTFILE

19/03/19 15:32:11 INFO ql.Driver: Starting task [Stage-0:DDL] in serial mode

19/03/19 15:32:12 ERROR exec.DDLTask: java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.ObjectMapper.readerFor(Ljava/lang/Class;)Lcom/fasterxml/jackson/databind/ObjectReader;

at org.apache.hadoop.hive.common.StatsSetupConst$ColumnStatsAccurate.<clinit>(StatsSetupConst.java:165)

at org.apache.hadoop.hive.common.StatsSetupConst.parseStatsAcc(StatsSetupConst.java:297)

at org.apache.hadoop.hive.common.StatsSetupConst.setBasicStatsState(StatsSetupConst.java:230)

at org.apache.hadoop.hive.common.StatsSetupConst.setBasicStatsStateForCreateTable(StatsSetupConst.java:292)


解決方法:

[root@node1 ~]# mv /opt/sqoop-1.4.7/lib/jackson-* /home/

[root@node1 ~]# cp -a /opt/hive-2.3.4/lib/jackson-* /opt/sqoop-1.4.7/lib/  


9.建立表和匯入資料到hive時沒有使用分隔符

19/03/19 18:38:40 INFO metastore.HiveMetaStore: 0: Done cleaning up thread local RawStore

19/03/19 18:38:40 INFO HiveMetaStore.audit: ugi=root ip=unknown-ip-addr cmd=Done cleaning up thread local RawStore

19/03/19 18:38:40 ERROR tool.ImportTool: Import failed: java.io.IOException: Hive CliDriver exited with status=1

at org.apache.sqoop.hive.HiveImport.executeScript(HiveImport.java:355)

at org.apache.sqoop.hive.HiveImport.importTable(HiveImport.java:241)

at org.apache.sqoop.tool.ImportTool.importTable(ImportTool.java:537)

at org.apache.sqoop.tool.ImportTool.run(ImportTool.java:628)


解決方法:

create table t1(a int,b int) row format delimited fields terminated by '\t';      --建立表時必須加分隔符

sqoop import --connect jdbc:mysql://172.16.9.100/hive --username hive --password system --table TBL_PRIVS  --target-dir /user/sqoop --direct -m 1 --fields-terminated-by '\t' 



來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/25854343/viewspace-2565234/,如需轉載,請註明出處,否則將追究法律責任。

相關文章