除了使用 Dataproc Metastore API,您也可以使用 Google Cloud CLI gcloud metastore
指令管理及存取 Dataproc Metastore 服務。
本頁說明如何開始使用 Google Cloud CLI,以便透過這項服務與 Dataproc Metastore 互動。
事前準備
- 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.
-
Enable the Dataproc Metastore 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.
-
Enable the Dataproc Metastore 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
- 如要設定預設專案,請執行下列指令:
gcloud config set project PROJECT_ID
其中 PROJECT_ID 是 Dataproc Metastore 服務所屬 Google Cloud 專案的 ID。
- 如要設定 Dataproc Metastore 位置,請執行下列指令:
gcloud config set metastore/location LOCATION
其中 LOCATION 是支援的區域,例如
us-central1
。 - 如要設定 Dataproc Metastore 層級,請執行下列指令:
gcloud config set metastore/tier TIER
其中 TIER 會設定新服務的容量。
- 選用:如要列出 gcloud CLI 的設定,請執行下列指令:
gcloud config list
開始使用 Google Cloud CLI
如要開始使用 gcloud CLI,請參閱 Google Cloud CLI 說明文件。您可以使用 --help
標記取得工具、資源和指令的相關說明:
gcloud metastore --help
Google Cloud CLI 參考資料也會提供 --help
旗標顯示的資訊。
在本機用戶端中設定預設設定屬性
大多數 gcloud metastore
指令都需要位置,您可以使用 --location
標記指定位置,或設定預設位置。您也可以為 Dataproc Metastore 服務設定預設專案和層級。