Creating and managing instances

This page describes how to create, list, edit, and delete Cloud Spanner instances.

Creating an instance

You can create an instance with the gcloud command-line tool or with the Google Cloud Platform Console.

Console

  1. Go to the Create an instance page in the GCP Console.

    Create an instance

  2. Enter the following values:

    • An instance name to display in the GCP Console. The instance name must be unique within your Google Cloud Platform project.
    • An instance ID to permanently identify your instance. The instance ID must also be unique within your GCP project. You cannot change the instance ID later.
    • A configuration, which defines the geographic location of the instance's nodes and affects how data is replicated. Learn more about instance configurations.
    • The number of nodes for the instance. The number of nodes determines the amount of serving and storage resources that are available to databases in the instance.
  3. Click Create to create the instance.

The following screenshot shows the instance creation page:

Screenshot of the instance creation page

gcloud

Use the gcloud spanner instances create command:

gcloud spanner instances create [INSTANCE-ID] --config=[INSTANCE-CONFIG] \
    --description="[INSTANCE-NAME]" --nodes=[NODE-COUNT]

Provide the following values:

  • [INSTANCE-ID]: A permanent identifier that is unique within your Google Cloud Platform project. You cannot change the instance ID later.
  • [INSTANCE-CONFIG]: The instance configuration, which defines the geographic location of the instance's nodes and affects how data is replicated. Learn more about instance configurations.
  • [INSTANCE-NAME]: The name to display for the instance in the GCP Console. The instance name must be unique within your Google Cloud Platform project.
  • [NODE-COUNT]: The number of nodes for the instance. The number of nodes determines the amount of serving and storage resources that are available to databases in the instance.

For example:

gcloud spanner instances create test-instance --config=regional-us-central1 \
    --description="Test Instance" --nodes=1

You should see a message similar to the following example:

Creating instance...done.

Listing instances

Console

Go to the Spanner Instances page in the GCP Console.

Go to the Instances page

The GCP Console shows a list of your Cloud Spanner instances, along with each instance's ID, display name, configuration, and number of nodes.

gcloud

Use the gcloud spanner instances list command:

gcloud spanner instances list

The gcloud tool prints a list of your Cloud Spanner instances, along with each instance's ID, display name, configuration, and number of nodes.

Editing an instance

The following sections explain how to change an instance's display name and number of nodes. You cannot change the instance ID or instance configuration.

Changing the display name

Console

  1. Go to the Spanner Instances page in the GCP Console.

    Go to the Instances page

  2. Click the name of the instance that you want to rename.

  3. Click Edit instance.

  4. Enter a new instance name. This name must be unique within the GCP project.

  5. Click Save.

gcloud

Use the gcloud spanner instances update command:

gcloud spanner instances update [INSTANCE-ID] --description=[INSTANCE-NAME]

Provide the following values:

  • [INSTANCE-ID]: The permanent identifier for the instance.
  • [INSTANCE-NAME]: The name to display for the instance in the GCP Console. The instance name must be unique within your Google Cloud Platform project.

Changing the number of nodes

You must provision enough nodes to accommodate your storage needs and keep CPU utilization below the recommended maximums. For more information about the resources provided by a node, see the quotas and limits for Cloud Spanner.

There are a few cases in which you cannot remove nodes from an existing instance:

  • Removing the nodes would require your instance to store more than 2 TB of data per node.
  • Based on your historic usage patterns, Cloud Spanner has created a large number of splits for your instance's data, and Cloud Spanner would not be able to manage the splits after removing the nodes.

If you want to increase the number of nodes in an instance, your GCP project must have sufficient quota to add the nodes.

Console

  1. Go to the Spanner Instances page in the GCP Console.

    Go to the Instances page

  2. Click the name of the instance that you want to change.

  3. Click Edit Instance.

  4. Enter the number of nodes that you want.

  5. Click Save.

    If you see a dialog that says you have insufficient quota to add nodes in this location, follow the instructions to request a higher quota.

gcloud

Use the gcloud spanner instances update command:

gcloud spanner instances update [INSTANCE-ID] --nodes=[NODE-COUNT]

Provide the following values:

  • [INSTANCE-ID]: The permanent identifier for the instance.
  • [NODE-COUNT]: The number of nodes for the instance.

Deleting an instance

Console

  1. Go to the Spanner Instances page in the GCP Console.

    Go to the Instances page

  2. Click the name of the instance that you want to delete.

  3. Click Delete instance.

  4. Follow the instructions to confirm that you want to delete the instance.

  5. Click Delete.

gcloud

Use the gcloud spanner instances delete command, replacing [INSTANCE-ID] with the instance ID:

gcloud spanner instances delete [INSTANCE-ID]

What's next

Var denne siden nyttig? Si fra hva du synes:

Send tilbakemelding om ...

Cloud Spanner Documentation