Cluster löschen
Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Einen Cluster anhand einer Projekt-ID und Instanz-ID löschen.
Codebeispiel
Nächste Schritte
Wenn Sie nach Codebeispielen für andere Google Cloud -Produkte suchen und filtern möchten, können Sie den Google Cloud -Beispielbrowser verwenden.
Sofern nicht anders angegeben, sind die Inhalte dieser Seite unter der Creative Commons Attribution 4.0 License und Codebeispiele unter der Apache 2.0 License lizenziert. Weitere Informationen finden Sie in den Websiterichtlinien von Google Developers. Java ist eine eingetragene Marke von Oracle und/oder seinen Partnern.
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","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)."]]