Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Verbindungsprofile erstellen
Auf dieser Seite wird der Vorbereitungsteil des Migrationsprozesses beschrieben. Dabei erstellen Sie Datastream-Verbindungsprofile, die später zum Importieren von Daten aus der MongoDB-kompatiblen Quelldatenbank in den Cloud Storage-Bucket verwendet werden.
In dieser Phase gehen Sie so vor:
Erstellen Sie ein Cloud Storage-Verbindungsprofil für den Cloud Storage-Bucket, den Sie zuvor erstellt haben.
Erstellen Sie ein Verbindungsprofil für die MongoDB-kompatible Quelldatenbank.
In der gcloud CLI anmelden
Beim Migrationsverfahren, das in den folgenden Abschnitten beschrieben wird, wird die gcloud CLI verwendet, um die Migrationsschritte zu konfigurieren und auszuführen. Melden Sie sich zuerst in Google Cloud an und wählen Sie das Projekt aus, in dem die Migrationspipeline gehostet werden soll.
In diesem Beispiel wird davon ausgegangen, dass Sie die SSH-Verbindung zu Ihrem privaten Netzwerk bereits konfiguriert haben, entweder direkt zum Computer, auf dem der MongoDB-kompatible Server gehostet wird, oder über einen Bastion-Host.
Führen Sie den folgenden Befehl aus, um ein Datastream-Verbindungsprofil für die in Compute Engine gehostete MongoDB-Datenbank zu erstellen.
Lassen Sie das Flag --mongodb-replica-set im folgenden Befehl weg, wenn Sie eine Verbindung zu einem Sharded Cluster herstellen.
Wenn Sie eine Verbindung mit einem SSH-Passwort herstellen möchten, übergeben Sie das Flag --forward-ssh-password anstelle des Flags --forward-ssh-private-key.
In diesem Beispiel wird davon ausgegangen, dass Sie die für die Amazon DocumentDB-Konnektivität erforderlichen Parameter und Zertifikate erhalten haben.
Bevor Sie ein Verbindungsprofil erstellen, müssen Sie Änderungsstreams in der Amazon DocumentDB-Datenbank explizit aktivieren. Eine Anleitung zum Aktivieren dieses Features finden Sie im Leitfaden Amazon DocumentDB Change Streams.
Führen Sie den folgenden Befehl aus, um ein Datastream-Verbindungsprofil für Ihre DocumentDB-Datenbank zu erstellen:
Ersetzen Sie subscription_id, resource_group_name und vCore_cluster_name durch Werte, die Ihrer Azure Cosmos DB-Bereitstellung entsprechen.
Führen Sie den folgenden Befehl aus, um ein Datastream-Verbindungsprofil für die Azure Cosmos DB-Quelle zu erstellen.
In diesem Beispiel wird davon ausgegangen, dass die Quelle über eine öffentliche DNS- oder IP-Adresse zugänglich ist, die im MongoDB SRV-Verbindungsformat angegeben werden kann.
In der Anleitung wird auch davon ausgegangen, dass der Azure Cosmos DB-Server für die Authentifizierung eine Kombination aus Nutzername und Passwort verwendet.
Führen Sie den folgenden Befehl aus, um ein Datastream-Verbindungsprofil für die MongoDB Atlas-Quelldatenbank zu erstellen.
In diesem Beispiel wird davon ausgegangen, dass die Quelle über eine öffentliche DNS- oder IP-Adresse zugänglich ist, die im MongoDB SRV-Verbindungsformat angegeben werden kann.
In der Anleitung wird auch davon ausgegangen, dass der MongoDB Atlas-Server eine Kombination aus Nutzername und Passwort zur Authentifizierung verwendet.
[[["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-04 (UTC)."],[],[],null,["# Create connection profiles\n==========================\n\nThis page describes the preparation part of the\n[migration process](/firestore/mongodb-compatibility/docs/migrate-data)\nwhere you create Datastream connection profiles that will be\nused later from importing data from the MongoDB-compatible source database to\nthe Cloud Storage bucket.\n\nAt this stage, you do the following:\n\n1. Create a Cloud Storage connection profile for the Cloud Storage bucket that you've created earlier.\n2. Create a connection profile for the MongoDB-compatible source database.\n\nSign in to gcloud CLI\n---------------------\n\nThe migration procedure described in the subsequent sections uses the\ngcloud CLI to configure and actuate the migration steps. Begin by\nlogging into Google Cloud and selecting the project that will host the\nmigration pipeline. \n\n gcloud auth login\n gcloud config set project \"$PROJECT_ID\"\n\nCreate a connection profile for the source database\n---------------------------------------------------\n\n### MongoDB on Compute Engine\n\nRun the following command to create a Datastream connection\nprofile to the MongoDB database hosted on Compute Engine.\n\nOmit the `--mongodb-replica-set` flag from the following command when\nconnecting to a sharded cluster. \n\n gcloud datastream connection-profiles create \"$SRC_CONNECTION_PROFILE_NAME\" \\\n --display-name=\"$SRC_CONNECTION_PROFILE_NAME\" \\\n --location=\"$LOCATION\" \\\n --mongodb-username=\"$MONGODB_USERNAME\" \\\n --mongodb-password=\"$MONGODB_PASSWORD\" \\\n --mongodb-host-addresses=\"$MONGODB_IP_ADDRESS\" \\\n --mongodb-replica-set=\"$REPLICA_SET\" \\\n --private-connection=\"$PRIVATE_CONNECTION_NAME\" \\\n --mongodb-standard-connection-format \\\n --type=mongodb \\\n --mongodb-direct-connection\n\n### MongoDB over SSH\n\nThis example assumes you have already [configured SSH connectivity](/firestore/mongodb-compatibility/docs/migrate-configure-env-vars#mongodb-over-ssh)\nto your private network, either directly to the machine hosting the MongoDB\ncompatible server, or through a [Bastion](/solutions/connecting-securely#bastion)\nhost.\n\nRun the following command to create a Datastream connection\nprofile to the MongoDB database hosted on Compute Engine.\n\nOmit the `--mongodb-replica-set` flag from the following command when\nconnecting to a sharded cluster.\n\nIf you want to connect with an SSH password, pass the\n`--forward-ssh-password` flag instead of the `--forward-ssh-private-key` flag. \n\n gcloud datastream connection-profiles create \"$SRC_CONNECTION_PROFILE_NAME\" \\\n --display-name=\"$SRC_CONNECTION_PROFILE_NAME\" \\\n --location=\"$LOCATION\" \\\n --mongodb-username=\"$MONGODB_USERNAME\" \\\n --mongodb-password=\"$MONGODB_PASSWORD\" \\\n --mongodb-host-addresses=\"$MONGODB_IP_ADDRESS\" \\\n --mongodb-replica-set=\"$REPLICA_SET\" \\\n --forward-ssh-hostname=\"$BASTION_IP_ADDRESS\" \\\n --forward-ssh-port=\"$BASTION_SSH_PORT\" \\\n --forward-ssh-username=\"$BASTION_SSH_USERNAME\" \\\n --forward-ssh-private-key=\"$BASTION_SSH_PRIVATE_KEY\" \\\n --mongodb-standard-connection-format \\\n --type=mongodb \\\n --mongodb-direct-connection\n\n### Amazon DocumentDB\n\nThis example assumes you have obtained the parameters and certificates required\nfor [Amazon DocumentDB connectivity](/firestore/mongodb-compatibility/docs/migrate-configure-env-vars#amazon-documentdb).\n\nPrior to creating a connection profile, explicitly enable change streams in\nthe Amazon DocumentDB database. See the [Amazon DocumentDB Change Streams](https://docs.aws.amazon.com/documentdb/latest/developerguide/change_streams.html)\nguide for instructions on enabling this feature.\n\nRun the following command to create a Datastream connection\nprofile to your DocumentDB database: \n\n gcloud datastream connection-profiles create \"$SRC_CONNECTION_PROFILE_NAME\" \\\n --display-name=\"$SRC_CONNECTION_PROFILE_NAME\" \\\n --location=\"$LOCATION\" \\\n --mongodb-username=\"$MONGODB_USERNAME\" \\\n --mongodb-password=\"$MONGODB_PASSWORD\" \\\n --mongodb-host-addresses=\"$MONGODB_HOST_ADDRESS\" \\\n --mongodb-replica-set=\"$REPLICA_SET\" \\\n --forward-ssh-hostname=\"$BASTION_IP_ADDRESS\" \\\n --forward-ssh-port=\"$BASTION_SSH_PORT\" \\\n --forward-ssh-username=\"$BASTION_SSH_USERNAME\" \\\n --forward-ssh-private-key=\"$BASTION_SSH_PRIVATE_KEY\" \\\n --mongodb-ca-certificate=\"$DOCUMENT_DB_CA_CERTIFICATE\" \\\n --mongodb-tls \\\n --mongodb-standard-connection-format \\\n --type=mongodb \\\n --mongodb-direct-connection\n\n### Azure Cosmos DB\n\nExplicitly enable change streams for MongoDB in Azure Cosmos DB's API to\nenable initiating Datastream streams.\n\nThis step requires\n[installing Azure CLI](/firestore/mongodb-compatibility/docs/migrate-configure-resources#install-source-specific-tools). \n\n az resource patch --ids \"/subscriptions/\u003cvar translate=\"no\"\u003esubscription_id\u003c/var\u003e/resourceGroups/\u003cvar translate=\"no\"\u003eresource_group_name\u003c/var\u003e/providers/Microsoft.DocumentDB/mongoClusters/\u003cvar translate=\"no\"\u003evCore_cluster_name\u003c/var\u003e\" \\\n --api-version 2024-10-01-preview \\\n --properties \"{\\\"previewFeatures\\\": [ \\\"ChangeStreams\\\"]}\"\n\nReplace \u003cvar translate=\"no\"\u003esubscription_id\u003c/var\u003e, \u003cvar translate=\"no\"\u003eresource_group_name\u003c/var\u003e, and\n\u003cvar translate=\"no\"\u003evCore_cluster_name\u003c/var\u003e with values corresponding to your\nAzure Cosmos DB deployment.\n\nRun the following command to create a Datastream connection\nprofile to the source Azure Cosmos DB.\n\nThis example assumes that the source is accessible through a public DNS or IP\naddress that can be expressed in the\n[MongoDB SRV connection format](https://www.mongodb.com/docs/manual/reference/connection-string/).\nThe instructions also assume the Azure Cosmos DB server\nuses a combination of a username and password for authentication. \n\n gcloud datastream connection-profiles create \"$SRC_CONNECTION_PROFILE_NAME\" \\\n --display-name=\"$SRC_CONNECTION_PROFILE_NAME\" \\\n --location=\"$LOCATION\" \\\n --mongodb-username=\"$MONGODB_USERNAME\" \\\n --mongodb-password=\"$MONGODB_PASSWORD\" \\\n --mongodb-host-addresses=\"$MONGODB_HOST_ADDRESS\" \\\n --mongodb-srv-connection-format \\\n --type=mongodb \\\n --static-ip-connectivity \\\n --labels=skip_all_validations=true\n\n### MongoDB Atlas\n\nRun the following command to create a Datastream connection\nprofile to the source MongoDB Atlas database.\n\nThis example assumes that the source is accessible through a public DNS or IP\naddress that can be expressed in the\n[MongoDB SRV connection format](https://www.mongodb.com/docs/manual/reference/connection-string/).\nThe instructions also assume that MongoDB Atlas server\nuses a combination of a username and password for authentication. \n\n gcloud datastream connection-profiles create \"$SRC_CONNECTION_PROFILE_NAME\" \\\n --display-name=\"$SRC_CONNECTION_PROFILE_NAME\" \\\n --location=\"$LOCATION\" \\\n --mongodb-username=\"$MONGODB_USERNAME\" \\\n --mongodb-password=\"$MONGODB_PASSWORD\" \\\n --mongodb-host-addresses=\"$MONGODB_HOST_ADDRESS\" \\\n --mongodb-srv-connection-format \\\n --type=mongodb \\\n --static-ip-connectivity\n\nFor more information about monitoring the connection profile creation, see\n[Troubleshooting](/firestore/mongodb-compatibility/docs/migrate-troubleshooting).\n\nCreate a Cloud Storage connection profile\n-----------------------------------------\n\nConfigure the Datastream connection profile for the\nCloud Storage destination, which is the bucket that you've created\nearlier. \n\n gcloud datastream connection-profiles create \"$DST_CONNECTION_PROFILE_NAME\" \\\n --display-name=\"$DST_CONNECTION_PROFILE_NAME\" \\\n --location=\"$LOCATION\" \\\n --type=google-cloud-storage \\\n --bucket=\"$GCS_BUCKET_NAME\" \\\n --root-path=\"/$GCS_BUCKET_ROOT_PATH\"\n\nFor more information about monitoring the connection profile creation, see\n[Troubleshooting](/firestore/mongodb-compatibility/docs/migrate-troubleshooting).\n\nWhat's next\n-----------\n\nProceed to\n[Import from the source database](/firestore/mongodb-compatibility/docs/migrate-import-from-source)."]]