创建复制的集群

在当前项目中创建一个复制的集群。

代码示例

C++

如需了解如何安装和使用 Bigtable 的客户端库,请参阅 Bigtable 客户端库

namespace cbt = ::google::cloud::bigtable;
using ::google::cloud::future;
using ::google::cloud::StatusOr;
[](cbt::InstanceAdmin instance_admin, std::string const& instance_id,
   std::string const& zone_a, std::string const& zone_b) {
  std::string display_name("Put description here");
  auto c1 = instance_id + "-c1";
  auto c2 = instance_id + "-c2";
  cbt::InstanceConfig config(
      instance_id, display_name,
      {{c1, cbt::ClusterConfig(zone_a, 3, cbt::ClusterConfig::HDD)},
       {c2, cbt::ClusterConfig(zone_b, 3, cbt::ClusterConfig::HDD)}});
  config.set_type(cbt::InstanceConfig::PRODUCTION);

  future<StatusOr<google::bigtable::admin::v2::Instance>> instance_future =
      instance_admin.CreateInstance(config);
  // Show how to perform additional work while the long running operation
  // completes. The application could use future.then() instead.
  std::cout << "Waiting for instance creation to complete " << std::flush;
  instance_future.wait_for(std::chrono::seconds(1));
  std::cout << '.' << std::flush;
  auto instance = instance_future.get();
  if (!instance) throw std::runtime_error(instance.status().message());
  std::cout << "DONE, details=" << instance->DebugString() << "\n";
}

后续步骤

如需搜索和过滤其他 Google Cloud 产品的代码示例,请参阅 Google Cloud 示例浏览器