Instanzbereitstellung in einem freigegebenen VPC-Netzwerk
Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Auf dieser Seite werden die gcloud CLI-Befehle aufgeführt, die zum Einrichten von Voraussetzungen, zum Bereitstellen einer Instanz in einem Dienstprojekt, zum Beschreiben einer Instanz und zum Löschen einer Instanz erforderlich sind. Folgen Sie der Anleitung in den einzelnen Abschnitten dieser Seite, um diese Aufgaben zu erledigen.
Ausführliche Informationen zu diesen Aufgaben finden Sie auf den folgenden Seiten:
Aktivieren Sie die folgenden APIs, die zum Konfigurieren einer Dienstverbindungsrichtlinie, zum Konfigurieren einer freigegebenen VPC und zum Erstellen einer Memorystore for Valkey-Instanz erforderlich sind.
gcloud
Aktivieren Sie die folgenden APIs im Dienstprojekt:
Ersetzen Sie HOST_PROJECT_ID durch die ID Ihres Hostprojekts.
Richtlinie für Dienstverbindungen erstellen
Als Nächstes muss eine Richtlinie für Dienstverbindungen für das Hostprojekt der freigegebene VPC erstellt werden, in der die Richtlinie definiert ist, sowie für das Netzwerk, die Region und die Subnetze, in denen Sie die Memorystore for Valkey-Instanz bereitstellen möchten. Normalerweise wird dies von Ihrem Netzwerkadministrator erledigt. Möglicherweise haben Sie aber auch die erforderliche Berechtigung zum Ausführen des Befehls, wenn Sie die erforderliche Rolle haben.
In dieser Kurzanleitung werden das Netzwerk default und das Subnetz default verwendet. IP-Adressen für Ihre Instanz werden in diesem Standardsubnetz in der Region zugewiesen.
gcloud
Führen Sie den Befehl create aus, um die Richtlinie für Dienstverbindungen zu erstellen:
REGION ist die Region, in der Sie Ihre Instanz bereitstellen möchten.
NODE_TYPE ist der von Ihnen ausgewählte Knotentyp. Zulässige Werte:
shared-core-nano
standard-small
highmem-medium
highmem-xlarge
SHARD_COUNT bestimmt die Anzahl der Shards in Ihrer Instanz. Die Anzahl der Shards bestimmt die Gesamtspeicherkapazität für das Speichern von Instanzdaten. Weitere Informationen zur Instanzspezifikation finden Sie unter Instanz- und Knotenspezifikation.
REPLICA_COUNT ist die gewünschte Anzahl von Lesereplikaten (pro Shard).
Zulässige Werte sind 0, 1 und 2.
HOST_PROJECT_ID ist die Hostprojekt-ID.
Instanz beschreiben
Führen Sie den folgenden Befehl aus, um die Instanzdetails aufzurufen:
[[["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,["# Instance provisioning on a Shared VPC network\n\nThis page lists the gcloud CLI commands needed to set up\nprerequisites, provision an instance in a service project, describe an instance,\nand delete an instance. In order to accomplish these tasks you should follow\nthe instructions in each section of this page.\n\nFor more detailed guidance for these tasks, see the following pages:\n\n- [Networking](/memorystore/docs/valkey/networking)\n- [Create instances](/memorystore/docs/valkey/create-instances)\n- [List instances](/memorystore/docs/valkey/list-instances)\n- [Delete instances](/memorystore/docs/valkey/delete-instances)\n\nEnable APIs\n-----------\n\nEnable the following APIs needed for configuring a service connection\npolicy, [configuring Shared VPC](/vpc/docs/provisioning-shared-vpc),\nand creating a Memorystore for Valkey instance. \n\n### gcloud\n\n1. Enable the following APIs in the service project:\n\n ```\n gcloud services enable --project=SERVICE_PROJECT_ID networkconnectivity.googleapis.com\n gcloud services enable --project=SERVICE_PROJECT_ID serviceconsumermanagement.googleapis.com\n gcloud services enable --project=SERVICE_PROJECT_ID memorystore.googleapis.com\n ```\n\n Replace the \u003cvar translate=\"no\"\u003eSERVICE_PROJECT_ID\u003c/var\u003e with your service project ID.\n2. Enable the following APIs in the host project:\n\n ```\n gcloud services enable --project=HOST_PROJECT_ID networkconnectivity.googleapis.com\n ```\n\n Replace the \u003cvar translate=\"no\"\u003eHOST_PROJECT_ID\u003c/var\u003e with the ID of your host project.\n\nCreate a service connection policy\n----------------------------------\n\nNext, a [service connection policy](/vpc/docs/about-service-connection-policies)\nmust be created for the host project of the Shared VPC where the policy\nis defined, network, region, and the subnet(s) where you want to provision\nthe Memorystore for Valkey instance. Usually this is done by your Network Admin,\nor you might have the necessary permission run the command if you have the\n[Required role](/vpc/docs/configure-service-connection-policies#roles).\n\nThis quickstart uses the `default` network and `default` subnet. IP addresses\nfor your instance are allocated on this default subnet in the region. \n\n### gcloud\n\n1. To create the service connection policy, run the `create` command:\n\n ```\n gcloud network-connectivity service-connection-policies create POLICY_NAME \\\n --network=default \\\n --project=HOST_PROJECT_ID \\\n --region=REGION \\\n --service-class=gcp-memorystore \\\n --subnets=https://www.googleapis.com/compute/v1/projects/HOST_PROJECT_ID/regions/REGION/subnetworks/default\n ```\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003ePOLICY_NAME\u003c/var\u003e is your desired policy name.\n - \u003cvar translate=\"no\"\u003eHOST_PROJECT_ID\u003c/var\u003e is the host project ID.\n - \u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e is the same region where you want to provision your Memorystore for Valkey instance.\n2. To validate if the policy was created successfully, run the `list`\n command:\n\n ```\n gcloud network-connectivity service-connection-policies list \\\n --region=REGION \\\n --project=HOST_PROJECT_ID\n ```\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eHOST_PROJECT_ID\u003c/var\u003e is the host project ID.\n - \u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e is the region where the service connection policy is defined.\n\nCreate an instance\n------------------\n\nTo create an instance in the service project attached to the Shared VPC, run the following command: \n\n### gcloud\n\n```\ngcloud memorystore instances create INSTANCE \\\n--project=SERVICE_PROJECT_ID \\\n--location=REGION \\\n--node-type=NODE_TYPE \\\n--shard-count=SHARD_COUNT \\\n--replica-count=REPLICA_COUNT \\\n--endpoints='[{\"connections\": [{\"pscAutoConnection\": {\"network\": \"projects/HOST_PROJECT_ID/global/networks/default\", \"projectId\": \"SERVICE_PROJECT_ID\"}}]}]'\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eINSTANCE\u003c/var\u003e is the instance ID.\n- \u003cvar translate=\"no\"\u003eSERVICE_PROJECT_ID\u003c/var\u003e is the service project ID.\n- \u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e is the region where you want to provision your instance.\n\n- \u003cvar translate=\"no\"\u003eNODE_TYPE\u003c/var\u003e is your chosen node type. Accepted values are:\n\n - `shared-core-nano`\n - `standard-small`\n - `highmem-medium`\n - `highmem-xlarge`\n\n | **Caution** : We recommend that you use the `shared-core-nano` node type for development or testing purposes only. If you run Memorystore for Valkey in a production environment, then we recommend using the `standard-small`, `highmem-medium`, or `highmem-xlarge` node types. For more information about these node types, see [Choose a node type](/memorystore/docs/valkey/instance-node-specification#choose-node-type).\n- \u003cvar translate=\"no\"\u003eSHARD_COUNT\u003c/var\u003e determines the number of shards in your\n instance. Shard count determines the total memory capacity for storing\n instance data. To see more details about instance specification, see [Instance and node specification](/memorystore/docs/valkey/instance-node-specification).\n\n- \u003cvar translate=\"no\"\u003eREPLICA_COUNT\u003c/var\u003e is your desired number of read replicas (per shard).\n Accepted values are `0`, `1`, and `2`.\n\n- \u003cvar translate=\"no\"\u003eHOST_PROJECT_ID\u003c/var\u003e is the host project ID.\n\nDescribe the instance\n---------------------\n\nTo view instance details, run the following command: \n\n### gcloud\n\n```\ngcloud memorystore instances describe INSTANCE \\\n--project=SERVICE_PROJECT_ID \\\n--location=REGION\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eINSTANCE\u003c/var\u003e is the instance ID.\n- \u003cvar translate=\"no\"\u003eSERVICE_PROJECT_ID\u003c/var\u003e is the service project ID.\n- \u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e is the region where your instance is located.\n\nDelete the instance\n-------------------\n\nTo delete an instance, run the following command: \n\n### gcloud\n\n```\ngcloud memorystore instances delete INSTANCE \\\n--project=SERVICE_PROJECT_ID \\\n--location=REGION\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eINSTANCE\u003c/var\u003e is the instance ID.\n- \u003cvar translate=\"no\"\u003eSERVICE_PROJECT_ID\u003c/var\u003e is the service project ID.\n- \u003cvar translate=\"no\"\u003eREGION\u003c/var\u003e is the region where your instance is located."]]