除了使用 Dataproc Metastore API,您也可以使用 Google Cloud CLI gcloud metastore 指令管理及存取 Dataproc Metastore 服務。
本頁說明如何開始使用 Google Cloud CLI,以便透過這項服務與 Dataproc Metastore 互動。
事前準備
- 登入 Google Cloud 帳戶。如果您是 Google Cloud新手,歡迎 建立帳戶,親自評估產品在實際工作環境中的成效。新客戶還能獲得價值 $300 美元的免費抵免額,可用於執行、測試及部署工作負載。
-
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 role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. 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.enablepermission. Learn how to grant roles.-
安裝 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 role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. 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.enablepermission. Learn how to grant roles.-
安裝 Google Cloud CLI。
-
若您採用的是外部識別資訊提供者 (IdP),請先使用聯合身分登入 gcloud CLI。
-
執行下列指令,初始化 gcloud CLI:
gcloud init
開始使用 Google Cloud CLI
如要開始使用 gcloud CLI,請參閱 Google Cloud CLI 說明文件。您可以使用 --help 標記取得工具、資源和指令的相關說明:
gcloud metastore --help
Google Cloud CLI 參考資料也會提供 --help 旗標顯示的資訊。
在本機用戶端中設定預設設定屬性
大多數 gcloud metastore 指令都需要位置,您可以使用 --location 標記指定位置,或設定預設位置。您也可以為 Dataproc Metastore 服務設定預設專案和層級。
- 如要設定預設專案,請執行下列指令:
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