删除集群
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
根据项目 ID 和实例 ID 删除集群。
代码示例
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],[],[[["\u003cp\u003eThis content provides code samples and instructions for deleting a cluster within a Bigtable instance using various programming languages.\u003c/p\u003e\n"],["\u003cp\u003eThe process requires a project ID, an instance ID, and a cluster ID to identify the specific cluster that should be deleted.\u003c/p\u003e\n"],["\u003cp\u003eEach code example emphasizes the use of the Bigtable client libraries, and proper authentication through Application Default Credentials is required.\u003c/p\u003e\n"],["\u003cp\u003eError handling, such as managing the "NOT_FOUND" exception, is incorporated in the examples to address cases where the cluster might not exist.\u003c/p\u003e\n"],["\u003cp\u003eThe page offers an introduction into getting started with Bigtable using the client libraries available, and references to the Google Cloud sample browser for further examples.\u003c/p\u003e\n"]]],[],null,["Delete a cluster, given a project ID and instance ID.\n\nCode sample \n\nC++\n\n\nTo learn how to install and use the client library for Bigtable, see\n[Bigtable client libraries](/bigtable/docs/reference/libraries).\n\n\nTo authenticate to Bigtable, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n namespace cbt = ::google::cloud::bigtable;\n namespace cbta = ::google::cloud::bigtable_admin;\n using ::google::cloud::Status;\n [](cbta::BigtableInstanceAdminClient instance_admin,\n std::string const& project_id, std::string const& instance_id,\n std::string const& cluster_id) {\n std::string cluster_name =\n cbt::ClusterName(project_id, instance_id, cluster_id);\n Status status = instance_admin.DeleteCluster(cluster_name);\n if (!status.ok()) throw std::runtime_error(status.message());\n }\n\nC#\n\n\nTo learn how to install and use the client library for Bigtable, see\n[Bigtable client libraries](/bigtable/docs/reference/libraries).\n\n\nTo authenticate to Bigtable, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n // Deltes cluster \"ssd-cluster2\" from instance.\n // At least one cluster must remain on an instance.\n // Initialize request argument(s)\n DeleteClusterRequest request = new DeleteClusterRequest\n {\n ClusterName = new ClusterName(projectId, instanceId, \"ssd-cluster2\")\n };\n try\n {\n // Make the request\n Console.WriteLine(\"Waiting for operation to complete...\");\n bigtableInstanceAdminClient.DeleteCluster(request);\n }\n catch (Exception ex)\n {\n Console.WriteLine($\"Exception deleting cluster {request.ClusterName.ClusterId} from instance {instanceId}\");\n Console.WriteLine(ex.Message);\n }\n\nJava\n\n\nTo learn how to install and use the client library for Bigtable, see\n[Bigtable client libraries](/bigtable/docs/reference/libraries).\n\n\nTo authenticate to Bigtable, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n try {\n adminClient.deleteCluster(instanceId, CLUSTER);\n System.out.printf(\"Cluster: %s deleted successfully%n\", CLUSTER);\n } catch (NotFoundException e) {\n System.err.println(\"Failed to delete a non-existent cluster: \" + e.getMessage());\n }\n\nNode.js\n\n\nTo learn how to install and use the client library for Bigtable, see\n[Bigtable client libraries](/bigtable/docs/reference/libraries).\n\n\nTo authenticate to Bigtable, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n console.log(); //for just a new-line\n console.log('Deleting Cluster');\n await cluster.delete();\n console.log(`Cluster deleted: ${cluster.id}`);\n\nPHP\n\n\nTo learn how to install and use the client library for Bigtable, see\n[Bigtable client libraries](/bigtable/docs/reference/libraries).\n\n\nTo authenticate to Bigtable, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n use Google\\ApiCore\\ApiException;\n use Google\\Cloud\\Bigtable\\Admin\\V2\\Client\\BigtableInstanceAdminClient;\n use Google\\Cloud\\Bigtable\\Admin\\V2\\DeleteClusterRequest;\n\n /**\n * Delete a cluster\n *\n * @param string $projectId The Google Cloud project ID\n * @param string $instanceId The ID of the Bigtable instance\n * @param string $clusterId The ID of the cluster to be deleted\n */\n function delete_cluster(\n string $projectId,\n string $instanceId,\n string $clusterId\n ): void {\n $instanceAdminClient = new BigtableInstanceAdminClient();\n $clusterName = $instanceAdminClient-\u003eclusterName($projectId, $instanceId, $clusterId);\n\n printf('Deleting Cluster' . PHP_EOL);\n try {\n $deleteClusterRequest = (new DeleteClusterRequest())\n -\u003esetName($clusterName);\n $instanceAdminClient-\u003edeleteCluster($deleteClusterRequest);\n printf('Cluster %s deleted.' . PHP_EOL, $clusterId);\n } catch (ApiException $e) {\n if ($e-\u003egetStatus() === 'NOT_FOUND') {\n printf('Cluster %s does not exist.' . PHP_EOL, $clusterId);\n } else {\n throw $e;\n }\n }\n }\n\nPython\n\n\nTo learn how to install and use the client library for Bigtable, see\n[Bigtable client libraries](/bigtable/docs/reference/libraries).\n\n\nTo authenticate to Bigtable, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n print(\"\\nDeleting cluster\")\n if cluster.exists():\n cluster.delete()\n print(\"Cluster deleted: {}\".format(cluster_id))\n else:\n print(\"\\nCluster {} does not exist.\".format(cluster_id))\n\nRuby\n\n\nTo learn how to install and use the client library for Bigtable, see\n[Bigtable client libraries](/bigtable/docs/reference/libraries).\n\n\nTo authenticate to Bigtable, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n cluster.delete\n\nWhat's next\n\n\nTo search and filter code samples for other Google Cloud products, see the\n[Google Cloud sample browser](/docs/samples?product=bigtable)."]]