cbt CLI를 사용하여 인스턴스를 만들고 데이터 쓰기
Bigtable에 대해 알아보려면 빠른 시작을 통해 프로덕션 환경에서 대규모로 사용할 기본 사항을 익힐 수 있습니다.
이 빠른 시작에서는 다음 작업을 수행합니다.
- Bigtable 인스턴스에 연결
- 기본 관리 작업 수행
- 테이블에 데이터 쓰기
- 테이블에서 데이터 읽기
시작하기 전에
- Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
- 
      Install the Google Cloud CLI. 
- 
          외부 ID 공급업체(IdP)를 사용하는 경우 먼저 제휴 ID로 gcloud CLI에 로그인해야 합니다. 
- 
        gcloud CLI를 초기화하려면, 다음 명령어를 실행합니다. gcloud init
- 
  
  
    Create or select a Google Cloud project. Roles required to select or create a project - Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
- 
      Create a project: To create a project, you need the Project Creator
      (roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
 - 
        Create a Google Cloud project: gcloud projects create PROJECT_ID Replace PROJECT_IDwith a name for the Google Cloud project you are creating.
- 
        Select the Google Cloud project that you created: gcloud config set project PROJECT_ID Replace PROJECT_IDwith your Google Cloud project name.
 
- 
  
    Verify that billing is enabled for your Google Cloud project. 
- 
  
  
    
      Enable the Cloud Bigtable and Cloud Bigtable Admin APIs: Roles required to enable APIs To enable APIs, you need the Service Usage Admin IAM role ( roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enablepermission. Learn how to grant roles.gcloud services enable bigtable.googleapis.com bigtableadmin.googleapis.com 
- 
    
        Grant roles to your user account. Run the following command once for each of the following IAM roles: roles/bigtable.admingcloud projects add-iam-policy-binding PROJECT_ID --member="user:USER_IDENTIFIER" --role=ROLE Replace the following: - PROJECT_ID: Your project ID.
- USER_IDENTIFIER: The identifier for your user account. For example,- myemail@example.com.
- ROLE: The IAM role that you grant to your user account.
 
- 
      Install the Google Cloud CLI. 
- 
          외부 ID 공급업체(IdP)를 사용하는 경우 먼저 제휴 ID로 gcloud CLI에 로그인해야 합니다. 
- 
        gcloud CLI를 초기화하려면, 다음 명령어를 실행합니다. gcloud init
- 
  
  
    Create or select a Google Cloud project. Roles required to select or create a project - Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
- 
      Create a project: To create a project, you need the Project Creator
      (roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
 - 
        Create a Google Cloud project: gcloud projects create PROJECT_ID Replace PROJECT_IDwith a name for the Google Cloud project you are creating.
- 
        Select the Google Cloud project that you created: gcloud config set project PROJECT_ID Replace PROJECT_IDwith your Google Cloud project name.
 
- 
  
    Verify that billing is enabled for your Google Cloud project. 
- 
  
  
    
      Enable the Cloud Bigtable and Cloud Bigtable Admin APIs: Roles required to enable APIs To enable APIs, you need the Service Usage Admin IAM role ( roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enablepermission. Learn how to grant roles.gcloud services enable bigtable.googleapis.com bigtableadmin.googleapis.com 
- 
    
        Grant roles to your user account. Run the following command once for each of the following IAM roles: roles/bigtable.admingcloud projects add-iam-policy-binding PROJECT_ID --member="user:USER_IDENTIFIER" --role=ROLE Replace the following: - PROJECT_ID: Your project ID.
- USER_IDENTIFIER: The identifier for your user account. For example,- myemail@example.com.
- ROLE: The IAM role that you grant to your user account.
 
- 다음 명령어를 실행하여 cbtCLI를 설치합니다.gcloud components install cbt
- Google Cloud 콘솔에서 인스턴스 만들기 페이지를 엽니다. 
- 인스턴스 이름에 - Quickstart instance를 입력합니다.
- 인스턴스 ID에 - quickstart-instance를 입력합니다.
- 계속을 클릭합니다. 
- 스토리지 유형으로 SSD를 선택합니다. 
- 계속을 클릭합니다. 
- 클러스터 ID에 - quickstart-instance-c1을 입력합니다.
- 리전으로 가까운 리전을 선택합니다. 
- 영역에서 모두를 선택합니다. 
- 노드 확장 모드에서 수동 할당을 선택합니다. 
- 수량에서 1을 선택합니다. 
- 만들기를 클릭하여 인스턴스를 만듭니다. 
- .cbtrc파일을 만들고- PROJECT_ID를 Bigtable 인스턴스를 만든 프로젝트의 ID로 바꿔 프로젝트와 인스턴스를 사용하도록- cbtCLI를 구성합니다.- echo project = PROJECT_ID >> ~/.cbtrc && echo instance = quickstart-instance >> ~/.cbtrc 
- .cbtrc파일을 올바르게 설정했는지 확인합니다.- cat ~/.cbtrc - 터미널에는 - .cbtrc파일의 콘텐츠가 표시됩니다. 이는 다음과 유사합니다.- project = PROJECT_ID instance = quickstart-instance - 이제 인스턴스에서 - cbtCLI를 사용할 수 있습니다.
- 이름이 - my-table인 테이블을 만듭니다.- cbt createtable my-table 
- 테이블을 나열합니다. - cbt ls - 이 명령어는 다음과 비슷한 출력을 표시합니다. - my-table
- 이름이 - cf1인 column family 1개를 추가합니다.- cbt createfamily my-table cf1 
- column family를 나열합니다. - cbt ls my-table - 이 명령어는 다음과 비슷한 출력을 표시합니다. - Family Name GC Policy ----------- --------- cf1 <never>
- column family - cf1및 column qualifier- c1을 사용하여- test-value1및- test-value2값을- r1행에 입력합니다.- cbt set my-table r1 cf1:c1=test-value1 cbt set my-table r1 cf1:c1=test-value2 
- cbt read명령어를 사용하여 테이블에 추가한 데이터를 읽습니다.- cbt read my-table - 다음과 유사한 출력이 셸에 표시됩니다. - ---------------------------------------- r1 cf1:c1 @ 2023/03/22-06:56:11.323000 "test-value1" cf1:c1 @ 2023/03/22-06:56:04.361000 "test-value2"- r1행의 동일한 열에 타임스탬프가 지정된 두 개의 값이 저장됩니다.
- my-table테이블을 삭제합니다.- cbt deletetable my-table 
- 인스턴스를 삭제합니다. - cbt deleteinstance quickstart-instance 
- .cbtrc파일을 삭제합니다.- rm ~/.cbtrc 
- 선택사항: gcloud CLI에서 사용자 인증 정보를 취소합니다. - gcloud auth revoke 
- Bigtable Codelab 살펴보기
- cbtCLI 참조 문서 보기
- 사기 감지 사용 사례의 샘플 소스 코드 참조하기
- Hello World 애플리케이션을 C#, C++, Go, 자바, Node.js, PHP, Python, Ruby로 또는자바용 HBase 클라이언트를 사용하여 작성
Bigtable 인스턴스를 만듭니다.
내 인스턴스에 연결
데이터 읽기 및 쓰기
Bigtable은 행을 포함하는 테이블에 데이터를 저장합니다. 각 행은 row key로 식별됩니다.
행의 데이터는 열의 그룹인 column family로 구성됩니다. column qualifier는 column family 내의 단일 열을 식별합니다.
행과 열의 교차점에는 타임스탬프가 지정된 셀이 여러 개 있을 수 있습니다.
삭제
이 빠른 시작에서 사용한 리소스에 대한 비용이 Google Cloud 계정에 청구되지 않게 하려면 인스턴스를 삭제합니다. .cbtrc 파일을 삭제하면 다른 프로젝트에서 작업할 수 있습니다.