Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Membuat profil koneksi
Halaman ini menjelaskan bagian persiapan dari
proses migrasi
tempat Anda membuat profil koneksi Datastream yang akan
digunakan nanti untuk mengimpor data dari database sumber yang kompatibel dengan MongoDB ke
bucket Cloud Storage.
Pada tahap ini, Anda akan melakukan hal berikut:
Buat profil koneksi Cloud Storage untuk bucket Cloud Storage yang telah Anda buat sebelumnya.
Buat profil koneksi untuk database sumber yang kompatibel dengan MongoDB.
Login ke gcloud CLI
Prosedur migrasi yang dijelaskan di bagian berikutnya menggunakan
gcloud CLI untuk mengonfigurasi dan mengaktifkan langkah-langkah migrasi. Mulai dengan
login ke Google Cloud dan memilih project yang akan menghosting
pipeline migrasi.
Contoh ini mengasumsikan Anda telah mengonfigurasi konektivitas SSH
ke jaringan pribadi, baik secara langsung ke mesin yang menghosting server yang kompatibel dengan MongoDB, atau melalui host Bastion.
Jalankan perintah berikut untuk membuat profil koneksi Datastream ke database MongoDB yang dihosting di Compute Engine.
Hilangkan tanda --mongodb-replica-set dari perintah berikut saat
menghubungkan ke cluster yang di-shard.
Jika Anda ingin terhubung dengan sandi SSH, teruskan flag
--forward-ssh-password, bukan flag --forward-ssh-private-key.
Contoh ini mengasumsikan bahwa Anda telah mendapatkan parameter dan sertifikat yang diperlukan
untuk konektivitas Amazon DocumentDB.
Sebelum membuat profil koneksi, aktifkan aliran perubahan secara eksplisit di database Amazon DocumentDB. Lihat panduan Aliran Perubahan Amazon DocumentDB
untuk mengetahui petunjuk tentang cara mengaktifkan fitur ini.
Jalankan perintah berikut untuk membuat profil koneksi Datastream ke database DocumentDB Anda:
Ganti subscription_id, resource_group_name, dan
vCore_cluster_name dengan nilai yang sesuai dengan deployment Azure Cosmos DB Anda.
Jalankan perintah berikut untuk membuat profil koneksi Datastream ke Azure Cosmos DB sumber.
Contoh ini mengasumsikan bahwa sumber dapat diakses melalui DNS atau alamat IP publik yang dapat dinyatakan dalam
format koneksi SRV MongoDB.
Petunjuk ini juga mengasumsikan bahwa server Azure Cosmos DB menggunakan kombinasi nama pengguna dan sandi untuk autentikasi.
Jalankan perintah berikut untuk membuat profil koneksi Datastream ke database MongoDB Atlas sumber.
Contoh ini mengasumsikan bahwa sumber dapat diakses melalui DNS atau alamat IP publik yang dapat dinyatakan dalam
format koneksi SRV MongoDB.
Petunjuk ini juga mengasumsikan bahwa server MongoDB Atlas menggunakan kombinasi nama pengguna dan sandi untuk autentikasi.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 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)."]]