Configurer une base de données PostgreSQL Amazon RDS
Restez organisé à l'aide des collections
Enregistrez et classez les contenus selon vos préférences.
La page suivante explique comment configurer la CDC pour une base de données Amazon RDS pour PostgreSQL.
Créer un groupe de paramètres
Lancez votre tableau de bord Amazon RDS.
Dans le panneau de navigation, cliquez sur Groupes de paramètres, puis sur Créer un groupe de paramètres. La page Créer un groupe de paramètres s'affiche.
Sélectionnez la famille de base de données qui correspond à votre base de données, saisissez un nom et une description pour le groupe de paramètres, puis cliquez sur Créer.
Cochez la case à gauche du groupe de paramètres que vous venez de créer, puis cliquez sur Modifier sous Actions associées au groupe de paramètres.
Définissez le paramètre suivant pour votre groupe.
Paramètre
Valeur
rds.logical_replication
1
Cliquez sur Enregistrer les modifications.
Configurer la base de données source
Lancez votre tableau de bord Amazon RDS.
Dans le panneau de navigation, cliquez sur Bases de données.
Sélectionnez votre source, puis cliquez sur Modifier.
Accédez à la section Configuration supplémentaire.
Sélectionnez le groupe de paramètres que vous avez créé.
Cliquez sur Continuer.
Sous Planification des modifications, sélectionnez Appliquer immédiatement.
Vérifier que le groupe de paramètres est attribué à l'instance de base de données
Lancez votre tableau de bord Amazon RDS.
Dans le panneau de navigation, cliquez sur Bases de données, puis sélectionnez votre instance de base de données.
Cliquez sur l'onglet Configurations.
Vérifiez que le groupe de paramètres que vous avez créé s'affiche et que son état correspond à pending-reboot (redémarrage en attente).
Redémarrez votre instance de base de données pour terminer la configuration. Pour redémarrer l'instance :
Dans le panneau de navigation, cliquez sur Instances.
Sélectionnez votre instance de base de données.
Dans le menu Actions associées à l'instance, sélectionnez Redémarrer.
Créer une publication et un emplacement de réplication
Créez une publication. Nous vous recommandons de créer une publication uniquement pour les tables que vous souhaitez répliquer. Cela permet à Datastream de lire uniquement les données pertinentes et de réduire la charge sur la base de données et Datastream:
CREATE PUBLICATION PUBLICATION_NAME
FOR TABLE SCHEMA1.TABLE1, SCHEMA2.TABLE2;
Remplacez les éléments suivants :
PUBLICATION_NAME: nom de votre publication. Vous devrez indiquer ce nom lorsque vous créerez un flux dans l'assistant de création de flux Datastream.
SCHEMA: nom du schéma contenant la table.
TABLE: nom de la table que vous souhaitez répliquer.
Vous pouvez également créer une publication pour toutes les tables de votre base de données. Notez que cette approche augmente la charge sur la base de données source et sur Datastream:
CREATE PUBLICATION PUBLICATION_NAME FOR ALL TABLES;
Créez un emplacement de réplication en saisissant la commande PostgreSQL suivante:
REPLICATION_SLOT_NAME: nom de votre emplacement de réplication. Vous devrez indiquer ce nom lorsque vous créerez un flux dans l'assistant de création de flux Datastream.
Créer un utilisateur Datastream
Pour créer un utilisateur Datastream, saisissez la commande PostgreSQL suivante :
CREATE USER USER_NAME WITH ENCRYPTED PASSWORD 'USER_PASSWORD';
Remplacez les éléments suivants :
USER_NAME: nom de l'utilisateur Datastream que vous souhaitez créer.
USER_PASSWORD: mot de passe de connexion de l'utilisateur Datastream que vous souhaitez créer.
Accordez les droits suivants à l'utilisateur que vous avez créé :
GRANT RDS_REPLICATION TO USER_NAME;
GRANT SELECT ON ALL TABLES IN SCHEMA SCHEMA_NAME TO USER_NAME;
GRANT USAGE ON SCHEMA SCHEMA_NAME TO USER_NAME;
ALTER DEFAULT PRIVILEGES IN SCHEMA SCHEMA_NAME
GRANT SELECT ON TABLES TO USER_NAME;
Remplacez les éléments suivants :
USER_NAME: utilisateur auquel vous souhaitez accorder les droits.
SCHEMA_NAME: nom du schéma auquel vous souhaitez accorder les droits.
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)."],[[["\u003cp\u003eThis page outlines the steps to configure Change Data Capture (CDC) for an Amazon RDS for PostgreSQL database, beginning with creating and modifying a database parameter group.\u003c/p\u003e\n"],["\u003cp\u003eConfiguring the source database involves assigning the newly created parameter group and applying it immediately, which requires a mandatory wait period for these changes to be properly applied.\u003c/p\u003e\n"],["\u003cp\u003eTo enable CDC, you must create a publication, either for specific tables or all tables, and a replication slot within the PostgreSQL database to track data changes.\u003c/p\u003e\n"],["\u003cp\u003eA dedicated Datastream user must be created with specific privileges like \u003ccode\u003eRDS_REPLICATION\u003c/code\u003e and \u003ccode\u003eSELECT\u003c/code\u003e access on relevant tables and schemas to facilitate data replication.\u003c/p\u003e\n"],["\u003cp\u003eVerifying the correct parameter group assignment requires a reboot of the database instance, after which the parameter group status should show as in-sync, indicating successful application of the changes.\u003c/p\u003e\n"]]],[],null,["# Configure an Amazon RDS PostgreSQL database\n\nThe following page covers how to configure CDC for an Amazon RDS for PostgreSQL database.\n\n### Create a parameter group\n\n1. Launch your Amazon RDS Dashboard.\n\n2. In the **Navigation Drawer** , click **Parameter Groups** , and then click **Create Parameter Group** . The **Create Parameter Group** page appears.\n\n3. Select the database family that matches your database, provide a name and description for the parameter group, and then click **Create**.\n\n4. Select the checkbox to the left of your newly created parameter group, and then, under **Parameter group actions** , click **Edit**.\n\n5. Set the following parameter for your group.\n\n6. Click **Save Changes**.\n\n | For PostgreSQL 13 and later, it is recommended that you also set the `max_slot_wal_keep_size` parameter in the `postgresql.conf` file to limit the amount of storage used by replication slots. For more information, see [Work with PostgreSQL database WAL log files](/datastream/docs/work-with-postgresql-database-wal-log-files).\n\n### Configure the source database\n\n1. Launch your Amazon RDS Dashboard.\n\n2. In the **Navigation Drawer** , click **Databases**.\n\n3. Select your source, and then click **Modify**.\n\n4. Go to the **Additional configuration** section.\n\n5. Select the parameter group that you [created](#create-a-parameter-group-rds).\n\n6. Click **Continue**.\n\n7. Under **Scheduling of modifications** , select **Apply immediately**.\n\n | Because you modified your source, you must wait until the changes to your parameter group are applied before proceeding.\n\n### Verify that the parameter group is assigned to the database instance\n\n1. Launch your Amazon RDS Dashboard.\n\n2. In the **Navigation Drawer** , click **Databases**, and then select your database instance.\n\n3. Click the **Configurations** tab.\n\n4. Verify that you see the parameter group that you [created](#create-a-parameter-group-rds), and that its status is **pending-reboot**.\n\n5. Reboot your database instance to complete the configuration. To reboot the instance:\n\n 1. In the **Navigation Drawer** , click **Instances**.\n 2. Select your database instance.\n 3. From the **Instance Actions** menu, select **Reboot**.\n\n | After you reboot your database instance, its status changes to **in-sync**.\n\n### Create a publication and a replication slot\n\n1. Create a publication. We recommend that you create a publication only for the\n tables that you want to replicate. This allows Datastream to read-only\n the relevant data, and lowers the load on the database and Datastream:\n\n ```\n CREATE PUBLICATION PUBLICATION_NAME\n FOR TABLE SCHEMA1.TABLE1, SCHEMA2.TABLE2;\n ```\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003ePUBLICATION_NAME\u003c/var\u003e: The name of your publication. You'll need to provide this name when you create a stream in the Datastream stream creation wizard.\n - \u003cvar translate=\"no\"\u003eSCHEMA\u003c/var\u003e: The name of the schema that contains the table.\n - \u003cvar translate=\"no\"\u003eTABLE\u003c/var\u003e: The name of the table that you want to replicate.\n\n You can also create a publication for all tables in your database. Note that\n this approach increases the load on both the source database and Datastream: \n\n ```\n CREATE PUBLICATION PUBLICATION_NAME FOR ALL TABLES;\n ```\n | For PostgreSQL 15 and later, you can create a publication for all tables in a schema. This approach lets you replicate changes for tables in the specified list of schemas, including tables that you create in the future: \n |\n | ```\n | CREATE PUBLICATION PUBLICATION_NAME\n | FOR TABLES IN SCHEMA SCHEMA1, SCHEMA2;\n | ```\n2. Create a replication slot by entering the following PostgreSQL command:\n\n ```\n SELECT PG_CREATE_LOGICAL_REPLICATION_SLOT('REPLICATION_SLOT_NAME', 'pgoutput'); \n ```\n\n \u003cbr /\u003e\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eREPLICATION_SLOT_NAME\u003c/var\u003e: The name of your replication slot. You'll need to provide this name when you create a stream in the Datastream stream creation wizard.\n\n | The replication slot must be unique for each stream that's replicating from this database.\n\n### Create a Datastream user\n\n1. To create a Datastream user, enter the following PostgreSQL command:\n\n ```\n CREATE USER USER_NAME WITH ENCRYPTED PASSWORD 'USER_PASSWORD';\n ```\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eUSER_NAME\u003c/var\u003e: The name of the Datastream user that you want to create.\n - \u003cvar translate=\"no\"\u003eUSER_PASSWORD\u003c/var\u003e: The login password for the Datastream user that you want to create.\n2. Grant the following privileges to the user you created:\n\n ```\n GRANT RDS_REPLICATION TO USER_NAME;\n GRANT SELECT ON ALL TABLES IN SCHEMA SCHEMA_NAME TO USER_NAME;\n GRANT USAGE ON SCHEMA SCHEMA_NAME TO USER_NAME;\n ALTER DEFAULT PRIVILEGES IN SCHEMA SCHEMA_NAME\n GRANT SELECT ON TABLES TO USER_NAME;\n ```\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eUSER_NAME\u003c/var\u003e: The user to whom you want to grant the privileges.\n - \u003cvar translate=\"no\"\u003eSCHEMA_NAME\u003c/var\u003e: The name of the schema to which you want to grant the privileges.\n\nWhat's next\n-----------\n\n- Learn more about how Datastream works with [PostgreSQL sources](/datastream/docs/sources-postgresql)."]]