Google Cloud コンソールを使用して Memorystore for Redis インスタンスを作成する

Memorystore for Redis インスタンスを作成して接続し、削除する方法を学習します。


このタスクを Google Cloud コンソールで直接行う際の順を追ったガイダンスについては、「ガイドを表示」をクリックしてください。

ガイドを表示


始める前に

  1. Google Cloud アカウントにログインします。 Google Cloudを初めて使用する場合は、 アカウントを作成して、実際のシナリオでの Google プロダクトのパフォーマンスを評価してください。新規のお客様には、ワークロードの実行、テスト、デプロイができる無料クレジット $300 分を差し上げます。
  2. In the Google Cloud console, on the project selector page, select or create 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 role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  3. If you're using an existing project for this guide, verify that you have the permissions required to complete this guide. If you created a new project, then you already have the required permissions.

  4. Verify that billing is enabled for your Google Cloud project.

  5. Enable the Memorystore for Redis API.

    Roles required to enable APIs

    To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains the serviceusage.services.enable permission. Learn how to grant roles.

    Enable the API

  6. In the Google Cloud console, on the project selector page, select or create 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 role (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  7. If you're using an existing project for this guide, verify that you have the permissions required to complete this guide. If you created a new project, then you already have the required permissions.

  8. Verify that billing is enabled for your Google Cloud project.

  9. Enable the Memorystore for Redis API.

    Roles required to enable APIs

    To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains the serviceusage.services.enable permission. Learn how to grant roles.

    Enable the API

必要なロール

Memorystore for Redis インスタンスの作成に必要な権限を取得するには、プロジェクトに対する次の IAM ロールを付与するよう管理者に依頼してください。

ロールの付与については、プロジェクト、フォルダ、組織へのアクセス権の管理をご覧ください。

必要な権限は、カスタムロールや他の事前定義ロールから取得することもできます。

Memorystore for Redis インスタンスを作成する

このセクションでは、us-central1 リージョンに配置され、ベーシック ティアの 2 GB の Memorystore for Redis インスタンスを作成します。階層の詳細については、Redis の階層の機能をご覧ください。

  1. Google Cloud コンソールで、[Memorystore for Redis] ページに移動します。

    Memorystore for Redis

  2. [インスタンスを作成] をクリックします。

  3. [Redis インスタンスの作成] ページで、作成するインスタンスに対して次の構成を行います。

    • [インスタンス ID] フィールドに「my-instance-1」と入力します。
    • [Deployment name] フィールドに「My Quickstart Instance」と入力します。
    • [階層の選択] セクションで、[基本] を選択します。この階層では、レプリカノードを使用してデータをバックアップする標準階層とは異なり、スタンドアロンの Redis ノードを指定します。
    • [容量] フィールドに「5」と入力します。これにより、インスタンスの容量が 5 GB に設定されます。
    • [リージョン] メニューから、[us-central1(アイオワ)] を選択します。
    • [ネットワーク] メニューから [デフォルト] を選択します。
    • [構成] ノードを開き、[バージョン] メニューから
      7.2(推奨)を選択します。
  4. [インスタンスを作成] をクリックします。

  5. インスタンスを作成したら、次の手順でインスタンスの IP address を取得します。

    1. Google Cloud コンソールで、[Memorystore for Redis] ページに移動します。
      Memorystore for Redis
    2. インスタンスの ID(my-instance-1)をクリックします。
    3. [接続] セクションで、インスタンスのプライマリ エンドポイントポート番号 6379 をメモします。インスタンスに接続するには、エンドポイントとポート番号が必要です。

Compute Engine VM から Memorystore for Redis インスタンスに接続する

Memorystore for Redis インスタンスには、インスタンスの承認済みネットワークを使用する任意の Compute Engine VM からサポートされている RFC 1918 IP アドレス]をクリックします。

  1. インスタンスと同じ承認済みネットワークを使用する Compute Engine VM がない場合は、作成して SSH を使用して VM に接続します。これを行うには、Compute Engine で Linux VM インスタンスを作成するの手順に沿って操作します。

  2. apt-get を使用して telnet をインストールします。

    sudo apt-get install telnet
    
  3. ターミナルから、インスタンスの IP アドレスに telnet で接続します。VARIABLES は適切な値に置き換えます。

    telnet INSTANCE_IP_ADDRESS 6379
    

    インスタンスに接続できる場合、コマンドは次の結果を返します。

    Trying INSTANCE_IP_ADDRESS…
    Connected to INSTANCE_IP_ADDRESS
    
  4. telnet セッションで、次のようにいくつかの Redis コマンドを入力します。

    次のように入力します。

    PING
    

    結果:

    PONG
    

    入力

    SET HELLO WORLD
    

    結果:

    +OK
    

    次のように入力します。

    GET HELLO
    

    結果:

    $5
    WORLD
    

クリーンアップ

このページで使用したリソースについて、 Google Cloud アカウントに課金されないようにするには、次の手順を実施します。

  1. Google Cloud コンソールで、[Memorystore for Redis] ページに移動します。
    Memorystore for Redis
  2. 削除するインスタンスの ID をクリックします。
  3. [削除] をクリックします。
  4. 入力を求められたら、インスタンス ID を入力します。
  5. [削除] をクリックします。
  6. (省略可)このクイックスタート用に Compute Engine VM を作成した場合は、それを削除します。

次のステップ