【问题标题】:Hive - How to see the table created in metastore?Hive - 如何查看在 Metastore 中创建的表?
【发布时间】:2013-05-20 06:20:39
【问题描述】:

这是我们的设置 - 我们有 Hive,它在另一台机器上使用 MySQL 作为元存储。 我可以启动 Hive 命令行 shell 并创建一个表并对其进行描述。 但是当我登录到使用 MySQL 作为 Metastore 的另一台机器时,我看不到 MySQL 上的 Hive 表详细信息。

例如这是 hive 命令 -

hive> create table student(name STRING, id INT);
OK
Time taken: 7.464 seconds
hive> describe student;
OK
name    string
id      int
Time taken: 0.408 seconds
hive>

接下来,我登录到安装 MySQL 的机器,并将这个 MySQL 用作 Hive 元存储。我使用“元存储”数据库。但是如果我想列出表格,我看不到表格或我在 Hive 中创建的表格信息。

如何在 Metastore 中查看 Hive 表信息?

【问题讨论】:

    标签: hive


    【解决方案1】:

    首先,找到 Metastore 存储在哪个 MySql 数据库中。这将在您的 hive-site.conf - 连接 URL 中。然后,一旦你连接到 MySql,你就可以

    use metastore; 
    show tables; 
    select * from TBLS; <-- this will give you list of your hive tables
    

    【讨论】:

      【解决方案2】:

      如果您想搜索特定列所属的其他表,另一个有用的查询:

      SELECT c.column_name, tbl_name, c.comment, c.type_name, c.integer_idx,
       tbl_id, create_time, owner, retention, t.sd_id, tbl_type, input_format, is_compressed, location,
       num_buckets, output_format, serde_id, s.cd_id
      FROM TBLS t, SDS s, COLUMNS_V2 c
      -- WHERE tbl_name = 'my_table'
      WHERE t.SD_ID = s.SD_ID
      AND s.cd_id = c.cd_id
      AND c.column_name = 'my_col'
      order by create_time
      

      【讨论】:

        【解决方案3】:

        您可以查询 MySQL 数据库中的元存储架构。比如:

        mysql&gt; select * from TBLS;

        有关如何配置 MySQL 元存储以存储 Hive 的元数据并验证并查看存储的元数据here 的更多详细信息。

        【讨论】:

          【解决方案4】:

          *虽然设置 Hadoop 服务是任何其他服务(这也是强制性的),但管理员在大多数场景中使用关系数据库来存储 hive 和 oozie 等服务的元数据信息。

          那么,找到你的hive备份的数据库(mysql、postgresql、sqlserver等),就可以在TBLS表中看到元数据信息了*

          升级配置单元时,您必须备份这些 TBLS。

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 2022-06-14
            • 1970-01-01
            • 2014-02-22
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2018-07-01
            • 1970-01-01
            相关资源
            最近更新 更多