Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Instanz von Memorystore for Redis mit der gcloud CLI erstellen
Hier erfahren Sie, wie Sie eine neue Memorystore for Redis-Instanz erstellen, eine Verbindung zur Instanz herstellen und die Instanz anschließend löschen.
Eine detaillierte Anleitung dazu finden Sie direkt in der Google Cloud Console. Klicken Sie dazu einfach auf Anleitung:
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.
Verwenden Sie die Werte host und port, um eine Verbindung zur Instanz herzustellen.
Verbindung zu einer Redis-Instanz über eine Compute Engine-VM herstellen
Sie können eine Verbindung zur Redis-Instanz über eine Compute Engine-VM herstellen, die das autorisierte Netzwerk der Redis-Instanz mit einer unterstützten IP-Adresse gemäß RFC 1918 verwendet.
Wenn Sie noch keine Compute Engine-VM haben, die dasselbe autorisierte Netzwerk wie Ihre Redis-Instanz verwendet, erstellen Sie eine VM und stellen Sie eine Verbindung zu ihr her: Folgen Sie dazu der Kurzanleitung: Linux-VM verwenden.
Installieren Sie telnet mit apt-get:
sudo apt-get install telnet
Rufen Sie vom Terminal aus Telnet an die IP-Adresse der Redis-Instanz auf und ersetzen Sie variables durch die entsprechenden Werte.
telnet instance-ip-address 6379
Bei Erfolg gibt der Befehl folgendes Ergebnis zurück:
Trying instance-ip-address…
Connected to instance-ip-address
Geben Sie in der Telnet-Sitzung einige Redis-Befehle ein:
Geben Sie Folgendes ein:
PING
Ergebnis:
PONG
Eingeben
SET HELLO WORLD
Ergebnis:
+OK
Geben Sie Folgendes ein:
GET HELLO
Ergebnis:
$5
WORLD
Bereinigen
Mit den folgenden Schritten vermeiden Sie, dass Ihrem Google Cloud -Konto die auf dieser Seite verwendeten Ressourcen in Rechnung gestellt werden:
Löschen Sie die Instanz mit dem folgenden Befehl, um zu vermeiden, dass Ihrem Google Cloud -Konto die in dieser Kurzanleitung verwendeten Ressourcen in Rechnung gestellt werden:
Geben Sie Y ein, um die zu löschende Instanz zu bestätigen:
You are about to delete instance [myinstance] in [us-central1].
Any associated data will be lost.
Do you want to continue (Y/n)? Y
Delete request issued for: [myinstance]
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-09-05 (UTC)."],[],[],null,["# Quickstart: Create a Memorystore for Redis instance by using the gcloud CLI\n\nCreate a Memorystore for Redis instance by using the gcloud CLI\n===============================================================\n\n| **Note:** If you are looking for the Memorystore for Redis Cluster documentation, see [Instance provisioning on a VPC network](/memorystore/docs/cluster/instance-provisioning-vpc).\n\nLearn how to create a new Memorystore for Redis instance, connect to\nit, and then delete it.\n\n*** ** * ** ***\n\nTo follow step-by-step guidance for this task directly in the\nGoogle Cloud console, click **Guide me**:\n\n[Guide me](https://console.cloud.google.com/freetrial?redirectPath=/?tutorial=memorystore__memorystore_redis_gcloud_quickstart)\n\n*** ** * ** ***\n\nBefore you begin\n----------------\n\n- Sign in to your Google Cloud account. If you're new to Google Cloud, [create an account](https://console.cloud.google.com/freetrial) to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.\n- In the Google Cloud console, on the project selector page,\n select or create a Google Cloud project.\n\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n-\n [Verify that billing is enabled for your Google Cloud project](/billing/docs/how-to/verify-billing-enabled#confirm_billing_is_enabled_on_a_project).\n\n- In the Google Cloud console, on the project selector page,\n select or create a Google Cloud project.\n\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n-\n [Verify that billing is enabled for your Google Cloud project](/billing/docs/how-to/verify-billing-enabled#confirm_billing_is_enabled_on_a_project).\n\n1. If you haven't already, [install the Google Cloud CLI](/sdk/docs).\n\n When prompted, choose the project that you selected or created above.\n2. If you already have the Google Cloud CLI installed, update it.\n\n ```\n gcloud components update\n ```\n\n\u003cbr /\u003e\n\nCreating a Memorystore for Redis instance\n-----------------------------------------\n\nTo create a Memorystore for Redis instance:\n\n1. Open a terminal window.\n2. Set the project you'd like to create your instance in as the default project in `gcloud` by entering the following command:\n\n ```\n gcloud config set core/project PROJECT_ID\n ```\n3. Enter the following command to create a 2 GiB Basic Tier Redis instance in the `us-central1` region:\n\n ```\n gcloud redis instances create myinstance --size=2 --region=us-central1 \\\n --redis-version=redis_6_x\n ```\n4. After the instance is created, enter the `describe` command to get the IP address and port of the instance:\n\n ```\n gcloud redis instances describe myinstance --region=us-central1\n ```\n\n If successful, `gcloud` returns the following: \n\n ```\n authorizedNetwork: projects/my-project/global/networks/default\n createTime: '2018-04-09T21:47:56.824081Z'\n currentLocationId: us-central1-a\n host: 10.0.0.27\n locationId: us-central1-a\n memorySizeGb: 2\n name: projects/my-project/locations/us-central1/instances/myinstance\n networkThroughputGbps: 2\n port: 6379\n redisVersion: REDIS_6_X\n reservedIpRange: 10.0.0.24/29\n state: READY\n tier: BASIC\n ```\n\n \u003cbr /\u003e\n\n You'll use the `host` and `port` values to connect to the instance.\n\nConnecting to the Redis instance from a Compute Engine VM\n---------------------------------------------------------\n\nYou can connect to the Redis instance from any Compute Engine VM\nthat uses the Redis instance's authorized network with a [supported RFC 1918 IP address](/memorystore/docs/redis/networking#supported_and_unsupported_networks).\n\n1. If you don't already have a Compute Engine VM that uses that same\n authorized network as your Redis instance, create one and connect to it by\n following [Quickstart using a Linux VM](/compute/docs/create-linux-vm-instance).\n\n2. Install `telnet` using `apt-get`:\n\n sudo apt-get install telnet\n\n3. From the terminal, telnet to the IP address of the Redis instance, replacing\n \u003cvar translate=\"no\"\u003evariables\u003c/var\u003e with appropriate values.\n\n ```\n telnet instance-ip-address 6379\n ```\n\n If successful, the command will return this result: \n\n ```\n Trying instance-ip-address…\n Connected to instance-ip-address\n ```\n4. In the telnet session, enter some Redis commands:\n\n Enter: \n\n ```\n PING\n ```\n\n Result: \n\n ```\n PONG\n ```\n\n Enter \n\n ```\n SET HELLO WORLD\n ```\n\n Result: \n\n ```\n +OK\n ```\n\n Enter: \n\n ```\n GET HELLO\n ```\n\n Result: \n\n ```\n $5\n WORLD\n ```\n\nClean up\n--------\n\n\nTo avoid incurring charges to your Google Cloud account for\nthe resources used on this page, follow these steps.\n\n1. To avoid incurring charges to your Google Cloud account for the resources used in this quickstart, delete the instance by entering the following command:\n\n ```\n gcloud redis instances delete myinstance --region=us-central1\n ```\n2. Enter `Y` to confirm the instance to delete:\n\n ```\n You are about to delete instance [myinstance] in [us-central1].\n Any associated data will be lost.\n Do you want to continue (Y/n)? Y\n Delete request issued for: [myinstance]\n ```\n\n If successful, `gcloud` returns the following response: \n\n ```\n Deleted instance [myinstance].\n ```\n\n \u003cbr /\u003e\n\nWhat's next\n-----------\n\n- Learn more about [creating and managing instances](/memorystore/docs/redis/creating-managing-instances).\n- Learn about other ways to [connect to your Redis instance](/memorystore/docs/redis/connecting-redis-instance).\n- Learn about the characteristics of a [Redis instance](/memorystore/docs/redis/instances)."]]