복제된 클러스터 만들기

현재 프로젝트에서 복제된 클러스터를 만듭니다.

코드 샘플

C++

Bigtable용 클라이언트 라이브러리를 설치하고 사용하는 방법은 Bigtable 클라이언트 라이브러리를 참조하세요.

Bigtable에 인증하려면 애플리케이션 기본 사용자 인증 정보를 설정합니다. 자세한 내용은 로컬 개발 환경의 인증 설정을 참조하세요.

namespace cbta = ::google::cloud::bigtable_admin;
using ::google::cloud::future;
using ::google::cloud::Location;
using ::google::cloud::Project;
using ::google::cloud::StatusOr;

[](cbta::BigtableInstanceAdminClient instance_admin,
   std::string const& project_id, std::string const& instance_id,
   std::string const& zone_a, std::string const& zone_b) {
  auto const project = Project(project_id);
  std::string project_name = project.FullName();
  std::string c1 = instance_id + "-c1";
  std::string c2 = instance_id + "-c2";

  google::bigtable::admin::v2::Instance in;
  in.set_type(google::bigtable::admin::v2::Instance::PRODUCTION);
  in.set_display_name("Put description here");

  google::bigtable::admin::v2::Cluster cluster1;
  cluster1.set_location(Location(project, zone_a).FullName());
  cluster1.set_serve_nodes(3);
  cluster1.set_default_storage_type(google::bigtable::admin::v2::HDD);

  google::bigtable::admin::v2::Cluster cluster2;
  cluster2.set_location(Location(project, zone_b).FullName());
  cluster2.set_serve_nodes(3);
  cluster2.set_default_storage_type(google::bigtable::admin::v2::HDD);

  std::map<std::string, google::bigtable::admin::v2::Cluster> cluster_map = {
      {c1, std::move(cluster1)}, {c2, std::move(cluster2)}};

  future<StatusOr<google::bigtable::admin::v2::Instance>> instance_future =
      instance_admin.CreateInstance(project_name, instance_id, std::move(in),
                                    std::move(cluster_map));
  // 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::move(instance).status();
  std::cout << "DONE, details=" << instance->DebugString() << "\n";
}

다음 단계

다른 Google Cloud 제품의 코드 샘플을 검색하고 필터링하려면 Google Cloud 샘플 브라우저를 참조하세요.