pg_recvlogical

Function

pg_recvlogical connects to a specified node to create and delete logical replication slots, obtains the intermediate result of logic decoding from the node continuously in real time, and outputs the result to a file or in standard mode.

Syntax

pg_recvlogical [OPTION]...

Logical replication slot behavior parameters are mandatory and must be specified. Other parameters are optional. If you do not specify them, the default values will be read.

Parameter Description

Logical replication slot behavior parameters (mandatory):

  • --create

    Creates a logical replication slot. The pg_create_logical_replication_slot function is called internally. The user who calls this function must have the SYSADMIN or REPLICATION permission or inherits the permission of the built-in role gs_role_replication. This function can be called only on the primary node. For details, see the description of the pg_create_logical_replication_slot function in SQLReference.

  • --start

    Starts the flow replication of a logic replication slot.

  • --drop

    Deletes a logical replication slot.

Connection parameters:

  • -d, --dbname=DBNAME

    Connects to the target database.

  • -h, --host=HOSTNAME

    Specifies the name or socket of the connected host.

  • -p, --port=PORT

    Specifies the HA port number for connecting to the target database node.

  • -U, --username=NAME

    Specifies the user name for connecting to the target database.

  • -w, --no-password

    Performs connection without a password.

  • -W, --password

    Performs connection with a specified password.

Replication parameters:

Other parameters:

  • -f, --file=FILE

    Specifies the output file.

    If - is used, data is output to stdout.

  • -n, --no-loop

    Specifies that the system does not retry after the connection fails.

  • -v, --verbose

    Displays detailed information.

  • -V, --version

    Displays the version and exits immediately.

  • -?, --help

    Displays help information and exits immediately.

  • -r, --raw

    In parallel decoding scenarios, if this parameter is set, the binary format or batch sending result will not be converted to the text format. This parameter is used only by test personnel to measure the parallel decoding performance. After this parameter is set, the decoding result sent in binary mode or in batches are in unreadable format.

Examples

  1. Create a logical replication slot named test_slot.

    pg_recvlogical -d postgres -S test_slot -p 26000 --create
    
  2. Enable stream decoding and output the result to stdout.

    pg_recvlogical -d postgres -S test_slot -p 26000 --start -v -f -
    pg_recvlogical: starting log streaming at 0/0 (slot test_slot)
    pg_recvlogical: initiated streaming
    pg_recvlogical: confirming write up to 0/0, flush to 0/0 (slot test_slot)
    pg_recvlogical: confirming write up to 0/2A342E8, flush to 0/2A342E8 (slot test_slot)
    pg_recvlogical: confirming write up to 0/2A34320, flush to 0/2A34320 (slot test_slot)
    pg_recvlogical: confirming write up to 0/2A34320, flush to 0/2A34320 (slot test_slot)
    BEGIN 16039
    table public.t: INSERT: a[integer]:4 b[integer]:4
    COMMIT 16039
    pg_recvlogical: confirming write up to 0/2A34450, flush to 0/2A34450 (slot test_slot)
    pg_recvlogical: confirming write up to 0/2A34450, flush to 0/2A34450 (slot test_slot)
    
  3. Delete the logical replication slot.

    pg_recvlogical -d postgres -S test_slot -p 26000 --drop
    
Feedback
编组 3备份
    openGauss 2024-12-22 00:53:44
    cancel