hive建表出现这个错误: Error while processing statement: FAILED: Execution
Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask.
MetaException(message:Error(s) were found while
auto-creating/validating the datastore for classes. The errors are
printed in the log, and are attached to this exception

这个时候,查看日志, hive默认日志的地址在:/tmp/root 目录下有个 hive.log文件, cat hive.log

你的报错信息如果跟我一样,就进入此服务器的mysql上,查看hive元数据的数据库, 不知道自己hive的元数据存在那个数据库,
查看hive/conf/hive-site.xml

知道保存的元数据的数据库后,进入数据库
先查询TBLS表字段集是:latin1 类型吗?
SHOW CREATE TABLE TBLS;
查看结果:

如果是utf8就会出现建表报错, 所以此时执行:alter table hive.TBLS convert to character set
//修改数据库
alter database 数据库名 character set utf8;
//修改表
alter table 表名 convert to character set gbk;
//修改字段
alter table 表名 modify column ‘字段名’ varchar(30) character set gbk not null;
//添加表字段
alter table 表名 add column ‘字段名’ varchar (20) character set gbk;
latin1; 执行完后一定再次查看:

接下来jps查看所有进程名,用kill -9 RunJar的id全部杀死

接下来重新启动hive:
nohup /hive/bin/hive --service metastore &
nohup /hive/bin/hive --service hiveserver2 &
/hive/bin/beeline 进入hive 建表即可:

成功了
博客主要讲述Hive建表报错的解决办法。当出现特定错误时,可查看Hive默认日志文件,进入服务器的MySQL查看Hive元数据数据库。若TBLS表字段集为utf8会导致建表报错,需修改数据库、表、字段的字符集。之后杀死相关进程,重新启动Hive并建表。
3144

被折叠的 条评论
为什么被折叠?



