Create and manage Redis instances

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

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 Google 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.
    • Select Redis Version 7.0 (recommended).
    • Under Capacity, enter a value between 1 and 300 GBs.
    • If you want to enable Redis AUTH select Enable AUTH.
    • If you want to enable in-transit encryption select Enable in-transit encryption.
    • 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.

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_7_2
  • redis_7_0 (Default)
  • redis_6_X
  • redis_5_0
  • redis_4_0
  • redis_3_2

For example:

gcloud redis instances create myinstance --size=5 --region=us-central1 \
    --zone=us-central1-a --redis-version=redis_6_X
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.

For instructions on using the --reserved-ip-range flag to specify a IP address range, see Creating a Redis instance with a specific IP address range.

Redis AUTH

To enable AUTH, use the following flag:

--enable-auth

In-transit encryption

To enable in-transit encryption, use the following flag:

--transit-encryption-mode=SERVER_AUTHENTICATION

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 

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 Google Cloud CLI 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
    

Creating a Redis instance with a specific IP address range

The following instructions explain how to create a Redis instance from within an IP address range of your choosing.

Custom ranges with direct peering

If your project uses the DIRECT_PEERING connection mode, use the following command to designate a specific IP address range when creating an instance:

gcloud redis instances create INSTANCE_ID --region=REGION --size=SIZE --connect-mode=DIRECT_PEERING --network=VPC_NETWORK_NAME --reserved-ip-range=RESERVED_RANGE

Where:

  • VPC_NETWORK_NAME is the name of the network used to create the instance.
  • RESERVED_RANGE is your desired custom range. For example, 10.0.0.0/29. The minimum required block size is /29 for instances without read replicas and /28 for instances with read replicas. You can't use this flag to designate multiple ranges with this connection mode.

For example:

gcloud redis instances create myinstance --region=us-central1 --size=1 --connect-mode=DIRECT_PEERING --network=default --reserved-ip-range=10.0.0.0/24

Custom ranges with private services access

If you only have one IP address range allocated for your private services access connection, that range is used by default for Memorystore instance creation.

If you have multiple address ranges allocated for private services access, you can select which one to use with the following gcloud command:

gcloud redis instances create INSTANCE_ID --region=REGION --size=SIZE --connect-mode=PRIVATE_SERVICE_ACCESS --network=VPC_NETWORK_NAME --reserved-ip-range=RESERVED_RANGE_NAME

Where:

  • VPC_NETWORK_NAME is the name of network used to create the instance.
  • RESERVED_RANGE_NAME is the name of the allocated IP address range(s). You can use this flag to specify the names of multiple range allocations with this connection mode. To do so, provide the names separated by a comma.

For example:

gcloud redis instances create myinstance --region=us-central1 --size=1 --connect-mode=PRIVATE_SERVICE_ACCESS --network=default --reserved-ip-range=my-reserved-range-1,my-reserved-range-2

Creating a Redis instance with read replicas

For instructions on how to create a Redis instance with read replicas, see Creating a Redis instance with read replicas.

Creating a Redis instance that uses customer managed encryption keys

For instructions on how to create a Redis instance that uses customer managed encryption keys (CMEK), see Creating a Memorystore for Redis instance that uses CMEK.

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.

What's next