当前位置: 首页 > news >正文

Hive问题记录(1)

在初始化中遇到的问题:

[root@master data]# schematool -dbType derby -initSchema
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/data/hive/lib/log4j-slf4j-impl-2.10.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/data/hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;Ljava/lang/Object;)V
        at org.apache.hadoop.conf.Configuration.set(Configuration.java:1357)
        at org.apache.hadoop.conf.Configuration.set(Configuration.java:1338)
        at org.apache.hadoop.mapred.JobConf.setJar(JobConf.java:518)
        at org.apache.hadoop.mapred.JobConf.setJarByClass(JobConf.java:536)
        at org.apache.hadoop.mapred.JobConf.<init>(JobConf.java:430)
        at org.apache.hadoop.hive.conf.HiveConf.initialize(HiveConf.java:5141)
        at org.apache.hadoop.hive.conf.HiveConf.<init>(HiveConf.java:5104)
        at org.apache.hive.beeline.HiveSchemaTool.<init>(HiveSchemaTool.java:96)
        at org.apache.hive.beeline.HiveSchemaTool.main(HiveSchemaTool.java:1473)
        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.util.RunJar.run(RunJar.java:318)
        at org.apache.hadoop.util.RunJar.main(RunJar.java:232)

来自DeepSeek的解决方案:(已经成功解决)

从错误信息来看,执行 schematool -dbType derby -initSchema 时出现了两个问题:

  1. SLF4J 绑定冲突
    在类路径中发现了多个 SLF4J 绑定(log4j-slf4j-impl-2.10.0.jarslf4j-log4j12-1.7.25.jar)。
    解决方法
    删除其中一个冲突的 JAR 包。例如:

    rm /data/hive/lib/log4j-slf4j-impl-2.10.0.jar
    

    或者:

    rm /data/hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.25.jar
    
  2. Guava 版本不兼容
    错误 java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument 表明 Hive 和 Hadoop 使用的 Guava 库版本不兼容。
    解决方法
    确保 Hive 和 Hadoop 使用相同版本的 Guava 库。以下是具体步骤:

    • 检查 Hadoop 的 Guava 版本:
      ls /data/hadoop/share/hadoop/common/lib/guava-*.jar
      
      例如,输出可能是 guava-27.0-jre.jar
    • 检查 Hive 的 Guava 版本:
      ls /data/hive/lib/guava-*.jar
      
      例如,输出可能是 guava-19.0.jar
    • 将 Hive 的 Guava 版本替换为与 Hadoop 一致的版本:
      rm /data/hive/lib/guava-19.0.jar
      cp /data/hadoop/share/hadoop/common/lib/guava-27.0-jre.jar /data/hive/lib/
      

完整解决步骤

  1. 删除 SLF4J 冲突的 JAR 包:
    rm /data/hive/lib/log4j-slf4j-impl-2.10.0.jar
    
  2. 替换 Hive 的 Guava 版本为与 Hadoop 一致的版本:
    rm /data/hive/lib/guava-*.jar
    cp /data/hadoop/share/hadoop/common/lib/guava-27.0-jre.jar /data/hive/lib/
    
  3. 重新执行初始化命令:
    schematool -dbType derby -initSchema
    

验证是否成功

如果成功,您将看到类似以下输出:

Metastore connection URL:        jdbc:derby:;databaseName=metastore_db;create=true  
Metastore Connection Driver :    org.apache.derby.jdbc.EmbeddedDriver  
Metastore connection User:       APP  
Starting metastore schema initialization to 3.1.0  
Initialization script hive-schema-3.1.0.derby.sql  
Initialization completed successfully  
SchemaTool completed  

注意事项

  • 备份文件:在删除或替换 JAR 包前,建议备份相关文件。
  • 权限问题:确保操作时有足够的权限(使用 root 用户或 sudo)。
  • 生产环境:生产环境中建议使用 MySQL 或 PostgreSQL 作为元数据库,而不是 Derby。

相关文章:

  • SingleMod
  • inline 配置全局参数变量
  • 深入解析 Spring Framework 5.1.8.RELEASE 的源码目录结构
  • 驱动编写-DS18B20温度传感器
  • 远场分量(平面波角谱)与倏逝波
  • 搜索旋转排序数组
  • 初见MyBatis
  • 区间端点(java)(贪心问题————区间问题)
  • 游戏中的碰撞检测算法
  • 吐血整理:Air8201如何使用LuatOS进行电源管理功能!
  • 线程控制与线程库
  • ideaIU-2023.2.5.exe install (IntelliJ_IDEA_IU_2023.2.5)
  • 解决海豚调度器跑出数据但显示状态失败(在CDH6.3.2跑离线数仓任务)
  • C#中获取字节数据的高字节和低字节
  • MyBatis-Plus LambdaQueryWrapper 详解:优雅构建类型安全的查询条件
  • 3.25学习总结 抽象类和抽象方法+接口+内部类+API
  • 常用的离散时间傅里叶变换(DTFT)对
  • 网络相关的知识总结1
  • 【Tauri2】002——Cargo.toml和入口文件
  • 【C++】智能指针
  • 个人网站数据库怎么做/西安危机公关公司
  • 上海网站开发培训/今日最新抗疫数据
  • 国内外优秀设计网站/深圳网络seo推广
  • 高端的网站制作/制作公司官网多少钱
  • 永年网站制作/宁波搜索引擎优化seo
  • 天津企朋做网站的公司/网站制作优化