Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Memorystore for Memcached-Instanz mit der gcloud CLI erstellen
Diese Kurzanleitung führt Sie durch die Schritte zum Erstellen einer Memorystore for Memcached-Instanz, zum Herstellen einer Verbindung zur Instanz, zum Senden einiger Memcached-Befehle und zum Löschen der Instanz.
Hinweise
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.
So erstellen Sie eine Memorystore for Memcache-Instanz:
Öffnen Sie ein Terminalfenster.
Legen Sie das Projekt, in dem Sie die Instanz erstellen möchten, in gcloud als Standardprojekt fest, indem Sie den folgenden Befehl eingeben:
gcloud config set core/project project-id
Geben Sie den folgenden Befehl ein, um eine Memcached-Instanz mit 3 Knoten (jeder Knoten mit 4 Kernen und 10 GB Arbeitsspeicher) in der Region us-central1 zu erstellen:
Verbindung zu einer Instanz über eine Compute Engine-VM herstellen
Verbindung zu einer Linux-VM herstellen: Schritte zum Herstellen einer Verbindung zu einer Linux-VM finden Sie unter Kurzanleitung: Linux-VM verwenden.
Wenn Sie ein Debian-basiertes Image verwendet haben, um Ihre VM-Instanz wie in der Kurzanleitung beschrieben zu erstellen, installieren Sie telnet mit apt-get:
sudo apt-get install telnet
Stellen Sie über das Terminal eine Telnet-Verbindung zur IP-Adresse eines der Memcache-Knoten her und ersetzen Sie variables durch die entsprechenden Werte.
telnet node-ip-address 11211
Wenn es korrekt funktioniert, sollten Sie die folgende Ausgabe sehen, wobei [bracketed-variables] durch die Variablen Ihres Projekts ersetzt wird:
Trying [node-ip-address]…
Connected to [node-ip-address]
Geben Sie in der Telnet-Sitzung einige Memcache-Befehle ein:
Geben Sie dazu Folgendes ein:
get greeting
Ergebnis:
END
Geben Sie Folgendes ein:
set greeting 1 0 11
hello world
Ergebnis:
STORED
Geben Sie Folgendes ein:
get greeting
Result:
VALUE greeting 1 11
hello world
END
Memorystore for Memcache unterstützt standardmäßige Open-Source-Memcache-Bibliotheken.
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 das Löschen der 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-08-19 (UTC)."],[],[],null,["# Quickstart: Create a Memorystore for Memcached instance by using the gcloud CLI\n\nCreate a Memorystore for Memcached instance by using the gcloud CLI\n===================================================================\n\nThis quickstart walks you through the steps to create a Memorystore for Memcached\ninstance, connect to the instance, send some Memcached commands, and delete the\ninstance.\n| **Caution:** You cannot create a Memorystore for Memcached instance without first having a private services access connection established. See [Networking](/memorystore/docs/memcached/networking) for details on the private services access connection that is required for Memorystore for Memcached.\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 SDK](/sdk/docs).\n\n When prompted, choose the project that you selected or created above.\n2. If you already have the Google Cloud SDK installed, update it.\n\n ```\n gcloud components update\n ```\n3. Enable the Service Networking API for your project. \n [Enable the Service Networking API](https://console.cloud.google.com/apis/library/servicenetworking.googleapis.com)\n4. Enable the Memorystore for Memcached API for your project. \n [Enable the Memorystore for Memcached API](https://console.cloud.google.com/apis/api/memcache.googleapis.com)\n\n\u003cbr /\u003e\n\nCreating a Memorystore for Memcached instance\n---------------------------------------------\n\nTo create a Memorystore for Memcached instance:\n\n1. Open a terminal window.\n\n2. Set the project you'd like to create your instance in as the default project\n 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 Memcached instance with 3 nodes (each\n node with 4 cores and 10GB memory) in the us-central1 region:\n\n ```\n gcloud memcache instances create myinstance --node-count=3 --node-cpu=4 \\\n --node-memory=10GB --region=us-central1 --memcached-version=1.6.15\n ```\n4. After you create the instance, run the following `describe` command, and\n write down the IP address of one of your nodes.\n\n ```\n gcloud memcache instances describe myinstance --region=us-central1\n ```\n\nConnecting to your instance from a Compute Engine VM\n----------------------------------------------------\n\n| **Note:** The connecting client must be located in the same region as the Memcached instance. Also, in order to connect the client must use the same network as the Memcached instance, or it must use a Shared VPC network.\n\n1. Connect to a Linux VM. For steps to connect to a Linux VM, see [Quickstart Using a Linux VM](/compute/docs/create-linux-vm-instance).\n If you used a Debian based image to create your VM instance as described in\n the quickstart, install `telnet` using `apt-get`:\n\n ```\n sudo apt-get install telnet\n ```\n2. From the terminal, telnet to the IP address of one of the Memcached nodes,\n replacing \u003cvar translate=\"no\"\u003evariables\u003c/var\u003e with appropriate values.\n\n ```\n telnet node-ip-address 11211\n ```\n\n If it works correctly, you should see the following output with the\n `[bracketed-variables]` replaced by your project's variables: \n\n ```\n Trying [node-ip-address]…\n Connected to [node-ip-address]\n ```\n3. In the telnet session, enter some Memcached commands:\n\n Enter: \n\n ```\n get greeting\n ```\n\n Result: \n\n ```\n END\n ```\n\n Enter: \n\n ```\n set greeting 1 0 11\n hello world\n ```\n\n Result: \n\n ```\n STORED\n ```\n\n Enter: \n\n ```\n get greeting\n ```\n\n Result: \n\n ```\n VALUE greeting 1 11\n hello world\n END\n ```\n\nMemorystore for Memcached supports standard open source Memcached libraries.\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\n resources used in this quickstart, delete the instance by entering the\n following command:\n\n ```\n gcloud memcache instances delete myinstance --region=us-central1\n ```\n\n Enter `Y` to confirm the instance deletion: \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 ```\n2. If successful, `gcloud` returns the following response:\n\n ```\n Deleted instance [myinstance]\n ```\n\nWhat's next\n-----------\n\n- [Connect to a Memcached instance](/memorystore/docs/memcached/connecting-memcached-instance).\n\n- [Use the Auto Discovery service](/memorystore/docs/memcached/using-auto-discovery).\n\n- [Monitor your Memcached instance](/memorystore/docs/memcached/monitoring-instances)."]]