Replizierten Cluster erstellen
Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Replizierten Cluster im aktuellen Projekt erstellen
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 demonstrates how to create a replicated cluster within a Google Cloud project using the Bigtable client library for C++.\u003c/p\u003e\n"],["\u003cp\u003eThe code utilizes the \u003ccode\u003eBigtableInstanceAdminClient\u003c/code\u003e to create an instance with a production type and a specified display name.\u003c/p\u003e\n"],["\u003cp\u003eThe example sets up two clusters, \u003ccode\u003ecluster1\u003c/code\u003e and \u003ccode\u003ecluster2\u003c/code\u003e, in different zones (\u003ccode\u003ezone_a\u003c/code\u003e and \u003ccode\u003ezone_b\u003c/code\u003e), each with three serve nodes and HDD storage.\u003c/p\u003e\n"],["\u003cp\u003eAuthentication to Bigtable requires setting up Application Default Credentials, as detailed in the provided documentation link.\u003c/p\u003e\n"],["\u003cp\u003eThe provided code will create an instance asynchronously, and waits until the operation is complete to display the results.\u003c/p\u003e\n"]]],[],null,["Create a replicated cluster in the current project.\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 cbta = ::google::cloud::bigtable_admin;\n using ::google::cloud::future;\n using ::google::cloud::Location;\n using ::google::cloud::Project;\n using ::google::cloud::StatusOr;\n\n [](cbta::BigtableInstanceAdminClient instance_admin,\n std::string const& project_id, std::string const& instance_id,\n std::string const& zone_a, std::string const& zone_b) {\n auto const project = Project(project_id);\n std::string project_name = project.FullName();\n std::string c1 = instance_id + \"-c1\";\n std::string c2 = instance_id + \"-c2\";\n\n google::bigtable::admin::v2::Instance in;\n in.set_type(google::bigtable::admin::v2::Instance::PRODUCTION);\n in.set_display_name(\"Put description here\");\n\n google::bigtable::admin::v2::Cluster cluster1;\n cluster1.set_location(Location(project, zone_a).FullName());\n cluster1.set_serve_nodes(3);\n cluster1.set_default_storage_type(google::bigtable::admin::v2::HDD);\n\n google::bigtable::admin::v2::Cluster cluster2;\n cluster2.set_location(Location(project, zone_b).FullName());\n cluster2.set_serve_nodes(3);\n cluster2.set_default_storage_type(google::bigtable::admin::v2::HDD);\n\n std::map\u003cstd::string, google::bigtable::admin::v2::Cluster\u003e cluster_map = {\n {c1, std::move(cluster1)}, {c2, std::move(cluster2)}};\n\n future\u003cStatusOr\u003cgoogle::bigtable::admin::v2::Instance\u003e\u003e instance_future =\n instance_admin.CreateInstance(project_name, instance_id, std::move(in),\n std::move(cluster_map));\n // Show how to perform additional work while the long running operation\n // completes. The application could use future.then() instead.\n std::cout \u003c\u003c \"Waiting for instance creation to complete \" \u003c\u003c std::flush;\n instance_future.wait_for(std::chrono::seconds(1));\n std::cout \u003c\u003c '.' \u003c\u003c std::flush;\n auto instance = instance_future.get();\n if (!instance) throw std::move(instance).status();\n std::cout \u003c\u003c \"DONE, details=\" \u003c\u003c instance-\u003eDebugString() \u003c\u003c \"\\n\";\n }\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)."]]