hive创建表失败:FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask.

在尝试将Hive的metadata配置为MySQL时,博主遇到了错误:'FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask.'。为解决问题,博主在MySQL中创建了hivedb,并通过修改hive-site.xml文件进行配置。随后,使用SQL命令`alter database hive character set latin1;`将数据库字符集更改为latin1。注意,latin1和utf8编码的区别,utf8通常用于支持多种语言,而latin1可能无法显示某些国家的语言。通过这些步骤,问题得到了解决。" 112023676,10295053,Git源代码管理与版本控制实战,"['Git', '版本控制', '代码管理', 'GitHub', '远程仓库']

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

前言:本文是在博主:http://blog.sina.com.cn/s/blog_7673d4a50102v7s1.html;博客基础上对遇到的问题的一个总结


把hive 的metadata配置成mysql,在mysql数据库里创建了hivedb后,修改hive的conf目录下的hive-site.xml

并且把 mysql-connector-java-5.1.22-bin.jar拷到hive的lib目录下面.
这里用的事hive0.14版本

结果运行hive, create table:
hive> create table t1
    > (tid int, tname string, age int);
Moved: 'hdfs://master:9000/home/hadoop/hive-0.14.0/warehouse/hive_table.db/t1' to trash at: hdfs://master:9000/user/root/.Trash/Current
Moved: 'hdfs://master:9000/home/hadoop/hive-0.14.0/warehouse/hive_table.db/t1' to trash at: hdfs://master:9000/user/root/.Trash/Current
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. MetaException(message:javax.jdo.JDODataStoreException: An exception was thrown while adding/validating class(es) : Specified key was too long; max key length is 767 bytes
com.mysql.jdbc.exceptions .jdbc4.MySQLSyntaxErrorException: Specified key was too long; max key length is 767 bytes
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
........

查看hive 的log:(本人小白一个,查的这个日志跟主页上显示的一样)
cat hive.log
2017-01-06 16:29:28,911 ERROR [main]: ql.Driver (SessionState.java:printError(833)) - FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask. MetaException(message:javax.jdo.JDODataStoreException: An exception was thrown while adding/validating class(es) : Specified key was too long; max key length is 767 bytes
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Specified key was too long; max key length is 767 bytes
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)


搜了下,在mysql上执行:

在mysql机器的上运行:

alter database hive character set latin1;

mysql> alter database hive character set latin1;
Query OK, 1 row affected (0.13 sec)

注意:
mysql latin1 utf8区别 那个比较强大
这是两种不同的编码,因为字节数的关系,有些国家的语言不能用latin1显示,
所以一般使用utf8编码,utf8是万国语言编码,既绝大多数国家的语言都可以用utf8


问题解决.

hive> 
    > create table t1                  
    > (tid int, tname string, age int);
OK
Time taken: 0.98 seconds
hive> show tables;
OK
t1
Time taken: 0.04 seconds, Fetched: 1 row(s)

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值