Vous pouvez établir la connectivité de la base de données AlloyDB de destination à la base de données source via un tunnel SSH inversé sécurisé. Cette méthode nécessite une VM hôte bastion dans le projet Google Cloud , ainsi qu'une machine (par exemple, un ordinateur portable sur le réseau) connectée à la base de données source.
Database Migration Service pour PostgreSQL vers AlloyDB collecte les informations requises au moment de la création de la migration et génère automatiquement le script de configuration.
Consultez le diagramme suivant :
Configurer un tunnel SSH inversé
Les étapes suivantes sont effectuées dans le flux Database Migration Service pour créer une tâche de migration afin de configurer un tunnel SSH inversé entre la base de données source et l'instance AlloyDB. Après avoir fourni des paramètres, vous exécutez un ensemble de commandes gcloud sur une machine connectée à la fois à la base de données source et à Google Cloud.
Sélectionnez l'instance de VM utilisée pour établir la connectivité entre la base de données source et l'instance AlloyDB. Il s'agit généralement d'une VM exécutée dans le VPC où s'exécute l'application qui accède à la nouvelle base de données AlloyDB. L'instance de VM sert de serveur bastion du tunnel SSH.
Vous pouvez utiliser à cette fin une instance de VM Compute Engine existante.
Choisissez l'instance de VM Compute Engine dans la liste.
Indiquez un port libre que le tunnel SSH peut utiliser.
Vous pouvez également créer une VM à cette étape. Sélectionnez CREATE A COMPUTE ENGINE VM INSTANCE. Le script généré inclut des instructions pour le créer.
Attribuez un nom à l'instance de VM.
Sélectionnez un type de machine pour la VM.
Spécifier un sous-réseau pour la VM
Cliquez sur AFFICHER LE SCRIPT pour afficher le script généré.
Assurez-vous que la section des connexions de réplication du fichier pg_hba.conf ou les définitions des groupes de sécurité AWS RDS sur la base de données source sont mises à jour pour accepter les connexions provenant de la plage d'adresses IP du VPC AlloyDB.
Exécutez le script sur une machine ayant accès à la base de données source et à la VM Compute Engine. Le script effectue les opérations suivantes:
Configure la VM Compute Engine en tant que serveur bastion de tunnel SSH.
Établit une connexion SSH sécurisée entre la base de données source et le VPC.
Si vous créez une VM Compute Engine, après avoir exécuté le script, copiez l'adresse IP du serveur de VM dans le résultat du script et saisissez-la dans le champ de texte fourni. L'instance AlloyDB sera mise à jour si nécessaire lorsque vous testerez ou démarrerez le job de migration ultérieurement.
Cliquez sur CONFIGURER ET CONTINUER.
Vérifiez votre job de migration pour vous assurer qu'il a correctement migré les données de votre instance de base de données source vers l'instance de base de données AlloyDB de destination.
Si votre source se trouve dans un VPN (par exemple, dans AWS ou dans votre propre VPN sur site), consultez la section
Connecter des VPC via des VPN pour en savoir plus sur la configuration du VPN source et de Google Cloud VPN afin qu'ils fonctionnent ensemble.
Une fois votre tâche de migration configurée, la connectivité vérifiée et les VPN configurés correctement si nécessaire, vous pouvez l'exécuter.
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/05 (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/05 (UTC)."],[[["\u003cp\u003eA secure reverse SSH tunnel can be established to connect a destination AlloyDB database to a source database, requiring a bastion host VM in Google Cloud and a machine with connectivity to the source.\u003c/p\u003e\n"],["\u003cp\u003eThe Database Migration Service automatically generates a script during migration job creation to set up the reverse SSH tunnel for PostgreSQL to AlloyDB migrations.\u003c/p\u003e\n"],["\u003cp\u003eUsers can select an existing Compute Engine VM or create a new one to serve as the SSH tunnel bastion server, but any created by script is not managed by Database Migration Service.\u003c/p\u003e\n"],["\u003cp\u003eThe generated script configures the Compute Engine VM as an SSH tunnel bastion server and establishes a secure connection between the source database and the VPC.\u003c/p\u003e\n"],["\u003cp\u003eIf the source database is behind a VPN, you should use the VPN IP address and port in the source connection profile, instead of the source IP and port.\u003c/p\u003e\n"]]],[],null,["# Configure connectivity using reverse SSH tunnel\n\n\u003cbr /\u003e\n\n[MySQL](/database-migration/docs/mysql/configure-connectivity-reverse-ssh-tunnel \"View this page for the MySQL version of Database Migration Service.\") \\| [PostgreSQL](/database-migration/docs/postgres/configure-connectivity-reverse-ssh-tunnel \"View this page for the PostgreSQL version of Database Migration Service.\") \\| PostgreSQL to AlloyDB\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nOverview\n--------\n\nYou can establish connectivity from the destination AlloyDB database to the source database through a secure reverse SSH tunnel. This method requires a bastion host VM in the Google Cloud project as well as a machine (for example, a laptop on the network) that has connectivity to the source database. **Important:** If your source is within a VPN (in AWS, for example, or your own on-premises VPN), your source connection profile should use the VPN IP address and port instead of the source IP address and port.\n\nThe Database Migration Service for PostgreSQL to AlloyDB collects the required information at migration creation\ntime, and auto-generates the script for setting it all up.\n\nSee the following diagram:\n\n\nSet up a reverse SSH tunnel\n---------------------------\n\nThe following steps are performed in the Database Migration Service flow for\n[creating a migration job](/database-migration/docs/postgresql-to-alloydb/create-migration-job), to set up a reverse SSH tunnel between the source database and AlloyDB instance. After you provide some parameters, you execute a set of `gcloud`\ncommands on a machine which has connectivity to both the source database and to Google Cloud.\n\n1. Select the VM instance used to establish connectivity between the source database and the AlloyDB instance. Typically this is a VM running in the VPC where the application accessing the new AlloyDB database runs. The VM instance serves as the SSH tunnel bastion server.\n2. You can use an existing Compute Engine VM instance for this purpose.\n\n 1. Choose the Compute Engine VM instance from the list.\n\n 2. Provide a free port that the SSH tunnel can use.\n\n | Note: For the reverse SSH tunnel to work, set the \\`GatewayPorts\\` parameter to \\`yes\\` in the `/etc/ssh/sshd_config` file on the target server. After you update the file, restart the sshd service using the `sudo systemctl restart sshd.service` command. \n |\n | If you don't want to change the configuration of your existing VM, then create a new VM.\n3. Alternatively, you can create a new VM at this step. Select\n `CREATE A COMPUTE ENGINE VM INSTANCE` and the generated script\n includes instructions to create it.\n\n 1. Provide a name for the VM instance.\n\n 2. Select a machine type for the VM.\n\n 3. Specify a subnet for the VM\n\n | Note: A Compute Engine VM instance created by the script isn't managed by Database Migration Service. If one is created, then your organization is charged for the instance based on standard pricing, and is responsible for its management, including deleting the instance when it's no longer needed.\n4. Click **VIEW SCRIPT** to view the generated script.\n\n | By default, the script will generate a public IP address for the Compute Engine VM server. If you want the IP address to be private, then do the following:\n | - Alter the `gcloud compute instances create` command by adding the [--no-address](https://cloud.google.com/sdk/gcloud/reference/compute/instances/create#--address) flag.\n | - Alter the `gcloud compute ssh` command by adding the [--internal-ip](https://cloud.google.com/sdk/gcloud/reference/compute/ssh#--internal-ip) flag.\n |\n | Also, if you want to create a bastion host VM on a subnet which is on a shared VPC, then alter the `export SUBNET_NAME` command from the generated script to point to `/projects/`\u003cvar translate=\"no\"\u003eproject_name\u003c/var\u003e`/regions/`\u003cvar translate=\"no\"\u003eregion_name\u003c/var\u003e`/subnetworks/`\u003cvar translate=\"no\"\u003esubnetwork_name\u003c/var\u003e.\n |\n | For example:\n |\n | `export SUBNET_NAME=projects/myproject/regions/myregion/subnetworks/mysubnetwork`\n |\n | \u003cvar translate=\"no\"\u003eproject_name\u003c/var\u003e is the name of the project where the shared VPC is placed. A project has regions and subnetworks. \u003cvar translate=\"no\"\u003eregion_name\u003c/var\u003e and \u003cvar translate=\"no\"\u003esubnetwork_name\u003c/var\u003e are the names of the region and subnetwork that are associated with the VPC project.\n\n \u003cbr /\u003e\n\n\n **Make sure the replication connections section of the `pg_hba.conf`\n file or the AWS RDS security groups definitions on the source database are updated to accept connections from the\n AlloyDB VPC's IP address range.**\n5. **Run the script on a machine that has access to both the source database and the\n Compute Engine VM**. The script performs the following operations:\n\n - Configures the Compute Engine VM as an SSH tunnel bastion server.\n\n - Establishes a secure SSH connection between the source database and the\n VPC.\n\n -\n If you're creating a new Compute Engine VM, then after successfully\n running the script, copy the VM server IP from the script output and enter\n it in the provided text field. The AlloyDB instance will be updated\n as needed when you later test or start the migration job.\n\n6. Click **CONFIGURE \\& CONTINUE**.\n\n7. [Verify your migration job](/database-migration/docs/postgresql-to-alloydb/verify-migration) to confirm that it correctly migrated data from your source database instance to the destination AlloyDB database instance.\n\n8. If your source is within a VPN (in AWS, for example, or your own\n on-premises VPN), proceed to the section on [connecting VPCs through VPNs](/database-migration/docs/postgresql-to-alloydb/configure-connectivity-vpns#vpc-vpn) for more information on configuring the\n source VPN and Google Cloud VPN to work with each other.\n\n9. After your migration job is configured, connectivity is verified,\n and VPNs are configured successfully if necessary, then you can run the job."]]