首页 > 其他分享 >【Flink 系列二十三】hudi 消失的 HIVE_CONF_DIR,HIVE 读不到 hive-site.xml 读不到

【Flink 系列二十三】hudi 消失的 HIVE_CONF_DIR,HIVE 读不到 hive-site.xml 读不到

时间:2024-10-10 18:22:57浏览次数:1  
标签:xml hudi HIVE hive site result conf

问题现象

Unable to find config file hive-site.xml
Unable to find config file hivemetastore-site.xml
Unable to find config file metastore-site.xml

本文记录这个问题是如何导致的,并记录如何向 Hive、Hudi 提供 hive-site.xml 以便正确加载。

问题分析: HiveMetaStore 是如何查找配置文件路径的

位置:org.apache.hadoop.hive.metastore.conf.MetastoreConf#findConfigFile

private static URL findConfigFile(ClassLoader classLoader, String name) {
    // First, look in the classpath
    URL result = classLoader.getResource(name);
    if (result == null) {
      // Nope, so look to see if our conf dir has been explicitly set
      result = seeIfConfAtThisLocation("METASTORE_CONF_DIR", name, false);
      if (result == null) {
        // Nope, so look to see if our home dir has been explicitly set
        result = seeIfConfAtThisLocation("METASTORE_HOME", name, true);
        if (result == null) {
          // Nope, so look to see if Hive's conf dir has been explicitly set
          result = seeIfConfAtThisLocation("HIVE_CONF_DIR", name, false);
          if (result == null) {
            // Nope, so look to see if Hive's home dir has been explicitly set
            result = seeIfConfAtThisLocation("HIVE_HOME", name, true);
            if (result == null) {
              // Nope, so look to see if we can find a conf file by finding our jar, going up one
              // directory, and looking for a conf directory.
              URI jarUri = null;
              try {
                jarUri = MetastoreConf.class.getProtectionDomain().getCodeSource().getLocation().toURI();
              } catch (Throwable e) {
                LOG.warn("Cannot get jar URI", e);
              }
              result = seeIfConfAtThisLocation(new File(jarUri).getParent(), name, true);
              // At this point if we haven't found it, screw it, we don't know where it is
              if (result == null) {
                LOG.info("Unable to find config file " + name);
              }
            }
          }
        }
      }
    }
    LOG.info("Found configuration file " + result);
    return result;
  }

显然是因为 classpath 没有,METASTORE_CONF_DIR、METASTORE_HOME、HIVE_CONF_DIR、HIVE_HOME, 这些位置相应的都没有

并且甚至 MetastoreConf 类所在的 jar 包内也没有

寻找原因:为什么所有的位置都没有读取到 hive-site.xml

位置:org.apache.hadoop.hive.metastore.conf.MetastoreConf#newMetastoreConf

 if(hiveSiteURL == null) {
      /*
       * this 'if' is pretty lame - QTestUtil.QTestUtil() uses hiveSiteURL to load a specific
       * hive-site.xml from data/conf/<subdir> so this makes it follow the same logic - otherwise
       * HiveConf and MetastoreConf may load different hive-site.xml  ( For example,
       * HiveConf uses data/conf/spark/hive-site.xml and MetastoreConf data/conf/hive-site.xml)
       */
      hiveSiteURL = findConfigFile(classLoader, "hive-site.xml");
    }
    if (hiveSiteURL != null) {
      conf.addResource(hiveSiteURL);
    }

当 hiveSiteURL 静态变量未设置的时候,才调用 findConfigFile,这个是正常情况。

Flink 相关的
位置:
org.apache.flink.table.catalog.hive.HiveCatalog.createHiveConf

        // ignore all the static conf file URLs that HiveConf may have set
        HiveConf.setHiveSiteLocation(null);

结论:

  • Flink 清理了这个静态变量,导致进入 findConfigFile。
  • MetastoreConf 看样子不支持 HDFS上的 hive-site.xml
  • Flink 如果new了HiveCatalog,一定导致查找过程

CLASSPATH 分析

Flink的 CLASSPATH 已经提供了为何仍然加载不了 hive-site.xml

lib/hive-site.xml

但 classLoader.getResource(name); 仍然加载不了,推测是因为 name应当是 "lib/hive-site.xml" 才能正确加载 ?

结论:
需要指定 HIVE_CONF_DIR

解决方案

给 Flink 程序传入 HIVE_CONF_DIR,那么具体怎么做的?可以参考 kyuubi

即:

-Dcontainerized.master.env.HIVE_CONF_DIR=/etc/hive/conf

标签:xml,hudi,HIVE,hive,site,result,conf
From: https://www.cnblogs.com/slankka/p/18456896

相关文章

  • 【Flink系列十八】Hudi hive_sync JDO报错 Could not find API definition for name "
    问题现象Error:CouldnotfindAPIdefinitionforname"JDO".Perhapsyoudonthavetherequisitedatanucleus-api-XXXjarintheCLASSPATH?2024-10-1011:12:31,251ERRORDataNucleus.Persistence[]-Error:Co......
  • 读取xml文件写到csv文件中
    #xml数据提取,拼合为csv文件importosimportcsvimportxml.dom.minidomimportglobdefto_int(str_value):try:returnint(str_value)exceptValueError:try:float_value=float(str_value)returnint(floa......
  • Hive(七)分区表和分桶表
    分区表分区表实际上就是对应一个HDFS文件系统上的独立的文件夹,该文件夹下是该分区所有的数据文件Hive中的分区就是分目录,把一个大的数据集根据业务需要分割成小的数据集在查询时通过WHERE子句中的表达式选择查询所需要的指定的分区,这样的查询效率会提高很多分区表基本操作......
  • spring上 -基于Xml配置bean笔记
    4,Spring内容   7,快速入门 需求:通过Spring的方式[配置文件],获取JavaBean:Monster的对象,并给该的对象属性赋值,输出该对象信息.代码结构:lib目录是自己创建的,然后再引入5个jar包 源码:beans.xml<?xmlversion="1.0"encoding="UTF-8"?><beansxmlns="......
  • Hive(六)JSON函数
    概念什么是JSONJSON(JavaScriptObjectNotation)是一种轻量级的数据交换格式,易于人阅读和编写,同时也易于机器解析和生成JSON是存储和交换文本信息的语法,类似XMLJSON比XML更小、更快,更易解析JSON语法数据在名称/值对中数据由,分开使用斜杠\来转义字符大括号{}保存对象......
  • Hive(五)常用函数
    Hive常用函数字符串函数返回值函数描述stringconcat(string/binaryA,string/binaryB…)对二进制字节码或字符串按次序进行拼接intinstr(stringstr,stringsubstr)查找字符串str中子字符串substr出现的位置intlength(stringA)返回字符串的长度int......
  • C# 类型增加自定义xml序列化
    1、首先类需要增加[Serializable]标识2、类实现IXmlSerializable接口下面是重写ReadXml和WriteXml方法publicvoidReadXml(XmlReaderreader){reader.ReadStartElement(reader.LocalName);while(reader.Read()){if(reader.Name=="TimeType"&&......
  • 基于springboot的Hive的网络电视剧收视率分析系统
    本网络电视剧收视率分析系统依托Java与SpringBoot技术,并结合Hive数据仓库,致力于为电视剧行业提供精准、全面的收视率分析服务。在系统设计上,充分考虑数据的海量性和复杂性。Java语言确保了系统各个模块的稳定运行和高效执行。SpringBoot框架则为系统提供了便捷......
  • 基于Python+Scrapy的高校岗位招聘和分析平台(源码+vue+hadoop+hive+部署文档+可视化大
    收藏关注不迷路!!......
  • python基于深度学习的短视频内容理解与推荐系统(源码+vue+hadoop+hive+部署文档+可视
    收藏关注不迷路!!......