本文档介绍了如何设置 Google Cloud 项目和 Compute Engine 虚拟机 (VM)。
设置 Google Cloud 项目
- Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator
(
roles/resourcemanager.projectCreator
), which contains theresourcemanager.projects.create
permission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
-
Enable the Google Cloud Dataproc API.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin
), which contains theserviceusage.services.enable
permission. Learn how to grant roles. -
Install the Google Cloud CLI.
-
如果您使用的是外部身份提供方 (IdP),则必须先使用联合身份登录 gcloud CLI。
-
如需初始化 gcloud CLI,请运行以下命令:
gcloud init
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator
(
roles/resourcemanager.projectCreator
), which contains theresourcemanager.projects.create
permission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
-
Enable the Google Cloud Dataproc API.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin
), which contains theserviceusage.services.enable
permission. Learn how to grant roles. -
Install the Google Cloud CLI.
-
如果您使用的是外部身份提供方 (IdP),则必须先使用联合身份登录 gcloud CLI。
-
如需初始化 gcloud CLI,请运行以下命令:
gcloud init
您需要凭据吗? 只有当您计划从应用或浏览器直接调用 Dataproc API 时,才需要使用凭据。
如果您计划使用 Google Cloud 控制台或 Google Cloud CLI 来创建和管理集群以及提交作业,则只需使用 gcloud init
命令登录 SDK。
可选:设置虚拟机
如果您计划从 Compute Engine 虚拟机 (VM) 实例运行 gcloud CLI,则必须设置该 VM 以访问 Google Cloud 服务。
如需测试虚拟机是否已正确设置,请从命令行运行 gcloud compute instances describe YOUR_VM_INSTANCE_NAME
。必须列出包含 https://www.googleapis.com/auth/cloud-platform
范围的服务账号。如需详细了解如何设置虚拟机,请参阅创建使用用户管理的服务账号的虚拟机。