Quickstart Using the Cloud SDK

This page describes how to create a new Cloud Memorystore for Redis instance, connect to it, and then delete it.

Before you begin

  1. Sign in to your Google Account.

    If you don't already have one, sign up for a new account.

  2. Select or create a GCP project.

    Go to the Manage resources page

  3. Make sure that billing is enabled for your project.

    Learn how to enable billing

  4. If you haven't already, install the Cloud SDK.

    When prompted, choose the project that you selected or created above.

  5. If you already have the Cloud SDK installed, update it.

    gcloud components update

Creating a Cloud Memorystore for Redis instance

To create a Cloud Memorystore for Redis instance:

  1. Open a terminal window.
  2. Set the project you'd like to create your instance in as the default project in gcloud by entering the following command:

    gcloud config set core/project PROJECT_ID

  3. Enter the following command to create a 2 GiB Basic Tier Redis instance in the us-central1 region:

    gcloud redis instances create myinstance --size=2 --region=us-central1

  4. After the instance is created, enter the describe command to get the IP address and port of the instance:

    gcloud redis instances describe myinstance --region=us-central1

    If successful, gcloud returns the following:

    authorizedNetwork: projects/my-project/global/networks/default
    createTime: '2018-04-09T21:47:56.824081Z'
    currentLocationId: us-central1-a
    host: 10.0.0.27
    locationId: us-central1-a
    memorySizeGb: 2
    name: projects/my-project/locations/us-central1/instances/myinstance
    networkThroughputGbps: 2
    port: 6379
    redisVersion: REDIS_3_2
    reservedIpRange: 10.0.0.24/29
    state: READY
    tier: BASIC

    You'll use the host and port values to connect to the instance.

Connecting to the Redis instance from a Compute Engine VM

You can connect to the Redis instance from any Compute Engine VM instance located within the same project, region and network as the Redis instance.

  1. Follow the instructions at Quickstart Using a Linux VM to create and connect to a Compute Engine VM instance. Make sure that you create your Compute Engine VM instance in the same region as your Redis instance. If you used a Debian 8 image to create your VM instance as described in the quickstart, install telnet using apt-get:

    sudo apt-get install telnet
    
  2. From the terminal, telnet to the IP address of the Redis instance, substituting your own instance's IP address and port number.

    telnet 10.0.0.27 6379
    Trying 10.0.0.27…
    Connected to 10.0.0.27
    
  3. In the telnet session, enter some Redis commands:

    PING
    +PONG
    SET HELLO WORLD
    +OK
    GET HELLO
    $5
    WORLD
    

You can also use the Redis client to issue commands to the Redis instance. For more information on how to use the Redis client, see the Redis Quick Start Guide.

Clean up

  1. To avoid incurring charges to your Google Cloud Platform account for the resources used in this quickstart, delete the instance by entering the following command:

    gcloud redis instances delete myinstance --region=us-central1

  2. Enter y to confirm the instance to delete:

    The following instance(s) will be deleted and any associated data will be lost.
            - [myinstance] in [us-central1]
            Do you want to continue (Y/n)? y
            Deleting instance [myinstance].../
    If successful, gcloud returns the following response:
    Deleted Redis instance [projects/myproject/locations/us-central1/instances/myinstance].

What's next

Was this page helpful? Let us know how we did:

Send feedback about...

Google Cloud Memorystore for Redis