Postgres Get Replication Slots

Postgres Get Replication Slots Average ratng: 4,4/5 5977 reviews

#define PGGETREPLICATIONSLOTSCOLS 13. Generated on Sat Dec 12 2020 00:13:42 for PostgreSQL Source Code by 1.8.13. It creates a permanent (persistent) logical replication slot on the publisher. PostgreSQL persists the state of the replication slot information in pgreplslot subdirectory within the data directory of the publisher. How To Install PostgreSQL Replication With Slots. Configure recovery.conf. After running pgbasebackup, we update the recovery.conf under the data directory with vi command and update it as follows. This tutorial assumes you have already setup streaming replication between a primary and a replica PostgreSQL server. If you need to set that up, use our Posgres replication tutorial. Also, make sure you have replication slots setup as well. You can set that up using our replication slot tutorial.

Note

This plugin is part of the community.general collection (version 1.3.0).

To install it use: ansible-galaxycollectioninstallcommunity.general.

Postgres

To use it in a playbook, specify: community.general.postgresql_slot.

  • Add or remove physical or logical replication slots from a PostgreSQL database.

The below requirements are needed on the host that executes this module.

I am trying to get a stream of updates for certain tables from my PostgreSQL database. The regular way of getting all updates looks like this: You create a logical replication slot.

  • psycopg2

ParameterChoices/DefaultsComments
ca_cert
string
Specifies the name of a file containing SSL certificate authority (CA) certificate(s).
If the file exists, the server's certificate will be verified to be signed by one of these authorities.
db
Name of database to connect to.
immediately_reserve
    Choices:
  • no
  • yes
Optional parameter that when yes specifies that the LSN for this replication slot be reserved immediately, otherwise the default, no, specifies that the LSN is reserved on the first connection from a streaming replication client.
Uses only with slot_type=physical.
login_host
Host running the database.
login_password
string
login_unix_socket
Path to a Unix domain socket for local connections.
login_user
string
Default:
The username used to authenticate with.
name
string / required

aliases: slot_name
output_plugin
string
Default:
All logical slots must indicate which output plugin decoder they're using.
It will be ignored with slot_type=physical.
port
integer
Default:
Database port to connect to.
session_role
Switch to session_role after connecting. The specified session_role must be a role that the current login_user is a member of.
Permissions checking for SQL commands is carried out as though the session_role were the one that had logged in originally.
slot_type
string
    Choices:
  • logical
Slot type.
ssl_mode
string
    Choices:
  • allow
  • disable
  • require
  • verify-ca
  • verify-full
Determines whether or with what priority a secure SSL TCP/IP connection will be negotiated with the server.
See https://www.postgresql.org/docs/current/static/libpq-ssl.html for more information on the modes.
state
    Choices:
  • absent
  • present
state=present implies the slot must be present in the system.
state=absent implies the groups must be revoked from target_roles.
trust_input
boolean
    Choices:
  • no
  • yes
If no, check the value of session_role is potentially dangerous.
It makes sense to use no only when SQL injections via session_role are possible.

Replication

Note

  • Physical replication slots were introduced to PostgreSQL with version 9.4, while logical replication slots were added beginning with version 10.0.

  • The default authentication assumes that you are either logging in as or sudo’ing to the postgres account on the host.

  • To avoid “Peer authentication failed for user postgres” error, use postgres user as a become_user.

  • This module uses psycopg2, a Python PostgreSQL database adapter. You must ensure that psycopg2 is installed on the host before using this module.

  • If the remote host is the PostgreSQL server (which is the default case), then PostgreSQL must also be installed on the remote host.

  • For Ubuntu-based systems, install the postgresql, libpq-dev, and python-psycopg2 packages on the remote host before using this module.

  • The ca_cert parameter requires at least Postgres version 8.4 and psycopg2 version 2.4.3.

See also

PostgreSQL pg_replication_slots view reference

Complete reference of the PostgreSQL pg_replication_slots view.

PostgreSQL streaming replication protocol reference

Complete reference of the PostgreSQL streaming replication protocol documentation.

PostgreSQL logical replication protocol reference

Complete reference of the PostgreSQL logical replication protocol documentation.

Common return values are documented here, the following are the fields unique to this module:

KeyReturnedDescription
name
string
always
Sample:
queriesalways
List of executed queries.

['SELECT pg_create_physical_replication_slot('physical_one', False, False)']

Authors¶

Postgres Get Replication Slots Software

  • John Scalia (@jscalia)

  • Andrew Klychkov (@Andersson007)

  • Thomas O’Donnell (@andytom)