Create a Memorystore for Redis instance by using the Google Cloud console
Learn how to create a new 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:
Before you begin
- 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.
-
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 theresourcemanager.projects.createpermission. Learn how to grant roles.
-
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.
-
Verify that billing is enabled for your Google Cloud project.
-
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 theserviceusage.services.enablepermission. Learn how to grant roles. -
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 theresourcemanager.projects.createpermission. Learn how to grant roles.
-
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.
-
Verify that billing is enabled for your Google Cloud project.
-
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 theserviceusage.services.enablepermission. Learn how to grant roles.
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:
-
Cloud Memorystore Redis Admin (
roles/redis.admin) -
Compute Instance Admin (v1) (
roles/compute.instanceAdmin.v1) -
Service Account User (
roles/iam.serviceAccountUser)
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 Redis instance
In the Google Cloud console, go to the Memorystore for Redis page.
Click Create instance.
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).
- In the Instance ID field, enter
Click Create instance.
After the instance is created, obtain your instance's
IP addressby following these steps:- Go to the Memorystore for Redis page in the Google Cloud console.
Memorystore for Redis - Click on the ID of the instance:
my-instance-1. - Under Connections, take a note of your instance's Primary Endpoint.
- Also note that your instance's Port number is
6379.
- Go to the Memorystore for Redis page in the Google Cloud console.
Connect to the Redis instance from a Compute Engine VM instance
You can connect to the Redis instance from any Compute Engine VM that uses the Redis instance's authorized network with a supported RFC 1918 IP address.
If you don't already have a Compute Engine VM that uses that same authorized network as your Redis instance, create one and connect to it by following Quickstart using a Linux VM.
Install
telnetusingapt-get:sudo apt-get install telnetFrom the terminal, telnet to the IP address of the Redis instance, replacing variables with appropriate values.
telnet instance-ip-address 6379
If successful, the command will return this result:
Trying instance-ip-address… Connected to instance-ip-address
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.
To avoid incurring charges to your Google Cloud account for the resources used in this quickstart:
- Go to the Memorystore for Redis page in the Google Cloud console.
Memorystore for Redis - Click the instance ID of the instance you want to delete.
- Click the Delete button.
- In the prompt that appears, enter the instance ID.
- Click Delete.
What's next
- Learn more about creating and managing instances.
- Learn about other ways to connect to your Redis instance.
- Learn about the characteristics of a Redis instance.