本页面介绍了如何开始使用 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.
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-27。"],[[["\u003cp\u003eThe Google Cloud CLI can be used as an alternative to the Dataproc Metastore APIs for managing and accessing Dataproc Metastore services.\u003c/p\u003e\n"],["\u003cp\u003eYou can get help with gcloud metastore tools, resources, and commands by using the \u003ccode\u003e--help\u003c/code\u003e flag, or by referring to the Google Cloud CLI reference documentation.\u003c/p\u003e\n"],["\u003cp\u003eDefault configuration properties such as project, location, and tier for your Dataproc Metastore services can be set in your local client.\u003c/p\u003e\n"],["\u003cp\u003eThe default project ID, Dataproc Metastore location, and tier can be set using \u003ccode\u003egcloud config set\u003c/code\u003e commands with the appropriate flags and values.\u003c/p\u003e\n"]]],[],null,["# Use the Google Cloud CLI\n\nAs an alternative to using the [Dataproc Metastore APIs](/dataproc-metastore/docs/reference/rest),\nyou can manage and access Dataproc Metastore services\nusing [Google Cloud CLI](/sdk) `gcloud metastore` commands.\n\nThis page explains how to get started using the Google Cloud CLI, so you can use it\nto interact with Dataproc Metastore.\n\nBefore you begin\n----------------\n\n- Sign in to your Google Cloud account. If you're new to Google Cloud, [create an account](https://console.cloud.google.com/freetrial) to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.\n- In the Google Cloud console, on the project selector page,\n select or create a Google Cloud project.\n\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n-\n\n\n Enable the Dataproc Metastore API.\n\n\n [Enable the API](https://console.cloud.google.com/flows/enableapi?apiid=metastore.googleapis.com)\n-\n [Install](/sdk/docs/install) the Google Cloud CLI.\n\n | **Note:** If you installed the gcloud CLI previously, make sure you have the latest version by running `gcloud components update`.\n- If you're using an external identity provider (IdP), you must first\n [sign in to the gcloud CLI with your federated identity](/iam/docs/workforce-log-in-gcloud).\n\n-\n To [initialize](/sdk/docs/initializing) the gcloud CLI, run the following command:\n\n ```bash\n gcloud init\n ```\n\n- In the Google Cloud console, on the project selector page,\n select or create a Google Cloud project.\n\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n-\n\n\n Enable the Dataproc Metastore API.\n\n\n [Enable the API](https://console.cloud.google.com/flows/enableapi?apiid=metastore.googleapis.com)\n-\n [Install](/sdk/docs/install) the Google Cloud CLI.\n\n | **Note:** If you installed the gcloud CLI previously, make sure you have the latest version by running `gcloud components update`.\n- If you're using an external identity provider (IdP), you must first\n [sign in to the gcloud CLI with your federated identity](/iam/docs/workforce-log-in-gcloud).\n\n-\n To [initialize](/sdk/docs/initializing) the gcloud CLI, run the following command:\n\n ```bash\n gcloud init\n ```\n\n\u003cbr /\u003e\n\nGet started with the Google Cloud CLI\n-------------------------------------\n\nTo start with the gcloud CLI, review the\n[Google Cloud CLI Documentation](/sdk/docs).\nYou can get help for the tool, resources, and commands by using the `--help`\nflag: \n\n gcloud metastore --help\n\nThe [Google Cloud CLI reference](/sdk/gcloud/reference) also provides the information\nshown by the `--help` flag.\n\nSet default configuration properties in your local client\n---------------------------------------------------------\n\nMost `gcloud metastore` commands require a location, which you specify using\nthe `--location` flag or by setting the default location. You can also set the\ndefault project and tier for your Dataproc Metastore services.\n\n1. To set the default project, run the following command: \n\n ```\n gcloud config set project PROJECT_ID\n ```\n\n where \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e is the ID of the Google Cloud project that the\n Dataproc Metastore service belongs to.\n2. To configure the Dataproc Metastore location, run the following command: \n\n ```\n gcloud config set metastore/location LOCATION\n ```\n\n where \u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e is a supported region such as `us-central1`.\n3. To configure the Dataproc Metastore tier, run the following command: \n\n ```\n gcloud config set metastore/tier TIER\n ```\n\n where \u003cvar translate=\"no\"\u003eTIER\u003c/var\u003e sets the capacity of the new service.\n4. Optional: To list the configuration for the gcloud CLI, run the following command: \n\n ```\n gcloud config list\n ```\n\nWhat's next\n-----------\n\n- [Dataproc Metastore gcloud commands](/sdk/gcloud/reference/metastore)\n- [Enabling the API](/dataproc-metastore/docs/enable-service)\n- [Quickstart for deploying Dataproc Metastore](/dataproc-metastore/docs/create-service-cluster)"]]