Sqoop导入数据异常怎么处理-成都创新互联网站建设

关于创新互联

多方位宣传企业产品与服务 突出企业形象

公司简介 公司的服务 荣誉资质 新闻动态 联系我们

Sqoop导入数据异常怎么处理

这篇文章主要介绍“Sqoop导入数据异常怎么处理”,在日常操作中,相信很多人在Sqoop导入数据异常怎么处理问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”Sqoop导入数据异常怎么处理”的疑惑有所帮助!接下来,请跟着小编一起来学习吧!

创新互联于2013年创立,先为泰和等服务建站,泰和等地企业,进行企业商务咨询服务。为泰和企业网站制作PC+手机+微官网三网同步一站式服务解决您的所有建站问题。

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)

解决方法:

参考文档:https://github.com/stleary/JSON-java

下载json包: https://search.maven.org/search?q=g:org.json%20AND%20a:json&core=gav

将下载的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.(HiveConf.java:370)

at org.apache.hadoop.hive.conf.HiveConf.(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 http://www.slf4j.org/codes.html#release 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 

    
        yarn.resourcemanager.address
        node1:8032
    
    
        yarn.resourcemanager.scheduler.address
        node1:8030
    
    
        yarn.resourcemanager.resource-tracker.address
        node1:8031
    

[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: http://node1:8088/proxy/application_1552965562217_0001/

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服务

    
        yarn.nodemanager.resource.memory-mb
        2048
    
    
        yarn.nodemanager.resource.cpu-vcores
        2
    

[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.(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' 

到此,关于“Sqoop导入数据异常怎么处理”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注创新互联网站,小编会继续努力为大家带来更多实用的文章!


名称栏目:Sqoop导入数据异常怎么处理
URL分享:http://kswsj.cn/article/jdjhpj.html

其他资讯