インスタンス パーティションの作成と管理

このページでは、Spanner のインスタンス パーティションを作成して管理する方法について説明します。

インスタンス パーティションを作成する

コンソール

  1. Google Cloud コンソールで、[Spanner] ページを開きます。

    Spanner に移動

  2. インスタンス パーティションを追加するインスタンスを選択します。

  3. ナビゲーション メニューで [インスタンス パーティション] を選択します。

  4. [インスタンス パーティションを作成する] をクリックします。

  5. インスタンス パーティションを永続的に識別するためのパーティション ID を入力します。インスタンス パーティション ID は、Google Cloud プロジェクト内で一意にする必要があります。インスタンス パーティション ID を後で変更することはできません。

  6. [構成を選択] セクションで、[リージョン] または [マルチリージョン] を選択します。リージョン間で仕様を比較する場合は、[リージョン構成の比較] をクリックします。

  7. プルダウン メニューから構成を選択します。

  8. [コンピューティング容量を割り当てる] セクションの [単位] で、次のいずれかをクリックします。

    • 小規模なインスタンス パーティションの場合: 処理ユニット
    • 大規模なインスタンスの場合: ノード。1 ノードは 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。インスタンス パーティション ID を後で変更することはできません。
  • INSTANCE_PARTITION_CONFIG: インスタンス パーティション構成の永続的な ID。インスタンス パーティションの地理的位置を定義し、データの保存場所に影響します。
  • INSTANCE_PARTITION_DESCRIPTION: Google Cloud コンソールに表示されるインスタンス パーティションの名前。インスタンス パーティション名は、 Google Cloud プロジェクト内で一意である必要があります。
  • INSTANCE_ID: このインスタンス パーティションが存在する Spanner インスタンスの永続的な ID。
  • 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)