背景

最近在整合pyspark与hive,新安装spark-2.3.3以客户端的方式访问hive数据,运行方式使用spark on yarn,但是在配置spark读取hive数据的时候,这里直接把hive下的hive-site.xml复制到spark目录下,启动了一次spark,上面的问题就出现了。

网上的说法:

hive元数据问题,需要重新初始化hive的元数据
但是这个方法肯定不适合我,因为仓库里的表不能受影响,上千张表呢,如果初始化了,所有表都要重新创建。

排查过程

* 首先查看服务器上/tmp/${user}/hive.log文件,这个是公司服务器当时配置的详细的hive执行日志。
在日志中,有一段报错:
2019-07-06T10:01:53,737 ERROR [370c0a81-c922-4c61-8315-264c39b372c3 main] metastore.RetryingHMSHandler: MetaException(message:Hive Schema version 3.1.0 does not match metastore's schema version 1.2.0 Metastore is not upgraded or corrupt)
at org.apache.hadoop.hive.metastore.ObjectStore.checkSchema(ObjectStore.java:9063)
at org.apache.hadoop.hive.metastore.ObjectStore.verifySchema(ObjectStore.java:9027)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
这里的意思是,hive的版本是3.1.0,但是元数据中的版本信息是1.2.0,因此报错。

* 到hive的元数据库里查了下version表里的数据,确实版本是1.2.0

问题原因

这里猜测,spark在读取hive元数据的时候,因为spark是直接从官网上下载的,可能官网上的spark是用hive1.2.0版本编译的,所以,它默认使用的1.2.0,导致在启动的时候,修改了hive的元数据

但是具体的原因还不知道

下面会拿官网上的spark源码手动编译测试一下

解决办法

  1. 直接修改version表的数据
select * from version;
update VERSION set SCHEMA_VERSION='2.1.1' where VER_ID=1;

2、在hvie-site.xml中关闭版本验证

<property>
<name>hive.metastore.schema.verification</name>
<value>false</value>
</property>

深入研究

在spark官网上查看了相关的资料,发现,在官网上下载的spark安装包,默认编译的hive版本是1.2.1的,所以每次启动spark的时候,会检查hive的版本。如果采用hive的默认配置,如果不一样,

就会修改version



一开始尝试着下载spark源码重新编译spark安装包,编译执行hive的版本为3.1.1,但是,发现每次指定hive的版本,maven下载依赖的时候,都会报错。

报错信息如下:

后来想了个折中的办法,spark还是使用原始版本,但是修改一下hive-site.xml文件。

注意:这里修改的是spark的conf下的hive-site.xml,原始的hive里的不需要修改

  <property>
<name>hive.metastore.schema.verification</name>
<value>true</value>
<description>
Enforce metastore schema version consistency.
True: Verify that version information stored in metastore matches with one from Hive jars. Also disable automatic
schema migration attempt. Users are required to manually migrate schema after Hive upgrade which ensures
proper metastore schema migration. (Default)
False: Warn if the version information stored in metastore doesn't match with one from in Hive jars.
</description>
</property>
<property>
<name>hive.metastore.schema.verification.record.version</name>
<value>false</value>
<description>
When true the current MS version is recorded in the VERSION table. If this is disabled and verification is
enabled the MS will be unusable.
</description>
</property>

这两个配置,hive.metastore.schema.verification如果设置为true,那么每次启动hive或者spark的时候,都会检查hive的版本。为false,则会告警

hive.metastore.schema.verification.record.version如果设置为true,每次启动spark的时候,如果检查了hive的版本和spark编译的版本不一致,那么就会修改hive的元数据

这里的修改需要设置hive.metastore.schema.verification=false 且hive.metastore.schema.verification.record.version=false

如过这两个都为true,那么spark会修改hive元数据

如果hive.metastore.schema.verification=true,并且hive.metastore.schema.verification.record.version=false,这时候启动spark就会报错:

Caused by: MetaException(message:Hive Schema version 1.2.0 does not match metastore's schema version 3.1.0 Metastore is not upgraded or corrupt)
at org.apache.hadoop.hive.metastore.ObjectStore.checkSchema(ObjectStore.java:6679)
at org.apache.hadoop.hive.metastore.ObjectStore.verifySchema(ObjectStore.java:6645)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

如果设置hive.metastore.schema.verification=false 且hive.metastore.schema.verification.record.version=true,spark还是会修改hive的元数据



所以,只要设置hive.metastore.schema.verification.record.version=false就可以了,但是为了保险起见,我两个都设置成false了

Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient报错,问题排查的更多相关文章

  1. Hive之FAILED: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient异常

    一.场景 Hive启动不报错,当使用show functions;或create table...时报:FAILED: SemanticException org.apache.hadoop.hive ...

  2. hive Caused by: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient

    Exception in thread "main" java.lang.RuntimeException: org.apache.hadoop.hive.ql.metadata. ...

  3. Hive2:Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient

    [root@node1 ~]# hive which: no hbase in (/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bi ...

  4. hive 2以上版本启动异常 Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient

    hive2.0以上的版本启动时 抛出 “Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreCli ...

  5. Have启动报错:java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient

    错误日志如下: [hadoop@master hive1.0.0]$ bin/hive Logging initialized using configuration in file:/opt/mod ...

  6. Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient

    1.今天在进行hive测试的时候,发现hive一直进不去,并且报了这个错误. Unable to instantiate org.apache.hadoop.hive.ql.metadata.Sess ...

  7. Hive启动后show tables报错:Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient

    错误详情: FAILED: HiveException java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive ...

  8. Hive 报错:java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.metastore.HiveMetaStoreClient

    在配置好hive后启动报错信息如下: [walloce@bigdata-study- hive--cdh5.3.6]$ bin/hive Logging initialized using confi ...

  9. java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.metastore.HiveMetaStoreClient

    1.启动hive的时候出现这个问题,报错如下所示: [hadoop@slaver1 conf]$ hive Logging initialized -cdh5.-cdh5.3.6.jar!/hive- ...

随机推荐

  1. 开机启动类似于Tencent Upd的弹窗解决方法

    1.开机启动的程序,后台启动自动升级的exe,每次开机都弹出弹窗,一不小心就点错了,神烦. 解决方式:直接在windows系统  [ 本地安全策略>软件限制策略>其他规则 ] 里面把弹出的 ...

  2. AT1879 2 つの山札

    题面 题解 直接求解比较麻烦,考虑将问题进行转化. 设序列\(a = \{3, 1, 4, 2, 5\}, b = \{3, 2, 4, 1, 5\}\),那么我们构造一个正方形方格,将\(a\)放在 ...

  3. Pycharm使用git版本控制

    一.使用Pycharm进行版本控制 01 从远程仓库克隆项目 从远程仓库将一个已存在的项目克隆到本地 打开pycharm, VCS --> Checkout from Version Contr ...

  4. 第10组 Beta冲刺(2/5)

    链接部分 队名:女生都队 组长博客: 博客链接 作业博客:博客链接 小组内容 恩泽(组长) 过去两天完成了哪些任务 描述 新增修改用户信息.任务完成反馈等功能API 服务器后端部署,API接口的bet ...

  5. Cookie和Session原理

    由于HTTP是无状态的协议,客户程序每次都去web页面,都打开到web服务器的单独的连接,并且不维护客户的上下文信息.如果需要维护上下文信息,比如用户登录系统后,每次都能够知道操作的是此登录用户,而不 ...

  6. Centos 安装 zookeeper

    下载 下载地址:http://archive.apache.org/dist/zookeeper/ [root@localhost bin]# wget http://archive.apache.o ...

  7. Java_jdbc 基础笔记之十二 数据库连接 (beanutils )

    public class BeanUtilsTest { /** * Java 类的属性: * 1.在JavaEE中,Java类的属性通过getter,setter来定义: get,set方法,去除 ...

  8. MySQL事务隔离级别(一)

    本文实验的测试环境:Windows 10+cmd+MySQL5.6.36+InnoDB 一.事务的基本要素(ACID) 1.原子性(Atomicity):事务开始后所有操作,要么全部做完,要么全部不做 ...

  9. N以内的素数计算(Java代码)

    列出小于N的所有素数 普通计算方式, 校验每个数字 优化的几处: 判断是否整除时, 除数使用小于自身的平方根的素数 大于3的素数, 都在6的整数倍两侧, 即 6m - 1 和 6m + 1 publi ...

  10. Docker 安装 redis 并实现配置文件启动,数据文件本地持久化

    1,笔者使用的是 Linux 的 Centos7 版本  2,安装 Docker,不会安装可以移步 Docker 在 Linux 平台的安装 以及一些常见命令 3,下载 docker 镜像 3.1,首 ...