向用户授予基本的 Dataproc Metastore IAM 角色

本页面介绍如何向 Google Cloud 用户帐号或服务帐号授予对项目中基本 Dataproc Metastore 资源的访问权限。本页面介绍的这些角色提供创建 Dataproc Metastore 服务的权限。

根据您希望帐号拥有的控制范围,您可以向其授予以下预定义 IAM 角色之一:

  • roles/metastore.editor,用于授予对 Dataproc Metastore 资源的完全控制权
  • roles/metastore.admin,用于授予对 Dataproc Metastore 资源的完全控制权,包括更新 IAM 权限。

如需详细了解这些角色提供的具体 IAM 权限,请参阅 Dataproc Metastore IAM 角色

准备工作

  1. 登录您的 Google Cloud 账号。如果您是 Google Cloud 新手,请创建一个账号来评估我们的产品在实际场景中的表现。新客户还可获享 $300 赠金,用于运行、测试和部署工作负载。
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  3. 确保您的 Google Cloud 项目已启用结算功能

  4. 启用 Dataproc Metastore API。

    启用 API

  5. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  6. 确保您的 Google Cloud 项目已启用结算功能

  7. 启用 Dataproc Metastore API。

    启用 API

必需的角色

您必须在正在使用的 Google Cloud 项目中拥有 roles/owner (Owner) 基本 IAM 角色,或拥有可授予这些权限的角色:

  • resourcemanager.projects.get
  • resourcemanager.projects.getIamPolicy
  • resourcemanager.projects.setIamPolicy

如需获得这些权限,同时遵循最小权限原则,请让管理员授予您 roles/resourcemanager.projectIamAdmin (Project IAM Admin) 角色。

如何授予访问权限角色

gcloud

如需使用 gcloud CLI,您可以安装并初始化 Google Cloud CLI,也可以使用 Cloud Shell

运行以下 add-iam-policy-binding 命令,向 IAM 主帐号(用户帐号或服务帐号)授予 Dataproc Metastore 预定义角色。

  gcloud projects add-iam-policy-binding PROJECT_ID \
     --member=PRINCIPAL \
     --role=METASTORE_ROLE

替换以下内容:

  • PROJECT_ID:您要启用 Metastore 访问权限的项目的 ID。
  • PRINCIPAL:主帐号的类型和电子邮件 ID(电子邮件地址)。
    • 对于用户帐号:user:EMAIL_ID
    • 对于服务账号:serviceAccount:EMAIL_ID
    • 对于 Google 网上论坛,群组:EMAIL_ID
  • METASTORE_ROLE:以下值之一(具体取决于您要授予主帐号的角色):roles/metastore.editorroles/metastore.admin。如需详细了解这些角色授予的权限,请参阅 Dataproc Metastore IAM 角色