sqoop mysql date_Sqoop_ 从 hive 导到mysql常遇九问题总结(转)

本文总结了使用Sqoop从Hive导数据到MySQL时遇到的问题,包括拒绝连接、表不存在、NULL字段处理、数据类型不匹配等问题,并提供了相应的解决方法。例如,通过指定--input-null-string和--input-null-non-string参数解决NULL值问题,调整MySQL表字段长度以适应数据,以及注意日期格式等。
摘要由CSDN通过智能技术生成

以前以为版本不同,遇到的问题就不同,后来发现,无论是新版本,还是老版本,遇到的问题大部分都是相同的。下面解决问题的方法仅供借鉴

1.拒绝连接的错误表现是什么?

2.表不存在该如何解决?

3.null字段填充符该如何指定?

00b6bcbc02b928b436cd7bd45240dc9c.png

环境hive 版本hive-0.11.0

sqoop 版本 sqoop-1.4.4.bin__hadoop-1.0.0

从hive导到mysql

mysql 表

mysql> desc cps_activation;

+————+————-+——+—–+———+—————-+

| Field | Type | Null | Key | Default | Extra |

+————+————-+——+—–+———+—————-+

| id | int(11) | NO | PRI | NULL | auto_increment |

| day | date | NO | MUL | NULL | |

| pkgname | varchar(50) | YES | | NULL | |

| cid | varchar(50) | YES | | NULL | |

| pid | varchar(50) | YES | | NULL | |

| activation | int(11) | YES | | NULL | |

+————+————-+——+—–+———+—————-+

6 rows in set (0.01 sec)

hive表

hive> desc active;

OK

id int None

day string None

pkgname string None

cid string None

pid string None

activation int None

测试链接成功

[hadoop@hs11 ~]sqoop list-databases –connect jdbc:mysql://localhost:3306/ –username root –password admin

Warning: /usr/lib/hcatalog does not exist! HCatalog jobs will fail.

Please set $HCAT_HOME to the root of your HCatalog installation.

13/08/20 16:42:26 WARN tool.BaseSqoopTool: Setting your password on the command-line is insecure. Consider using -P instead.

13/08/20 16:42:26 INFO manager.MySQLManager: Preparing to use a MySQL streaming resultset.

information_schema

easyhadoop

mysql

test

[hadoop@hs11 ~]$ sqoop list-databases –connect jdbc:mysql://localhost:3306/test –username root –password admin

Warning: /usr/lib/hcatalog does not exist! HCatalog jobs will fail.

Please set $HCAT_HOME to the root of your HCatalog installation.

13/08/20 16:42:40 WARN tool.BaseSqoopTool: Setting your password on the command-line is insecure. Consider using -P instead.

13/08/20 16:42:40 INFO manager.MySQLManager: Preparing to use a MySQL streaming resultset.

information_schema

easyhadoop

mysql

test

[hadoop@hs11 ~]$ sqoop list-tables –connect jdbc:mysql://localhost:3306/test –username root –password admin

Warning: /usr/lib/hcatalog does not exist! HCatalog jobs will fail.

Please set $HCAT_HOME to the root of your HCatalog installation.

13/08/20 16:42:54 WARN tool.BaseSqoopTool: Setting your password on the command-line is insecure. Consider using -P instead.

13/08/20 16:42:54 INFO manager.MySQLManager: Preparing to use a MySQL streaming resultset.

active

[hadoop@hs11 ~]$ sqoop create-hive-table –connect jdbc:mysql://localhost:3306/test –table active –username root –password admin –hive-table test

Warning: /usr/lib/hcatalog does not exist! HCatalog jobs will fail.

Please set $HCAT_HOME to the root of your HCatalog installation.

13/08/20 16:57:04 WARN tool.BaseSqoopTool: Setting your password on the command-line is insecure. Consider using -P instead.

13/08/20 16:57:04 INFO tool.BaseSqoopTool: Using Hive-specific delimiters for output. You can override

13/08/20 16:57:04 INFO tool.BaseSqoopTool: delimiters with –fields-terminated-by, etc.

13/08/20 16:57:04 WARN tool.BaseSqoopTool: It seems that you’ve specified at least one of following:

13/08/20 16:57:04 WARN tool.BaseSqoopTool: –hive-home

13/08/20 16:57:04 WARN tool.BaseSqoopTool: –hive-overwrite

13/08/20 16:57:04 WARN tool.BaseSqoopTool: –create-hive-table

13/08/20 16:57:04 WARN tool.BaseSqoopTool: –hive-table

13/08/20 16:57:04 WARN tool.BaseSqoopTool: –hive-partition-key

13/08/20 16:57:04 WARN tool.BaseSqoopTool: –hive-partition-value

13/08/20 16:57:04 WARN tool.BaseSqoopTool: –map-column-hive

13/08/20 16:57:04 WARN tool.BaseSqoopTool: Without specifying parameter –hive-import. Please note that

13/08/20 16:57:04 WARN tool.BaseSqoopTool: those arguments will not be used in this session. Either

13/08/20 16:57:04 WARN tool.BaseSqoopTool: specify –hive-import to apply them correctly or remove them

13/08/20 16:57:04 WARN tool.BaseSqoopTool: from command line to remove this warning.

13/08/20 16:57:04 INFO tool.BaseSqoopTool: Please note that –hive-home, –hive-partition-key,

13/08/20 16:57:04 INFO tool.BaseSqoopTool: hive-partition-value and –map-column-hive options are

13/08/20 16:57:04 INFO tool.BaseSqoopTool: are also valid for HCatalog imports and exports

13/08/20 16:57:04 INFO manager.MySQLManager: Preparing to use a MySQL streaming resultset.

13/08/20 16:57:05 INFO manager.SqlManager: Executing SQL statement: SELECT t.* FROM `active` AS t LIMIT 1

13/08/20 16:57:05 INFO

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值