Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
Créer des profils de connexion
Cette page décrit la partie préparatoire du processus de migration, au cours de laquelle vous créez des profils de connexion Datastream qui seront utilisés ultérieurement pour importer des données de la base de données source compatible avec MongoDB vers le bucket Cloud Storage.
À ce stade, vous allez effectuer les opérations suivantes :
Créez un profil de connexion Cloud Storage pour le bucket Cloud Storage que vous avez créé précédemment.
Créez un profil de connexion pour la base de données source compatible avec MongoDB.
Se connecter à gcloud CLI
La procédure de migration décrite dans les sections suivantes utilise la gcloud CLI pour configurer et effectuer les étapes de migration. Commencez par vous connecter à Google Cloud et sélectionnez le projet qui hébergera le pipeline de migration.
Cet exemple suppose que vous avez déjà configuré la connectivité SSH à votre réseau privé, soit directement à la machine hébergeant le serveur compatible MongoDB, soit via un hôte bastion.
Exécutez la commande suivante pour créer un profil de connexion Datastream à la base de données MongoDB hébergée sur Compute Engine.
Omettez l'indicateur --mongodb-replica-set de la commande suivante lorsque vous vous connectez à un cluster fragmenté.
Si vous souhaitez vous connecter avec un mot de passe SSH, transmettez l'indicateur --forward-ssh-password au lieu de l'indicateur --forward-ssh-private-key.
Cet exemple suppose que vous avez obtenu les paramètres et les certificats requis pour la connectivité Amazon DocumentDB.
Avant de créer un profil de connexion, activez explicitement les flux de modifications dans la base de données Amazon DocumentDB. Pour savoir comment activer cette fonctionnalité, consultez le guide Flux de modifications Amazon DocumentDB.
Exécutez la commande suivante pour créer un profil de connexion Datastream à votre base de données DocumentDB :
Remplacez subscription_id, resource_group_name et vCore_cluster_name par des valeurs correspondant à votre déploiement Azure Cosmos DB.
Exécutez la commande suivante pour créer un profil de connexion Datastream à la base de données Azure Cosmos DB source.
Cet exemple suppose que la source est accessible via une adresse IP ou DNS publique pouvant être exprimée au format de connexion SRV MongoDB.
Les instructions supposent également que le serveur Azure Cosmos DB utilise une combinaison de nom d'utilisateur et de mot de passe pour l'authentification.
Exécutez la commande suivante pour créer un profil de connexion Datastream à la base de données source MongoDB Atlas.
Cet exemple suppose que la source est accessible via une adresse IP ou DNS publique pouvant être exprimée au format de connexion SRV MongoDB.
Les instructions supposent également que le serveur MongoDB Atlas utilise une combinaison de nom d'utilisateur et de mot de passe pour l'authentification.
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/09/04 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 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)."]]