이 페이지에서는 Google Cloud CLI, 클라이언트 라이브러리, Spanner 드라이버와 함께 Cloud Spanner API를 사용하는 데 필요한 설정 단계를 안내합니다.
Google Cloud 콘솔에서 Spanner를 사용하려면 콘솔을 사용한 빠른 시작을 참조하세요.
Google Cloud 프로젝트 설정
-
Google Cloud 콘솔의 프로젝트 페이지로 이동합니다.
- 새 Google Cloud 프로젝트를 만들거나 프로젝트 이름을 클릭하여 기존 프로젝트를 엽니다.
-
터미널 창을 열고
MY_PROJECT_ID
를 프로젝트 ID(프로젝트 이름 아님)로 바꾸어 프로젝트를 Google Cloud CLI의 기본 프로젝트로 설정합니다.gcloud config set project MY_PROJECT_ID
-
Make sure that billing is enabled for your Google Cloud project.
Spanner 가격 책정에 대해서도 알아볼 수 있습니다.
-
프로젝트에서 Cloud Spanner API를 사용하도록 설정합니다.
참고: 다른 프로젝트의 서비스 계정을 사용하여 Spanner 인스턴스에 액세스하는 경우 두 프로젝트 모두에서 Spanner API를 사용 설정해야 합니다.
인증 설정
Select the tabs for how you plan to access the API:
Console
When you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.
gcloud
After installing the Google Cloud CLI, initialize it by running the following command:
gcloud init
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
Terraform
로컬 개발 환경에서 이 페이지의 Terraform 샘플을 사용하려면 gcloud CLI를 설치 및 초기화한 다음 사용자 인증 정보로 애플리케이션 기본 사용자 인증 정보를 설정하세요.
-
Install the Google Cloud CLI.
-
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
-
To initialize the gcloud CLI, run the following command:
gcloud init
-
If you're using a local shell, then create local authentication credentials for your user account:
gcloud auth application-default login
You don't need to do this if you're using Cloud Shell.
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
자세한 내용은 다음을 참조하세요: Set up authentication for a local development environment.
C#
로컬 개발 환경에서 이 페이지의 .NET 샘플을 사용하려면 gcloud CLI를 설치 및 초기화한 다음 사용자 인증 정보로 애플리케이션 기본 사용자 인증 정보를 설정하세요.
-
Install the Google Cloud CLI.
-
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
-
To initialize the gcloud CLI, run the following command:
gcloud init
-
If you're using a local shell, then create local authentication credentials for your user account:
gcloud auth application-default login
You don't need to do this if you're using Cloud Shell.
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
자세한 내용은 다음을 참조하세요: Set up authentication for a local development environment.
C++
로컬 개발 환경에서 이 페이지의 C++ 샘플을 사용하려면 gcloud CLI를 설치 및 초기화한 다음 사용자 인증 정보로 애플리케이션 기본 사용자 인증 정보를 설정하세요.
-
Install the Google Cloud CLI.
-
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
-
To initialize the gcloud CLI, run the following command:
gcloud init
-
If you're using a local shell, then create local authentication credentials for your user account:
gcloud auth application-default login
You don't need to do this if you're using Cloud Shell.
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
자세한 내용은 다음을 참조하세요: Set up authentication for a local development environment.
Go
로컬 개발 환경에서 이 페이지의 Go 샘플을 사용하려면 gcloud CLI를 설치 및 초기화한 다음 사용자 인증 정보로 애플리케이션 기본 사용자 인증 정보를 설정하세요.
-
Install the Google Cloud CLI.
-
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
-
To initialize the gcloud CLI, run the following command:
gcloud init
-
If you're using a local shell, then create local authentication credentials for your user account:
gcloud auth application-default login
You don't need to do this if you're using Cloud Shell.
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
자세한 내용은 다음을 참조하세요: Set up authentication for a local development environment.
Java
로컬 개발 환경에서 이 페이지의 Java 샘플을 사용하려면 gcloud CLI를 설치 및 초기화한 다음 사용자 인증 정보로 애플리케이션 기본 사용자 인증 정보를 설정하세요.
-
Install the Google Cloud CLI.
-
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
-
To initialize the gcloud CLI, run the following command:
gcloud init
-
If you're using a local shell, then create local authentication credentials for your user account:
gcloud auth application-default login
You don't need to do this if you're using Cloud Shell.
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
자세한 내용은 다음을 참조하세요: Set up authentication for a local development environment.
Node.js
로컬 개발 환경에서 이 페이지의 Node.js 샘플을 사용하려면 gcloud CLI를 설치 및 초기화한 다음 사용자 인증 정보로 애플리케이션 기본 사용자 인증 정보를 설정하세요.
-
Install the Google Cloud CLI.
-
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
-
To initialize the gcloud CLI, run the following command:
gcloud init
-
If you're using a local shell, then create local authentication credentials for your user account:
gcloud auth application-default login
You don't need to do this if you're using Cloud Shell.
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
자세한 내용은 다음을 참조하세요: Set up authentication for a local development environment.
PHP
로컬 개발 환경에서 이 페이지의 PHP 샘플을 사용하려면 gcloud CLI를 설치 및 초기화한 다음 사용자 인증 정보로 애플리케이션 기본 사용자 인증 정보를 설정하세요.
-
Install the Google Cloud CLI.
-
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
-
To initialize the gcloud CLI, run the following command:
gcloud init
-
If you're using a local shell, then create local authentication credentials for your user account:
gcloud auth application-default login
You don't need to do this if you're using Cloud Shell.
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
자세한 내용은 다음을 참조하세요: Set up authentication for a local development environment.
Python
로컬 개발 환경에서 이 페이지의 Python 샘플을 사용하려면 gcloud CLI를 설치 및 초기화한 다음 사용자 인증 정보로 애플리케이션 기본 사용자 인증 정보를 설정하세요.
-
Install the Google Cloud CLI.
-
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
-
To initialize the gcloud CLI, run the following command:
gcloud init
-
If you're using a local shell, then create local authentication credentials for your user account:
gcloud auth application-default login
You don't need to do this if you're using Cloud Shell.
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
자세한 내용은 다음을 참조하세요: Set up authentication for a local development environment.
Ruby
로컬 개발 환경에서 이 페이지의 Ruby 샘플을 사용하려면 gcloud CLI를 설치 및 초기화한 다음 사용자 인증 정보로 애플리케이션 기본 사용자 인증 정보를 설정하세요.
-
Install the Google Cloud CLI.
-
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
-
To initialize the gcloud CLI, run the following command:
gcloud init
-
If you're using a local shell, then create local authentication credentials for your user account:
gcloud auth application-default login
You don't need to do this if you're using Cloud Shell.
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
자세한 내용은 다음을 참조하세요: Set up authentication for a local development environment.
REST
로컬 개발 환경에서 이 페이지의 REST API 샘플을 사용하려면 gcloud CLI에 제공한 사용자 인증 정보를 사용합니다.
After installing the Google Cloud CLI, initialize it by running the following command:
gcloud init
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
자세한 내용은 Google Cloud 인증 문서의 REST 사용을 위한 인증을 참조하세요.
Google Cloud CLI 실행
개발 환경과 인증을 설정했으므로 이제 gcloud
명령줄 도구를 실행하여 Spanner와 상호작용합니다.
gcloud spanner instance-configs list
프로젝트가 액세스할 수 있는 Spanner 인스턴스 구성의 목록(리전 구성, 이중 리전 구성, 멀티 리전 구성 포함)이 표시됩니다. 자세한 내용은 인스턴스 개요를 참조하세요.
이제 설정을 완료하였습니다.
다음 단계
Cloud 클라이언트 라이브러리와 드라이버를 사용하여 Spanner 인스턴스, 데이터베이스, 테이블, 색인을 만드는 방법을 알아봅니다. 그런 다음 Spanner에서 데이터를 저장하고 쿼리하고 읽으세요.
- C++에서 Spanner 시작하기
- C++에서 Spanner 시작하기
- Go에서 Spanner 시작하기
- 자바에서 Spanner 시작하기
- JDBC에서 Spanner 시작하기
- Node.js에서 Spanner 시작하기
- PHP에서 Spanner 시작하기
- Python에서 Spanner 시작하기
- Ruby에서 Spanner 시작하기
- REST에서 Spanner 시작하기
- gcloud에서 Spanner 시작하기
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-06-11(UTC)