MapReduce服务 MRS-Hive分区表支持OBS和HDFS存储源:操作示例

时间:2023-11-01 16:25:29

操作示例

  1. 以Hive客户端安装用户登录安装客户端的节点。
  2. 执行以下命令,切换到客户端安装目录。

    cd 客户端安装目录

    例如安装目录为“/opt/client”,则执行以下命令:

    cd /opt/client

  3. 执行以下命令配置环境变量。

    source bigdata_env

  4. 集群认证模式是否为安全模式。
    • 是,执行以下命令进行用户认证:

      kinit Hive业务用户

    • 否,执行5
  5. 执行以下命令登录Hive客户端。

    beeline

  6. 执行如下命令创建Hive分区表“table_1”,指定分区“pt='2021-12-12'”的路径为“hdfs//xxx”,指定分区“pt='2021-12-18'”的路径为“obs://xxx”:

    create table table_1(id string) partitioned by(pt string) [stored as [orc|textfile|parquet|...]];

    alter table table_1 add partition(pt='2021-12-12') location 'hdfs://xxx';

    alter table table_1 add partition(pt='2021-12-18') location 'obs://xxx';

  7. 给分区表“table_1”中插入数据后,对应的分区数据存储在对应的存储源上,可以使用desc查看分区的location,执行以下命令查看路径下的数据:

    desc formatted table_1 partition(pt='2021-12-18');

support.huaweicloud.com/cmpntguide-lts-mrs/mrs_01_24470.html