HiveServer2 启动时 datanucleus.schema.autoCreateTables 不生效的问题

HiveServer2 启动时出 "Either your MetaData is incorrect, or you need to enable "datanucleus.schema.autoCreateTables"问题

java 复制代码
Required table missing : "FUNCS" in Catalog "" Schema "". DataNucleus requires this table to perform its persistence operations. Either your MetaData is incorrect, or you need to enable "datanucleus.schema.autoCreateTables"
org.datanucleus.store.rdbms.exceptions.MissingTableException: Required table missing : "FUNCS" in Catalog "" Schema "". DataNucleus requires this table to perform its persistence operations. Either your MetaData is incorrect, or you need to enable "datanucleus.schema.autoCreateTables"
	at org.datanucleus.store.rdbms.table.AbstractTable.exists(AbstractTable.java:606)
	at org.datanucleus.store.rdbms.RDBMSStoreManager$ClassAdder.performTablesValidation(RDBMSStoreManager.java:3385)
	at org.datanucleus.store.rdbms.RDBMSStoreManager$ClassAdder.run(RDBMSStoreManager.java:2896)
	at org.datanucleus.store.rdbms.AbstractSchemaTransaction.execute(AbstractSchemaTransaction.java:119)
	at org.datanucleus.store.rdbms.RDBMSStoreManager.manageClasses(RDBMSStoreManager.java:1627)
	at org.datanucleus.store.rdbms.RDBMSStoreManager.getDatastoreClass(RDBMSStoreManager.java:672)
	at org.datanucleus.store.rdbms.query.RDBMSQueryUtils.getStatementForCandidates(RDBMSQueryUtils.java:425)
	at org.datanucleus.store.rdbms.query.JDOQLQuery.compileQueryFull(JDOQLQuery.java:865)
	at org.datanucleus.store.rdbms.query.JDOQLQuery.compileInternal(JDOQLQuery.java:347)
	at org.datanucleus.store.query.Query.executeQuery(Query.java:1816)
	at org.datanucleus.store.query.Query.executeWithArray(Query.java:1744)
	at org.datanucleus.api.jdo.JDOQuery.executeInternal(JDOQuery.java:368)
	at org.datanucleus.api.jdo.JDOQuery.execute(JDOQuery.java:228)
	at org.apache.hadoop.hive.metastore.ObjectStore.getAllFunctions(ObjectStore.java:9429)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.hadoop.hive.metastore.RawStoreProxy.invoke(RawStoreProxy.java:97)
	at com.sun.proxy.$Proxy118.getAllFunctions(Unknown Source)
	at org.apache.hadoop.hive.metastore.HiveMetaStore$HMSHandler.get_all_functions(HiveMetaStore.java:7113)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.hadoop.hive.metastore.RetryingHMSHandler.invokeInternal(RetryingHMSHandler.java:147)
	at org.apache.hadoop.hive.metastore.RetryingHMSHandler.invoke(RetryingHMSHandler.java:108)
	at com.sun.proxy.$Proxy120.get_all_functions(Unknown Source)
	at org.apache.hadoop.hive.metastore.HiveMetaStoreClient.getAllFunctions(HiveMetaStoreClient.java:2861)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.hadoop.hive.metastore.RetryingMetaStoreClient.invoke(RetryingMetaStoreClient.java:212)
	at com.sun.proxy.$Proxy122.getAllFunctions(Unknown Source)
	at org.apache.hadoop.hive.ql.metadata.Hive.getAllFunctions(Hive.java:4610)
	at org.apache.hadoop.hive.ql.metadata.Hive.reloadFunctions(Hive.java:291)
	at org.apache.hadoop.hive.ql.metadata.Hive.registerAllFunctionsOnce(Hive.java:274)
	at org.apache.hadoop.hive.ql.metadata.Hive.<init>(Hive.java:442)
	at org.apache.hadoop.hive.ql.metadata.Hive.create(Hive.java:382)
	at org.apache.hadoop.hive.ql.metadata.Hive.getInternal(Hive.java:362)
	at org.apache.hadoop.hive.ql.metadata.Hive.get(Hive.java:331)
	at 

出现这个问题就是需要将 datanucleus.schema.autoCreateAll 配置设置为 true。

但是明明我们已经将 HiveConf 的 datanucleus.schema.autoCreateAll 参数设置为 true 了,为什么还是会出现这个问题呢?

留意日志可以发现这一行:

[INFO] (org.apache.hadoop.hive.metastore.HiveMetaStoreClient:346) [main] - Mestastore configuration datanucleus.schema.autoCreateAll changed from true to false

原来是将配置改成了 false。

研究相关的逻辑发现,原来是初始化时如果两个配置不同就会出现这个问题,那为什么配置会不同呢?

追踪一下可以发现 HiveMaterializedViewRegistry 在初始化时会新建一个 HiveConf,而不是我们传入的 HiveConf:

解决办法

HiveConf 在初始化时,将会添加设置的 hivemetastoreSiteUrl HiveConf 资源,而 hivemetastoreSiteUrl 需要通过调用HiveConf#setHivemetastoreSiteUrl 方法设置,该方法是个静态的公共方法,可以在任何地方调用。

注意:设置的 HiveConf 需要配置 hive.metastore.schema.verification = false 以及 datanucleus.schema.autoCreateAll = true 参数,因为如果没有设置 hive.metastore.schema.verification 参数的话,hive.metastore.schema.verification 的默认值为 true,而在初始化时,如果检测 hive.metastore.schema.verification 为 true 那么就会将 datanucleus.schema.autoCreateAll 参数设置为 false,datanucleus.schema.autoCreateAll 参数我们是知道的,是解决这个问题的关键。

相关推荐
The Open Group1 小时前
英特尔公司Darren Pulsipher 博士:以架构之力推动政府数字化转型
大数据·人工智能·架构
喂完待续1 小时前
【Tech Arch】Spark为何成为大数据引擎之王
大数据·hadoop·python·数据分析·spark·apache·mapreduce
三掌柜6661 小时前
NVIDIA 技术沙龙探秘:聚焦 Physical AI 专场前沿技术
大数据·人工智能
源码宝2 小时前
【智慧工地源码】智慧工地云平台系统,涵盖安全、质量、环境、人员和设备五大管理模块,实现实时监控、智能预警和数据分析。
java·大数据·spring cloud·数据分析·源码·智慧工地·云平台
百思可瑞教育3 小时前
Git 对象存储:理解底层原理,实现高效排错与存储优化
大数据·git·elasticsearch·搜索引擎
数据超市4 小时前
香港数据合集:建筑物、手机基站、POI、职住数据、用地类型
大数据·人工智能·智能手机·数据挖掘·数据分析
SelectDB5 小时前
Apache Doris 在菜鸟的大规模湖仓业务场景落地实践
大数据·数据分析·开源
BYSJMG7 小时前
计算机大数据毕业设计推荐:基于Hadoop+Spark的食物口味差异分析可视化系统【源码+文档+调试】
大数据·hadoop·分布式·python·spark·django·课程设计
萤丰信息8 小时前
技术赋能安全:智慧工地构建城市建设新防线
java·大数据·开发语言·人工智能·智慧城市·智慧工地
Viking_bird9 小时前
Apache Spark 3.2.0 开发测试环境部署指南
大数据·分布式·ajax·spark·apache