์ธ์Šคํ„ด์Šค ํŒŒํ‹ฐ์…˜ ๋งŒ๋“ค๊ธฐ ๋ฐ ๊ด€๋ฆฌ

์ด ํŽ˜์ด์ง€์—์„œ๋Š” Spanner ์ธ์Šคํ„ด์Šค ํŒŒํ‹ฐ์…˜์„ ๋งŒ๋“ค๊ณ  ๊ด€๋ฆฌํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์„ค๋ช…ํ•ฉ๋‹ˆ๋‹ค.

์ธ์Šคํ„ด์Šค ํŒŒํ‹ฐ์…˜ ๋งŒ๋“ค๊ธฐ

์ฝ˜์†”

  1. Google Cloud ์ฝ˜์†”์—์„œ Spanner ํŽ˜์ด์ง€๋ฅผ ์—ฝ๋‹ˆ๋‹ค.

    Spanner๋กœ ์ด๋™

  2. ์ธ์Šคํ„ด์Šค ํŒŒํ‹ฐ์…˜์„ ์ถ”๊ฐ€ํ•  ์ธ์Šคํ„ด์Šค๋ฅผ ์„ ํƒํ•ฉ๋‹ˆ๋‹ค.

  3. ํƒ์ƒ‰ ๋ฉ”๋‰ด์—์„œ ์ธ์Šคํ„ด์Šค ํŒŒํ‹ฐ์…˜์„ ์„ ํƒํ•ฉ๋‹ˆ๋‹ค.

  4. ์ธ์Šคํ„ด์Šค ํŒŒํ‹ฐ์…˜ ๋งŒ๋“ค๊ธฐ๋ฅผ ํด๋ฆญํ•ฉ๋‹ˆ๋‹ค.

  5. ์ธ์Šคํ„ด์Šค ํŒŒํ‹ฐ์…˜์„ ์˜๊ตฌ ์‹๋ณ„ํ•  ํŒŒํ‹ฐ์…˜ ID๋ฅผ ์ž…๋ ฅํ•ฉ๋‹ˆ๋‹ค. ์ธ์Šคํ„ด์Šค ํŒŒํ‹ฐ์…˜ ID๋„Google Cloud ํ”„๋กœ์ ํŠธ ๋‚ด์—์„œ ๊ณ ์œ ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์ธ์Šคํ„ด์Šค ํŒŒํ‹ฐ์…˜ ID๋Š” ๋‚˜์ค‘์— ๋ณ€๊ฒฝํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.

  6. ๊ตฌ์„ฑ ์„ ํƒ ์„น์…˜์—์„œ ๋ฆฌ์ „ ๋˜๋Š” ๋ฉ€ํ‹ฐ ๋ฆฌ์ „์„ ์„ ํƒํ•ฉ๋‹ˆ๋‹ค. ๋˜๋Š” ๋ฆฌ์ „ ๊ฐ„ ์‚ฌ์–‘์„ ๋น„๊ตํ•˜๋ ค๋ฉด ๋ฆฌ์ „ ๊ตฌ์„ฑ ๋น„๊ต๋ฅผ ํด๋ฆญํ•ฉ๋‹ˆ๋‹ค.

  7. ๋“œ๋กญ๋‹ค์šด ๋ฉ”๋‰ด์—์„œ ๊ตฌ์„ฑ์„ ์„ ํƒํ•ฉ๋‹ˆ๋‹ค.

  8. ์ปดํ“จํŒ… ์šฉ๋Ÿ‰ ํ• ๋‹น ์„น์…˜์˜ ๋‹จ์œ„์—์„œ ๋‹ค์Œ ์ค‘ ํ•˜๋‚˜๋ฅผ ํด๋ฆญํ•ฉ๋‹ˆ๋‹ค.

    • ์ž‘์€ ์ธ์Šคํ„ด์Šค ํŒŒํ‹ฐ์…˜์˜ ๊ฒฝ์šฐ ์ฒ˜๋ฆฌ ๋‹จ์œ„
    • ํฐ ์ธ์Šคํ„ด์Šค์˜ ๊ฒฝ์šฐ ๋…ธ๋“œ. ๋…ธ๋“œ ํ•˜๋‚˜๋Š” ์ฒ˜๋ฆฌ ๋‹จ์œ„ 1,000๊ฐœ์ž…๋‹ˆ๋‹ค.
  9. ์„ ํƒํ•œ ๋‹จ์œ„์˜ ๊ฐ’์„ ์ž…๋ ฅํ•ฉ๋‹ˆ๋‹ค.

    ์ธ์Šคํ„ด์Šค ํŒŒํ‹ฐ์…˜์— ์ตœ์†Œ ๋…ธ๋“œ 1๊ฐœ ๋˜๋Š” ์ฒ˜๋ฆฌ ๋‹จ์œ„ 1,000๊ฐœ ์ด์ƒ์ด ์žˆ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

  10. ๋งŒ๋“ค๊ธฐ๋ฅผ ํด๋ฆญํ•˜์—ฌ ์ธ์Šคํ„ด์Šค ํŒŒํ‹ฐ์…˜์„ ๋งŒ๋“ญ๋‹ˆ๋‹ค.

gcloud

์ธ์Šคํ„ด์Šค ํŒŒํ‹ฐ์…˜์„ ๋งŒ๋“ค๋ ค๋ฉด gcloud beta spanner instance-partitions create๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.

gcloud beta spanner instance-partitions create INSTANCE_PARTITION_ID \
  --config=INSTANCE_PARTITION_CONFIG \
  --description="INSTANCE_PARTITION_DESCRIPTION" \
  --instance=INSTANCE_ID \
  [--nodes=NODE_COUNT | --processing-units=PROCESSING_UNIT_COUNT]

๋‹ค์Œ์„ ๋ฐ”๊ฟ‰๋‹ˆ๋‹ค.

  • INSTANCE_PARTITION_ID: Google Cloud ํ”„๋กœ์ ํŠธ ๋‚ด์—์„œ ๊ณ ์œ ํ•œ ์˜๊ตฌ ์ธ์Šคํ„ด์Šค ํŒŒํ‹ฐ์…˜ ์‹๋ณ„์ž์ž…๋‹ˆ๋‹ค. ์ธ์Šคํ„ด์Šค ํŒŒํ‹ฐ์…˜ ID๋Š” ๋‚˜์ค‘์— ๋ณ€๊ฒฝํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.
  • INSTANCE_PARTITION_CONFIG: ์ธ์Šคํ„ด์Šค ํŒŒํ‹ฐ์…˜ ๊ตฌ์„ฑ์˜ ์˜๊ตฌ ์‹๋ณ„์ž๋กœ, ์ธ์Šคํ„ด์Šค ํŒŒํ‹ฐ์…˜์˜ ์ง€๋ฆฌ์  ์œ„์น˜๋ฅผ ์ •์˜ํ•˜๊ณ  ๋ฐ์ดํ„ฐ๊ฐ€ ์ €์žฅ๋˜๋Š” ์œ„์น˜์— ์˜ํ–ฅ์„ ๋ฏธ์นฉ๋‹ˆ๋‹ค.
  • INSTANCE_PARTITION_DESCRIPTION: Google Cloud ์ฝ˜์†”์— ํ‘œ์‹œ๋˜๋Š” ์ธ์Šคํ„ด์Šค ํŒŒํ‹ฐ์…˜ ์ด๋ฆ„์ž…๋‹ˆ๋‹ค. ์ธ์Šคํ„ด์Šค ํŒŒํ‹ฐ์…˜ ์ด๋ฆ„์€ Google Cloud ํ”„๋กœ์ ํŠธ ๋‚ด์—์„œ ๊ณ ์œ ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.
  • INSTANCE_ID: ์ด ์ธ์Šคํ„ด์Šค ํŒŒํ‹ฐ์…˜์ด ์žˆ๋Š” Spanner ์ธ์Šคํ„ด์Šค์˜ ์˜๊ตฌ ์‹๋ณ„์ž์ž…๋‹ˆ๋‹ค.
  • NODE_COUNT: ์ธ์Šคํ„ด์Šค ํŒŒํ‹ฐ์…˜์˜ ์ปดํ“จํŒ… ์šฉ๋Ÿ‰์œผ๋กœ, ๋…ธ๋“œ ์ˆ˜๋กœ ํ‘œํ˜„๋ฉ๋‹ˆ๋‹ค. ๋…ธ๋“œ 1๊ฐœ๋Š” ์ฒ˜๋ฆฌ ๋‹จ์œ„ 1,000๊ฐœ์™€ ๊ฐ™์Šต๋‹ˆ๋‹ค.
  • PROCESSING_UNIT_COUNT: ์ธ์Šคํ„ด์Šค์˜ ์ปดํ“จํŒ… ์šฉ๋Ÿ‰์œผ๋กœ์„œ ์ฒ˜๋ฆฌ ๋‹จ์œ„ ์ˆ˜๋กœ ํ‘œํ˜„๋ฉ๋‹ˆ๋‹ค. ์ธ์Šคํ„ด์Šค ํŒŒํ‹ฐ์…˜์— ์ฒ˜๋ฆฌ ๋‹จ์œ„๊ฐ€ ์ตœ์†Œ 1,000๊ฐœ ์ด์ƒ ์žˆ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์ˆ˜๋Ÿ‰์„ 1,000์˜ ๋ฐฐ์ˆ˜(1,000, 2,000, 3,000 ๋“ฑ)๋กœ ์ž…๋ ฅํ•ฉ๋‹ˆ๋‹ค.

์˜ˆ๋ฅผ ๋“ค์–ด eur3์— ๋…ธ๋“œ 5๊ฐœ๊ฐ€ ์žˆ๋Š” ์ธ์Šคํ„ด์Šค ํŒŒํ‹ฐ์…˜ europe-partition์„ ๋งŒ๋“ค๋ ค๋ฉด ๋‹ค์Œ์„ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.

  gcloud beta spanner instance-partitions create europe-partition --config=eur3 \
    --description="europe-partition" --instance=test-instance --nodes=5

ํด๋ผ์ด์–ธํŠธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ

C++

Spanner์šฉ ํด๋ผ์ด์–ธํŠธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์„ค์น˜ํ•˜๊ณ  ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์€ Spanner ํด๋ผ์ด์–ธํŠธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์ฐธ๊ณ ํ•˜์„ธ์š”.

void CreateInstancePartition(
    google::cloud::spanner_admin::InstanceAdminClient client,
    std::string const& project_id, std::string const& instance_id,
    std::string const& instance_partition_id) {
  auto project = google::cloud::Project(project_id);
  auto in = google::cloud::spanner::Instance(project_id, instance_id);
  auto config = project.FullName() + "/instanceConfigs/nam3";

  google::spanner::admin::instance::v1::CreateInstancePartitionRequest request;
  request.set_parent(in.FullName());
  request.set_instance_partition_id(instance_partition_id);
  request.mutable_instance_partition()->set_display_name(
      "Test instance partition");
  request.mutable_instance_partition()->set_node_count(1);
  request.mutable_instance_partition()->set_config(config);

  auto instance_partition = client.CreateInstancePartition(request).get();
  if (!instance_partition) throw std::move(instance_partition).status();
  std::cout << "Created instance partition [" << instance_partition_id << "]:\n"
            << instance_partition->DebugString();
}

C#

Spanner์šฉ ํด๋ผ์ด์–ธํŠธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์„ค์น˜ํ•˜๊ณ  ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์€ Spanner ํด๋ผ์ด์–ธํŠธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์ฐธ๊ณ ํ•˜์„ธ์š”.


using Google.Cloud.Spanner.Admin.Instance.V1;
using Google.Cloud.Spanner.Common.V1;
using Google.LongRunning;
using System;

public class CreateInstancePartitionSample
{
    public InstancePartition CreateInstancePartition(string projectId, string instanceId, string instancePartitionId)
    {
        // Create the InstanceAdminClient instance.
        InstanceAdminClient instanceAdminClient = InstanceAdminClient.Create();

        // Initialize request parameters.
        InstancePartition partition = new InstancePartition
        {
            DisplayName = "This is a display name.",
            NodeCount = 1,
            ConfigAsInstanceConfigName = InstanceConfigName.FromProjectInstanceConfig(projectId, "nam3"),
        };
        InstanceName instanceName = InstanceName.FromProjectInstance(projectId, instanceId);

        // Make the CreateInstancePartition request.
        Operation<InstancePartition, CreateInstancePartitionMetadata> response = instanceAdminClient.CreateInstancePartition(instanceName, partition, instancePartitionId);

        Console.WriteLine("Waiting for the operation to finish.");

        // Poll until the returned long-running operation is complete.
        Operation<InstancePartition, CreateInstancePartitionMetadata> completedResponse = response.PollUntilCompleted();

        if (completedResponse.IsFaulted)
        {
            Console.WriteLine($"Error while creating instance partition: {completedResponse.Exception}");
            throw completedResponse.Exception;
        }

        Console.WriteLine($"Instance created successfully.");

        return completedResponse.Result;
    }
}

Go

Spanner์šฉ ํด๋ผ์ด์–ธํŠธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์„ค์น˜ํ•˜๊ณ  ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์€ Spanner ํด๋ผ์ด์–ธํŠธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์ฐธ๊ณ ํ•˜์„ธ์š”.

import (
	"context"
	"fmt"
	"io"

	instance "cloud.google.com/go/spanner/admin/instance/apiv1"
	"cloud.google.com/go/spanner/admin/instance/apiv1/instancepb"
)

// Example of creating an instance partition with Go.
// projectID is the ID of the project that the new instance partition will be in.
// instanceID is the ID of the instance that the new instance partition will be in.
// instancePartitionID is the ID of the new instance partition to be created.
func createInstancePartition(w io.Writer, projectID, instanceID, instancePartitionID string) error {
	// projectID := "my-project-id"
	// instanceID := "my-instance"
	// instancePartitionID := "my-instance-partition"
	ctx := context.Background()
	instanceAdmin, err := instance.NewInstanceAdminClient(ctx)
	if err != nil {
		return err
	}
	defer instanceAdmin.Close()

	op, err := instanceAdmin.CreateInstancePartition(ctx, &instancepb.CreateInstancePartitionRequest{
		Parent:              fmt.Sprintf("projects/%s/instances/%s", projectID, instanceID),
		InstancePartitionId: instancePartitionID,
		InstancePartition: &instancepb.InstancePartition{
			Config:          fmt.Sprintf("projects/%s/instanceConfigs/%s", projectID, "nam3"),
			DisplayName:     "my-instance-partition",
			ComputeCapacity: &instancepb.InstancePartition_NodeCount{NodeCount: 1},
		},
	})
	if err != nil {
		return fmt.Errorf("could not create instance partition %s: %w", fmt.Sprintf("projects/%s/instances/%s/instancePartitions/%s", projectID, instanceID, instancePartitionID), err)
	}
	// Wait for the instance partition creation to finish.
	i, err := op.Wait(ctx)
	if err != nil {
		return fmt.Errorf("waiting for instance partition creation to finish failed: %w", err)
	}
	// The instance partition may not be ready to serve yet.
	if i.State != instancepb.InstancePartition_READY {
		fmt.Fprintf(w, "instance partition state is not READY yet. Got state %v\n", i.State)
	}
	fmt.Fprintf(w, "Created instance partition [%s]\n", instancePartitionID)
	return nil
}

Java

Spanner์šฉ ํด๋ผ์ด์–ธํŠธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์„ค์น˜ํ•˜๊ณ  ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์€ Spanner ํด๋ผ์ด์–ธํŠธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์ฐธ๊ณ ํ•˜์„ธ์š”.


import com.google.cloud.spanner.Spanner;
import com.google.cloud.spanner.SpannerOptions;
import com.google.cloud.spanner.admin.instance.v1.InstanceAdminClient;
import com.google.spanner.admin.instance.v1.CreateInstancePartitionRequest;
import com.google.spanner.admin.instance.v1.InstanceConfigName;
import com.google.spanner.admin.instance.v1.InstanceName;
import com.google.spanner.admin.instance.v1.InstancePartition;
import java.util.concurrent.ExecutionException;

class CreateInstancePartitionSample {

  static void createInstancePartition() {
    // TODO(developer): Replace these variables before running the sample.
    String projectId = "my-project";
    String instanceId = "my-instance";
    String instancePartitionId = "my-instance-partition";
    createInstancePartition(projectId, instanceId, instancePartitionId);
  }

  static void createInstancePartition(
      String projectId, String instanceId, String instancePartitionId) {
    // Set instance partition configuration.
    int nodeCount = 1;
    String displayName = "Descriptive name";

    // Create an InstancePartition object that will be used to create the instance partition.
    InstancePartition instancePartition =
        InstancePartition.newBuilder()
            .setDisplayName(displayName)
            .setNodeCount(nodeCount)
            .setConfig(InstanceConfigName.of(projectId, "nam3").toString())
            .build();

    try (Spanner spanner =
            SpannerOptions.newBuilder().setProjectId(projectId).build().getService();
        InstanceAdminClient instanceAdminClient = spanner.createInstanceAdminClient()) {

      // Wait for the createInstancePartition operation to finish.
      InstancePartition createdInstancePartition =
          instanceAdminClient
              .createInstancePartitionAsync(
                  CreateInstancePartitionRequest.newBuilder()
                      .setParent(InstanceName.of(projectId, instanceId).toString())
                      .setInstancePartitionId(instancePartitionId)
                      .setInstancePartition(instancePartition)
                      .build())
              .get();
      System.out.printf(
          "Instance partition %s was successfully created%n", createdInstancePartition.getName());
    } catch (ExecutionException e) {
      System.out.printf(
          "Error: Creating instance partition %s failed with error message %s%n",
          instancePartition.getName(), e.getMessage());
    } catch (InterruptedException e) {
      System.out.println(
          "Error: Waiting for createInstancePartition operation to finish was interrupted");
    }
  }
}

Node.js

Spanner์šฉ ํด๋ผ์ด์–ธํŠธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์„ค์น˜ํ•˜๊ณ  ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์€ Spanner ํด๋ผ์ด์–ธํŠธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์ฐธ๊ณ ํ•˜์„ธ์š”.

// Imports the Google Cloud client library
const {Spanner} = require('@google-cloud/spanner');

/**
 * TODO(developer): Uncomment the following lines before running the sample.
 */
// const projectId = 'my-project-id';
// const instanceId = 'my-instance';
// const instancePartitionId = 'my-instance-partition';

// Creates a client
const spanner = new Spanner({
  projectId: projectId,
});

// Get the instance admin client
const instanceAdminClient = spanner.getInstanceAdminClient();

// Creates a new instance partition
try {
  console.log(
    `Creating instance partition ${instanceAdminClient.instancePartitionPath(
      projectId,
      instanceId,
      instancePartitionId,
    )}.`,
  );
  const [operation] = await instanceAdminClient.createInstancePartition({
    instancePartitionId: instancePartitionId,
    parent: instanceAdminClient.instancePath(projectId, instanceId),
    instancePartition: {
      config: instanceAdminClient.instanceConfigPath(projectId, 'nam3'),
      nodeCount: 1,
      displayName: 'Test instance partition',
    },
  });

  console.log(
    `Waiting for operation on ${instancePartitionId} to complete...`,
  );
  await operation.promise();

  console.log(`Created instance partition ${instancePartitionId}.`);
} catch (err) {
  console.error('ERROR:', err);
}

PHP

Spanner์šฉ ํด๋ผ์ด์–ธํŠธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์„ค์น˜ํ•˜๊ณ  ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์€ Spanner ํด๋ผ์ด์–ธํŠธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์ฐธ๊ณ ํ•˜์„ธ์š”.

use Google\Cloud\Spanner\Admin\Instance\V1\Client\InstanceAdminClient;
use Google\Cloud\Spanner\Admin\Instance\V1\CreateInstancePartitionRequest;
use Google\Cloud\Spanner\Admin\Instance\V1\InstancePartition;

/**
 * Creates an instance partition.
 * Example:
 * ```
 * create_instance_partition($projectId, $instanceId, $instancePartitionId);
 * ```
 *
 * @param string $projectId The Google Cloud project ID.
 * @param string $instanceId The Spanner instance ID.
 * @param string $instancePartitionId The instance partition ID.
 */
function create_instance_partition(string $projectId, string $instanceId, string $instancePartitionId): void
{
    $instanceAdminClient = new InstanceAdminClient();

    $instanceName = $instanceAdminClient->instanceName($projectId, $instanceId);
    $instancePartitionName = $instanceAdminClient->instancePartitionName($projectId, $instanceId, $instancePartitionId);
    $configName = $instanceAdminClient->instanceConfigName($projectId, 'nam3');

    $instancePartition = (new InstancePartition())
        ->setConfig($configName)
        ->setDisplayName('Test instance partition.')
        ->setNodeCount(1);

    $operation = $instanceAdminClient->createInstancePartition(
        (new CreateInstancePartitionRequest())
        ->setParent($instanceName)
        ->setInstancePartitionId($instancePartitionId)
        ->setInstancePartition($instancePartition)
    );

    print('Waiting for operation to complete...' . PHP_EOL);
    $operation->pollUntilComplete();

    printf('Created instance partition %s' . PHP_EOL, $instancePartitionId);
}

Python

Spanner์šฉ ํด๋ผ์ด์–ธํŠธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์„ค์น˜ํ•˜๊ณ  ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์€ Spanner ํด๋ผ์ด์–ธํŠธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ์ฐธ๊ณ ํ•˜์„ธ์š”.

def create_instance_partition(instance_id, instance_partition_id):
    """Creates an instance partition."""
    from google.cloud.spanner_admin_instance_v1.types import spanner_instance_admin

    spanner_client = spanner.Client()
    instance_admin_api = spanner_client.instance_admin_api

    config_name = "{}/instanceConfigs/nam3".format(spanner_client.project_name)

    operation = spanner_client.instance_admin_api.create_instance_partition(
        parent=instance_admin_api.instance_path(spanner_client.project, instance_id),
        instance_partition_id=instance_partition_id,
        instance_partition=spanner_instance_admin.InstancePartition(
            config=config_name,
            display_name="Test instance partition",
            node_count=1,
        ),
    )

    print("Waiting for operation to complete...")
    operation.result(OPERATION_TIMEOUT_SECONDS)

    print("Created instance partition {}".format(instance_partition_id))

์ธ์Šคํ„ด์Šค ํŒŒํ‹ฐ์…˜ ์„ค๋ช…

gcloud

์ธ์Šคํ„ด์Šค ํŒŒํ‹ฐ์…˜์„ ์„ค๋ช…ํ•˜๋ ค๋ฉด gcloud beta spanner instance-partitions describe๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.

gcloud beta spanner instance-partitions describe PARTITION_ID \
  --instance=INSTANCE_ID

๋‹ค์Œ์„ ๋ฐ”๊ฟ‰๋‹ˆ๋‹ค.

  • INSTANCE_PARTITION_ID: ์ธ์Šคํ„ด์Šค ํŒŒํ‹ฐ์…˜์˜ ์˜๊ตฌ ์‹๋ณ„์ž์ž…๋‹ˆ๋‹ค.
  • INSTANCE_ID: ์ธ์Šคํ„ด์Šค์˜ ์˜๊ตฌ ์‹๋ณ„์ž์ž…๋‹ˆ๋‹ค.

์˜ˆ๋ฅผ ๋“ค์–ด ์ธ์Šคํ„ด์Šค ํŒŒํ‹ฐ์…˜ europe-partition์„ ์„ค๋ช…ํ•˜๋ ค๋ฉด ๋‹ค์Œ์„ ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.

  gcloud beta spanner instance-partitions describe europe-partition
    --instance=test-instance

์ธ์Šคํ„ด์Šค ํŒŒํ‹ฐ์…˜ ๋‚˜์—ด

์ฝ˜์†”

  1. Google Cloud ์ฝ˜์†”์—์„œ Spanner ํŽ˜์ด์ง€๋ฅผ ์—ฝ๋‹ˆ๋‹ค.

    Spanner๋กœ ์ด๋™

  2. ๋ชฉ๋ก์—์„œ ์ธ์Šคํ„ด์Šค๋ฅผ ์„ ํƒํ•ฉ๋‹ˆ๋‹ค.

  3. ํƒ์ƒ‰ ๋ฉ”๋‰ด์—์„œ ์ธ์Šคํ„ด์Šค ํŒŒํ‹ฐ์…˜์„ ์„ ํƒํ•ฉ๋‹ˆ๋‹ค.

    ํ•ด๋‹น ์ธ์Šคํ„ด์Šค์™€ ์—ฐ๊ฒฐ๋œ ์ธ์Šคํ„ด์Šค ํŒŒํ‹ฐ์…˜ ๋ชฉ๋ก์ด ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค.

gcloud

์ธ์Šคํ„ด์Šค ํŒŒํ‹ฐ์…˜์„ ๋‚˜์—ดํ•˜๋ ค๋ฉด gcloud beta spanner instance-partitions list๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.

gcloud beta spanner instance-partitions list --instance=INSTANCE_ID

๊ทธ๋Ÿฌ๋ฉด gcloud CLI์—์„œ Spanner ์ธ์Šคํ„ด์Šค ํŒŒํ‹ฐ์…˜ ๋ชฉ๋ก๊ณผ ํ•จ๊ป˜ ๊ฐ ์ธ์Šคํ„ด์Šค ํŒŒํ‹ฐ์…˜์˜ ID, ํ‘œ์‹œ ์ด๋ฆ„, ๊ตฌ์„ฑ, ์ปดํ“จํŒ… ์šฉ๋Ÿ‰์„ ์ถœ๋ ฅํ•ฉ๋‹ˆ๋‹ค.

์ธ์Šคํ„ด์Šค ํŒŒํ‹ฐ์…˜ ์ˆ˜์ •

๋‹ค์Œ ์„น์…˜์—์„œ๋Š” ์ธ์Šคํ„ด์Šค ํŒŒํ‹ฐ์…˜์˜ ์ปดํ“จํŒ… ์šฉ๋Ÿ‰์„ ๋ณ€๊ฒฝํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์„ค๋ช…ํ•ฉ๋‹ˆ๋‹ค. ์ธ์Šคํ„ด์Šค ํŒŒํ‹ฐ์…˜ ID, ์ด๋ฆ„ ๋˜๋Š” ๊ตฌ์„ฑ์„ ๋ณ€๊ฒฝํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.

์ปดํ“จํŒ… ์šฉ๋Ÿ‰ ๋ณ€๊ฒฝ

CPU ์‚ฌ์šฉ๋ฅ  ๋ฐ ์Šคํ† ๋ฆฌ์ง€ ์‚ฌ์šฉ๋ฅ ์„ ๊ถŒ์žฅ ์ตœ๋Œ“๊ฐ’ ์•„๋ž˜๋กœ ์œ ์ง€ํ•  ์ˆ˜ ์žˆ๋„๋ก ์ปดํ“จํŒ… ์šฉ๋Ÿ‰์„ ์ถฉ๋ถ„ํ•˜๊ฒŒ ํ”„๋กœ๋น„์ €๋‹ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์ž์„ธํ•œ ๋‚ด์šฉ์€ Spanner์˜ ํ• ๋‹น๋Ÿ‰ ๋ฐ ํ•œ๋„๋ฅผ ์ฐธ์กฐํ•˜์„ธ์š”.

์ธ์Šคํ„ด์Šค ํŒŒํ‹ฐ์…˜์˜ ์ปดํ“จํŒ… ์šฉ๋Ÿ‰์„ ๋Š˜๋ฆฌ๋ ค๋ฉดGoogle Cloud ํ”„๋กœ์ ํŠธ์— ์ปดํ“จํŒ… ์šฉ๋Ÿ‰์„ ์ถ”๊ฐ€ํ•  ์ˆ˜ ์žˆ์„ ๋งŒํผ ์ถฉ๋ถ„ํ•œ ํ• ๋‹น๋Ÿ‰์ด ์žˆ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์ฆ๊ฐ€ ์š”์ฒญ์„ ์™„๋ฃŒํ•˜๋Š” ๋ฐ ๊ฑธ๋ฆฌ๋Š” ์‹œ๊ฐ„์€ ์š”์ฒญ ํฌ๊ธฐ์— ๋”ฐ๋ผ ๋‹ฌ๋ผ์ง‘๋‹ˆ๋‹ค. ๋Œ€๋ถ€๋ถ„์˜ ๊ฒฝ์šฐ ๋ช‡ ๋ถ„ ๋‚ด์— ์š”์ฒญ์ด ์™„๋ฃŒ๋ฉ๋‹ˆ๋‹ค. ๋“œ๋ฌธ ๊ฒฝ์šฐ์ง€๋งŒ ์ˆ˜์ง ํ™•์žฅ์„ ์™„๋ฃŒํ•˜๋Š” ๋ฐ ์ตœ๋Œ€ 1์‹œ๊ฐ„๊นŒ์ง€ ๊ฑธ๋ฆด ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์ฝ˜์†”

  1. Google Cloud ์ฝ˜์†”์—์„œ Spanner ํŽ˜์ด์ง€๋ฅผ ์—ฝ๋‹ˆ๋‹ค.

    Spanner๋กœ ์ด๋™

  2. ๋ชฉ๋ก์—์„œ ์ธ์Šคํ„ด์Šค๋ฅผ ์„ ํƒํ•ฉ๋‹ˆ๋‹ค.

  3. ํƒ์ƒ‰ ๋ฉ”๋‰ด์—์„œ ์ธ์Šคํ„ด์Šค ํŒŒํ‹ฐ์…˜์„ ์„ ํƒํ•ฉ๋‹ˆ๋‹ค.

  4. ์ธ์Šคํ„ด์Šค ํŒŒํ‹ฐ์…˜ ๋ชฉ๋ก์˜ ์ž‘์—… ์—ด์—์„œ ์ž‘์—… ๋”๋ณด๊ธฐ๋ฅผ ํด๋ฆญํ•˜๊ณ  ์ˆ˜์ •์„ ์„ ํƒํ•ฉ๋‹ˆ๋‹ค.

  5. ์ธก์ • ๋‹จ์œ„(์ฒ˜๋ฆฌ ๋‹จ์œ„ ๋˜๋Š” ๋…ธ๋“œ)๋ฅผ ์„ ํƒํ•œ ํ›„ ์ˆ˜๋Ÿ‰์„ ์ž…๋ ฅํ•˜์—ฌ ์ปดํ“จํŒ… ์šฉ๋Ÿ‰์„ ๋ณ€๊ฒฝํ•ฉ๋‹ˆ๋‹ค. ์ฒ˜๋ฆฌ ๋‹จ์œ„๋ฅผ ์‚ฌ์šฉํ•  ๊ฒฝ์šฐ ์ˆ˜๋Ÿ‰์„ 1,000์˜ ๋ฐฐ์ˆ˜(1,000, 2,000, 3,000 ๋“ฑ)๋กœ ์ž…๋ ฅํ•ฉ๋‹ˆ๋‹ค. ๋…ธ๋“œ 1๊ฐœ๋Š” ์ฒ˜๋ฆฌ ๋‹จ์œ„ 1,000๊ฐœ์™€ ๊ฐ™์Šต๋‹ˆ๋‹ค.

    ์ธ์Šคํ„ด์Šค ํŒŒํ‹ฐ์…˜์— ๋…ธ๋“œ๊ฐ€ ์ตœ์†Œ ํ•˜๋‚˜(์ฒ˜๋ฆฌ ๋‹จ์œ„ 1,000๊ฐœ) ์ด์ƒ ์žˆ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

  6. ์ €์žฅ์„ ํด๋ฆญํ•ฉ๋‹ˆ๋‹ค.

    ํ• ๋‹น๋Ÿ‰์ด ๋ถ€์กฑํ•˜์—ฌ ์ปดํ“จํŒ… ์šฉ๋Ÿ‰์„ ์ถ”๊ฐ€ํ•  ์ˆ˜ ์—†๋‹ค๋Š” ๋Œ€ํ™”์ƒ์ž๊ฐ€ ํ‘œ์‹œ๋˜๋ฉด ์•ˆ๋‚ด์— ๋”ฐ๋ผ ํ• ๋‹น๋Ÿ‰ ์ƒํ–ฅ์„ ์š”์ฒญํ•ฉ๋‹ˆ๋‹ค.

gcloud

์ธ์Šคํ„ด์Šค ํŒŒํ‹ฐ์…˜์˜ ์ปดํ“จํŒ… ์šฉ๋Ÿ‰์„ ๋ณ€๊ฒฝํ•˜๋ ค๋ฉด gcloud beta spanner instance-partitions update๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ์ด ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉํ•  ๋•Œ ์ปดํ“จํŒ… ์šฉ๋Ÿ‰์„ ์ˆซ์ž, ๋…ธ๋“œ ๋˜๋Š” ์ฒ˜๋ฆฌ ๋‹จ์œ„๋กœ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค.

gcloud beta spanner instance-partitions update INSTANCE_PARTITION_ID \
  --instance=INSTANCE_ID \
  [--nodes=NODE_COUNT | --processing-units=PROCESSING_UNIT_COUNT]
  [--async]

๋‹ค์Œ์„ ๋ฐ”๊ฟ‰๋‹ˆ๋‹ค.

  • INSTANCE_PARTITION_ID: ์ธ์Šคํ„ด์Šค ํŒŒํ‹ฐ์…˜์˜ ์˜๊ตฌ ์‹๋ณ„์ž์ž…๋‹ˆ๋‹ค.
  • INSTANCE_ID: ์ธ์Šคํ„ด์Šค์˜ ์˜๊ตฌ ์‹๋ณ„์ž์ž…๋‹ˆ๋‹ค.
  • NODE_COUNT: ์ธ์Šคํ„ด์Šค ํŒŒํ‹ฐ์…˜์˜ ์ƒˆ๋กœ์šด ์ปดํ“จํŒ… ์šฉ๋Ÿ‰์œผ๋กœ, ๋…ธ๋“œ ์ˆ˜๋กœ ํ‘œํ˜„๋ฉ๋‹ˆ๋‹ค. ๋…ธ๋“œ 1๊ฐœ๋Š” ์ฒ˜๋ฆฌ ๋‹จ์œ„ 1,000๊ฐœ์™€ ๊ฐ™์Šต๋‹ˆ๋‹ค.
  • PROCESSING_UNIT_COUNT: ์ธ์Šคํ„ด์Šค ํŒŒํ‹ฐ์…˜์˜ ์ƒˆ๋กœ์šด ์ปดํ“จํŒ… ์šฉ๋Ÿ‰์œผ๋กœ, ์ฒ˜๋ฆฌ ๋‹จ์œ„ ์ˆ˜๋กœ ํ‘œํ˜„๋ฉ๋‹ˆ๋‹ค. ์ธ์Šคํ„ด์Šค ํŒŒํ‹ฐ์…˜์— ์ฒ˜๋ฆฌ ๋‹จ์œ„๊ฐ€ ์ตœ์†Œ 1,000๊ฐœ ์ด์ƒ ์žˆ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์ˆ˜๋Ÿ‰์„ 1,000์˜ ๋ฐฐ์ˆ˜(1,000, 2,000, 3,000 ๋“ฑ)๋กœ ์ž…๋ ฅํ•ฉ๋‹ˆ๋‹ค.

์„ ํƒ์  ํ”Œ๋ž˜๊ทธ:

  • --async: ์ง„ํ–‰ ์ค‘์ธ ์ž‘์—…์ด ์™„๋ฃŒ๋  ๋•Œ๊นŒ์ง€ ๊ธฐ๋‹ค๋ฆฌ์ง€ ์•Š๊ณ  ์š”์ฒญ์ด ์ฆ‰์‹œ ๋ฐ˜ํ™˜๋˜๋„๋ก ํ•˜๋ ค๋ฉด ์ด ํ”Œ๋ž˜๊ทธ๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.

gcloud spanner operations describe๋ฅผ ์‹คํ–‰ํ•˜์—ฌ ์š”์ฒญ ์ƒํƒœ๋ฅผ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์ธ์Šคํ„ด์Šค ํŒŒํ‹ฐ์…˜ ์‚ญ์ œ

๋ฐฐ์น˜ ๋˜๋Š” ๋ฐ์ดํ„ฐ์™€ ์—ฐ๊ฒฐ๋œ ์ƒํƒœ์—์„œ๋Š” ์ธ์Šคํ„ด์Šค ํŒŒํ‹ฐ์…˜์„ ์‚ญ์ œํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค. ์ธ์Šคํ„ด์Šค ํŒŒํ‹ฐ์…˜์„ ์‚ญ์ œํ•˜๋ ค๋ฉด ๋จผ์ € ์ธ์Šคํ„ด์Šค ํŒŒํ‹ฐ์…˜์— ์žˆ๋Š” ๋ฐ์ดํ„ฐ๋ฅผ ์ด๋™ํ•˜๊ฑฐ๋‚˜ ์ธ์Šคํ„ด์Šค ํŒŒํ‹ฐ์…˜์„ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฐ์น˜ ํ…Œ์ด๋ธ”์„ ์‚ญ์ œํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

์ฝ˜์†”

  1. Google Cloud ์ฝ˜์†”์—์„œ Spanner ํŽ˜์ด์ง€๋ฅผ ์—ฝ๋‹ˆ๋‹ค.

    Spanner๋กœ ์ด๋™

  2. ๋ชฉ๋ก์—์„œ ์ธ์Šคํ„ด์Šค๋ฅผ ์„ ํƒํ•ฉ๋‹ˆ๋‹ค.

  3. ํƒ์ƒ‰ ๋ฉ”๋‰ด์—์„œ ์ธ์Šคํ„ด์Šค ํŒŒํ‹ฐ์…˜์„ ์„ ํƒํ•ฉ๋‹ˆ๋‹ค.

  4. ์ธ์Šคํ„ด์Šค ํŒŒํ‹ฐ์…˜ ๋ชฉ๋ก์˜ ์ž‘์—… ์—ด์—์„œ ์ž‘์—… ๋”๋ณด๊ธฐ๋ฅผ ํด๋ฆญํ•˜๊ณ  ์‚ญ์ œ๋ฅผ ์„ ํƒํ•ฉ๋‹ˆ๋‹ค.

  5. ์•ˆ๋‚ด์— ๋”ฐ๋ผ ์ธ์Šคํ„ด์Šค ํŒŒํ‹ฐ์…˜์„ ์‚ญ์ œํ•  ๊ฒƒ์ธ์ง€ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค.

  6. ์‚ญ์ œ๋ฅผ ํด๋ฆญํ•ฉ๋‹ˆ๋‹ค.

gcloud

gcloud beta spanner instance-partitions delete ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.

gcloud beta spanner instance-partitions delete INSTANCE_PARTITION_ID
  --instance=INSTANCE_ID

๋‹ค์Œ ๋‹จ๊ณ„