除了使用 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.
-
Enable the Dataproc Metastore API.
-
Install the Google Cloud CLI.
-
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
-
To initialize the gcloud CLI, run the following command:
gcloud init
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Enable the Dataproc Metastore API.
-
Install the Google Cloud CLI.
-
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
-
To initialize the gcloud CLI, run the following command:
gcloud init
- 如要設定預設專案,請執行下列指令:
gcloud config set project PROJECT_ID
其中 PROJECT_ID 是 Dataproc Metastore 服務所屬專案的 ID。 Google Cloud
- 如要設定 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 服務設定預設專案和層級。