Create a Memorystore for Redis instance by using the Google Cloud console

Learn how to create a Memorystore for Redis instance, connect to it, and then delete it.


To follow step-by-step guidance for this task directly in the Google Cloud console, click Guide me:

Guide me


Before you begin

  1. Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
  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

Required roles

To get the permissions that you need to create a Memorystore for Redis instance, ask your administrator to grant you the following IAM roles on the project:

For more information about granting roles, see Manage access to projects, folders, and organizations.

You might also be able to get the required permissions through custom roles or other predefined roles.

Create a Memorystore for Redis instance

In this section, you create a 2-GB Memorystore for Redis instance that's located in the us-central1 region and is in the Basic tier. For more information about tiers, see Redis tier capabilities.

  1. In the Google Cloud console, go to the Memorystore for Redis page.

    Memorystore for Redis

  2. Click Create instance.

  3. In the Create a Redis instance page, make the following configurations for the instance that you're creating:

    • In the Instance ID field, enter my-instance-1.
    • In the Display name field, enter My Quickstart Instance.
    • In the Tier selection section, select Basic. This tier designates a standalone Redis node, as opposed to the Standard tier, which uses a replica node to backup your data.
    • In the Capacity field, enter 5. This sets the capacity of your instance to 5 GB.
    • From the Region menu, select us-central1 (Iowa).
    • From the Network menu, select default.
    • Expand the Configuration node, and then from the Version menu, select
      7.2 (Recommended).
  4. Click Create instance.

  5. After you create the instance, obtain your instance's IP address by following these steps:

    1. In the Google Cloud console, go to the Memorystore for Redis page.
      Memorystore for Redis
    2. Click the ID of your instance: my-instance-1.
    3. In the Connections section, make a note of your instance's Primary Endpoint and Port number of 6379. You need the endpoint and port number to connect to the instance.

Connect to the Memorystore for Redis instance from a Compute Engine VM

You can connect to the Memorystore for Redis instance from any Compute Engine VM that uses the instance's authorized network with a supported RFC 1918 IP address.

  1. If you don't have a Compute Engine VM that uses that same authorized network as your instance, then create one and connect to the VM by using SSH. To do this, follow the steps in Create a Linux VM instance in Compute Engine.

  2. Use apt-get to install telnet:

    sudo apt-get install telnet
    
  3. From the terminal, telnet to the IP address of the instance. Replace VARIABLES with appropriate values.

    telnet INSTANCE_IP_ADDRESS 6379
    

    If you can connect to the instance, then the command returns this result:

    Trying INSTANCE_IP_ADDRESS…
    Connected to INSTANCE_IP_ADDRESS
    
  4. In the telnet session, enter some Redis commands:

    Enter:

    PING
    

    Result:

    PONG
    

    Enter

    SET HELLO WORLD
    

    Result:

    +OK
    

    Enter:

    GET HELLO
    

    Result:

    $5
    WORLD
    

Clean up

To avoid incurring charges to your Google Cloud account for the resources used on this page, follow these steps.

  1. In the Google Cloud console, go to the Memorystore for Redis page.
    Memorystore for Redis
  2. Click the ID of the instance that you want to delete.
  3. Click Delete.
  4. In the prompt that appears, enter the instance ID.
  5. Click Delete.
  6. Optional. If you created a Compute Engine VM for this quickstart, then delete it.

What's next