刪除叢集
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
根據專案 ID 和執行個體 ID 刪除叢集。
程式碼範例
C++
如要瞭解如何安裝及使用 Bigtable 的用戶端程式庫,請參閱這篇文章。
如要向 Bigtable 進行驗證,請設定應用程式預設憑證。
詳情請參閱「為本機開發環境設定驗證」。
C#
如要瞭解如何安裝及使用 Bigtable 的用戶端程式庫,請參閱這篇文章。
如要向 Bigtable 進行驗證,請設定應用程式預設憑證。
詳情請參閱「為本機開發環境設定驗證」。
Java
如要瞭解如何安裝及使用 Bigtable 的用戶端程式庫,請參閱這篇文章。
如要向 Bigtable 進行驗證,請設定應用程式預設憑證。
詳情請參閱「為本機開發環境設定驗證」。
Node.js
如要瞭解如何安裝及使用 Bigtable 的用戶端程式庫,請參閱這篇文章。
如要向 Bigtable 進行驗證,請設定應用程式預設憑證。
詳情請參閱「為本機開發環境設定驗證」。
PHP
如要瞭解如何安裝及使用 Bigtable 的用戶端程式庫,請參閱這篇文章。
如要向 Bigtable 進行驗證,請設定應用程式預設憑證。
詳情請參閱「為本機開發環境設定驗證」。
Python
如要瞭解如何安裝及使用 Bigtable 的用戶端程式庫,請參閱這篇文章。
如要向 Bigtable 進行驗證,請設定應用程式預設憑證。
詳情請參閱「為本機開發環境設定驗證」。
Ruby
如要瞭解如何安裝及使用 Bigtable 的用戶端程式庫,請參閱這篇文章。
如要向 Bigtable 進行驗證,請設定應用程式預設憑證。
詳情請參閱「為本機開發環境設定驗證」。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。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)."]]