Hive报错:FAILED: HiveException java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.me

Hive 启动后,执行 SQL 报如下的错:

FAILED: HiveException java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.me

根据提示:无法启动元数据服务。

方向一:尝试重新初始化元数据 (该方法无效,看方向二)

1. 删除 mysql 中的 matestore 库:

mysql -uroot -p123456

drop database matestore;

create database matestore;

 

2. 执行初始化命令:

schematool -initSchema -dbType mysql -verbose

初始化成功。

 

3. 尝试在 hive 客户端使用 SQL 看是否报错:

bin/hive

show databses;

结果:依然报错,报同样的错。

分析:初始化成功了,检查 hive-site.xml 也没有问题。根据报错,是元数据服务没有启动,尝试手动启动该服务。

 

方向二:手动启动 hive 的元数据服务:

hive --service metastore

hive 客户端尝试 SQL 语句,可以使用,已解决。

另:hiveserver2 启动命令,用于 jdbc 连接:

bin/hive --service hiveserver2

 

注:matestore 服务需要在 hive-site.xml 文件中做如下配置:

    <!-- 指定存储元数据要连接的地址 -->
<span style="color: rgba(128, 128, 128, 1)">&lt;</span>property<span style="color: rgba(128, 128, 128, 1)">&gt;</span>

    <span style="color: rgba(128, 128, 128, 1)">&lt;</span>name<span style="color: rgba(128, 128, 128, 1)">&gt;</span>hive.metastore.uris<span style="color: rgba(128, 128, 128, 1)">&lt;/</span>name<span style="color: rgba(128, 128, 128, 1)">&gt;</span>

    <span style="color: rgba(128, 128, 128, 1)">&lt;</span>value<span style="color: rgba(128, 128, 128, 1)">&gt;</span>thrift:<span style="color: rgba(128, 128, 128, 1)">//</span>hadoop102:<span style="color: rgba(128, 0, 0, 1); font-weight: bold">9083</span><span style="color: rgba(128, 128, 128, 1)">&lt;/</span>value<span style="color: rgba(128, 128, 128, 1)">&gt;</span>

<span style="color: rgba(128, 128, 128, 1)">&lt;/</span>property<span style="color: rgba(128, 128, 128, 1)">&gt;</span></pre>

注:hiveserver2 服务需要在 hive-site.xml 文件中做如下配置:

    <!-- 指定 hiveserver2 连接的 host -->
    <property>
        <name>hive.server2.thrift.bind.host</name>
        <value>hadoop102</value>
    </property>
<span style="color: rgba(128, 128, 128, 1)">&lt;</span>!<span style="color: rgba(0, 128, 128, 1)">--</span><span style="color: rgba(0, 128, 128, 1)"> 指定hiveserver2连接的端口号 --&gt;</span>
<span style="color: rgba(128, 128, 128, 1)">&lt;</span>property<span style="color: rgba(128, 128, 128, 1)">&gt;</span>
    <span style="color: rgba(128, 128, 128, 1)">&lt;</span>name<span style="color: rgba(128, 128, 128, 1)">&gt;</span>hive.server2.thrift.port<span style="color: rgba(128, 128, 128, 1)">&lt;/</span>name<span style="color: rgba(128, 128, 128, 1)">&gt;</span>
    <span style="color: rgba(128, 128, 128, 1)">&lt;</span>value<span style="color: rgba(128, 128, 128, 1)">&gt;</span><span style="color: rgba(128, 0, 0, 1); font-weight: bold">10000</span><span style="color: rgba(128, 128, 128, 1)">&lt;/</span>value<span style="color: rgba(128, 128, 128, 1)">&gt;</span>
<span style="color: rgba(128, 128, 128, 1)">&lt;/</span>property<span style="color: rgba(128, 128, 128, 1)">&gt;</span></pre>