Criar um cluster replicado
Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Criar um cluster replicado no projeto atual.
Exemplo de código
Exceto em caso de indicação contrária, o conteúdo desta página é licenciado de acordo com a Licença de atribuição 4.0 do Creative Commons, e as amostras de código são licenciadas de acordo com a Licença Apache 2.0. Para mais detalhes, consulte as políticas do site do Google Developers. Java é uma marca registrada da Oracle e/ou afiliadas.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","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)."]]