Creating and managing Redis instances

This page describes how to use the Google Cloud Console and the Cloud SDK to create and manage Memorystore for Redis instances.

To connect a client to a Memorystore for Redis instance, the client and the instance must be located in the same region.

For a list of the permissions you need to create and manage Redis instances, see Access control and permissions.

Creating a Redis instance on a VPC network

To create a new instance:

Console

  1. Go to the Memorystore for Redis page in the Cloud Console.

    Memorystore for Redis

  2. Click Create Instance.

    Memorystore UI

  3. On the Create a Redis instance page, select your desired configurations for your new instance.

    • Give your instance an Instance ID and, if desired, a Display name. The Instance ID must use only lowercase letters, numbers and hyphens. It must also start with a letter and be unique in its region.
      • For example: my-instance-1.
    • Choose Basic or Standard tier. For more information about tiers, see Redis Tier Capabilities.
    • Choose a Region and a Zone for your instance. To access your Redis instance using a regional resource, such as a Compute Engine VM instance, make sure to create them both in the same region.
    • Select Redis Version 5.0 (recommended).
    • Under Capacity, enter a value between 1 and 300 GBs.
    • If you want to enable Redis AUTH select Enable AUTH.
    • Under Authorized network, select the default network, or one of your available VPC networks.
    • Optional. To set up private services access connection click the Advanced network options expander.

      • If you see the Private service connection required panel, use the panel to establish a private services access connection.
    • To add Redis configurations, click the Add Configuration button, choose a configuration from the Configuration dropdown and enter your desired value. For more information about available configurations, see Configuring Redis Instances.

  4. Click the Create button.

gcloud

Enter the following command, replacing VARIABLES with appropriate values:

gcloud redis instances create INSTANCE_ID --size=SIZE --region=REGION_ID

Where:

  • INSTANCE_ID is the ID assigned to the instance.
  • SIZE is the size of the instance, in gibibytes (GiB).
  • REGION_ID is the region ID.

For example:

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

Instance creation requirements

Instance IDs must begin with a lowercase letter and may only include lowercase letters, hyphens, and numbers, with no spaces.

To access your Redis instance using a regional resource, such as a Compute Engine VM instance, make sure to create them both in the same region.

Optional flags

Redis version

To choose one of the available OSS Redis versions for Memorystore for Redis, use the --redis-version flag with one of the following values:

  • redis_5_0 (recommended)
  • redis_4_0 (default)
  • redis_3_2

For example:

gcloud redis instances create myinstance --size=5 --region=us-central1 \
    --zone=us-central1-a --redis-version=redis_5_0
Networking

You can create Redis instances using one of two connection modes: --connect-mode=private-service-access or --connect-mode=direct-peering. We recommend that you use the private service access connection mode. For more details, see Networking.

If you choose to use the direct peering mode to create your instance, you can choose a custom IP address range using the optional --reserved-ip-range gcloud parameter. Here is an example of an acceptable value for this parameter:

--reserved-ip-range=10.0.0.0/29

This parameter only works with the direct peering connection mode. The range must be unique and non-overlapping with existing ranges in the network. If you leave the reserved range parameter unspecified, the service automatically picks an available range.

Redis AUTHPREVIEW

To enable AUTH, use the following flag:

--enable-auth

Remember to use the gcloud beta redis command to access this beta feature.

Standard tier

To create a Standard Tier instance, add --tier=STANDARD to the create command. The following command creates a Standard Tier instance:

gcloud redis instances create INSTANCE_ID --size=SIZE --zone=ZONE --alternative-zone=ALTERNATIVE_ZONE --tier=STANDARD 

Where:

  • ZONE is the location where the primary node is provisioned.
  • ALTERNATIVE_ZONE is the location where the replica node is provisioned.

For example:

gcloud redis instances create myinstance --size=5 --region=us-central1 --tier=standard 

For more information about using gcloud with Memorystore for Redis, see the Cloud SDK reference page.

Now your instance is created.

Creating a Redis instance on a Shared VPC network from a service project

This section explains how to create a Redis instance in a service project using the Shared VPC network from the host project. This allows you to connect to your Redis instance from resources in different projects connected to the same Shared VPC network. For more details, see Shared VPC overview.

Console

  1. Verify or establish a private services access connection for the network in the host project that you use to create your Redis instance.

  2. Make sure the Service Networking API is enabled for both the host project and the service project.

  3. Follow the steps from Creating a Redis instance on a VPC network, but make the following modifications:

    1. Complete the optional step for setting up a private services access connection.

    2. Use the Authorized VPC Network dropdown to select the Shared VPC network from the host project. It is listed under Shared VPC Networks.

gcloud

  1. Make sure the Service Networking API is enabled for both the host project and the service project.

  2. Create a Redis instance in a service project using the Shared VPC from the host project:

    gcloud redis instances create INSTANCE_ID --size=SIZE --region=REGION_ID --project=SERVICE_PROJECT_ID \
      --network=projects/HOST_PROJECT_ID/global/networks/HOST_NETWORK_NAME \
      --connect-mode=private-service-access
    

    Where:

    • INSTANCE_ID is the ID assigned to the instance.
    • SIZE is the size of the instance, in gibibytes (GiB).
    • REGION_ID is the region ID.
    • SERVICE_PROJECT_ID is the project ID for your service project.
    • HOST_PROJECT_ID is the project ID for your host project.
    • HOST_NETWORK_NAME is the name of your host project network.

    For example:

    gcloud redis instances create myinstance --size=5 --region=us-central1 --project=my-service-project \
      --network=projects/my-host-project/global/networks/my-host-shared-vpc \
      --connect-mode=private-service-access
    

Creating a Redis instance that uses a centralized IP address range

Centralized IP address range management is provided by using private services access. Private services access designates one IP address range that is used by multiple Google Cloud services. Using private services access removes the need to manage a different IP address range for each service.

Console

  1. Verify or establish a private service access connection for the network you use to create the Redis instance.

  2. Follow the steps from Creating a Redis instance on a VPC network, but make sure to complete the optional section on establishing a private services access connection.

gcloud

  1. Verify or establish a private service access connection for the network you use to create the Redis instance.

  2. Create a Redis instance using the network on which you established a private services access connection:

    gcloud redis instances create INSTANCE_ID --size=SIZE --region=REGION_ID --project=PROJECT_ID \
      --network=projects/PROJECT_ID/global/networks/NETWORK_NAME \
      --connect-mode=private-service-access
    

    Where:

    • INSTANCE_ID is the ID assigned to the instance.
    • SIZE is the size of the instance, in gibibytes (GiB).
    • REGION_ID is the region ID.
    • PROJECT_ID is the project ID.
    • NETWORK_NAME is the name of the network with which to create the Redis instance.

    For example:

    gcloud redis instances create myinstance --size=5 --region=us-central1 --project=my-project \
      --network=projects/my-project/global/networks/my-network \
      --connect-mode=private-service-access
    

Viewing instance information

To view an instance's information:

Console

  1. Go to the Memorystore for Redis page in the Google Cloud Console.

    Memorystore for Redis

  2. Click the Instance ID of the instance to view its information.

Gcloud

To view the list of all instances in a region, enter the following command, replacing VARIABLES with appropriate values:

gcloud redis instances list --region=REGION_ID

To view the details of an instance, enter the following command:

gcloud redis instances describe INSTANCE_ID --region=REGION_ID

Editing instances

To edit an instance:

Console

  1. Go to the Memorystore for Redis page in the Google Cloud Console.

    Memorystore for Redis

  2. Click the Instance ID of the instance you'd like to edit.

  3. Click the Edit button

    1. From the Edit Redis instance page you can change an instance's:
      • Display name
      • Capacity
      • Configurations
  4. Click the Save button.

While your updates are being made, a spinning circle appears next to your instance on the Memorystore for Redis home page. When the updates are finished, the circle becomes a green checkmark.

Gcloud

You can update the following properties after creating an instance:

  • Display name
  • Redis configuration
  • Labels
  • Size (For more information on scaling, see Scaling Instances.)

For example, enter the following command to update the display name of an instance, replacing VARIABLES with appropriate values:

gcloud redis instances update INSTANCE_ID --region=REGION_ID --display-name=NEW_DISPLAY_NAME

For more details on how to set configuration parameters, see Configuring Redis Instances.

Deleting instances

To delete an instance:

Console

  1. Go to the Memorystore for Redis page in the Google Cloud Console.

    Memorystore for Redis

  2. To delete an instance, click its Instance ID.

  3. Click the Delete button.

  4. To confirm deletion, enter the instance's ID.

  5. Click delete again.

Gcloud

To delete an instance, enter the following command, replacing VARIABLES with appropriate values:

gcloud redis instances delete INSTANCE_ID --region=REGION_ID

After the instance is deleted, it's removed from the list of instances on the Memorystore homepage.