6
votes

I want to make my master / slave streaming replication setup into a single master slave setup without replication and without HA.

How is it possible to tell master that it no longer has slave and it should not replicate its data to the slave. Of course it should also not keep WALs to be sent to the slave as is done when the slave is temporarily down.

1
There is nothing you need to do. Just shut down the slave. Streaming replication is a "pull" replication - the slave actively retrieves the WAL records from the master. - a_horse_with_no_name
If I shut down the slave doesn't the master accumulate WALs? Isn't wal_keep_segments indicates how many WALs will be kept in Master in case data was not sent to slave? - user1409708
from the docs: Specifies the minimum number of past log file segments kept in the pg_xlog directory. I believe it is a lower bound, not an upper bound. - AJ Slater

1 Answers

1
votes

Depending on the version of Postgres you're using, it's possible your replicatoin is done using "replication slots". If you don't have a client streaming from a replication slot anymore, you can drop the slot. Here are some useful queries:

Get disk usage per replication slot (for Postgres 9.6):

SELECT
    redo_location,
    slot_name,restart_lsn,
    round((redo_location-restart_lsn) / 1024 / 1024 / 1024, 2) AS GB_behind
FROM
    pg_control_checkpoint(),
    pg_replication_slots;

Get disk usage per replication slot (for Postgres 10+):

SELECT redo_lsn,
    slot_name,
    restart_lsn,
    round((redo_lsn-restart_lsn) / 1024 / 1024 / 1024, 2) AS GB_behind
FROM pg_control_checkpoint(),
    pg_replication_slots;

Drop replication slot:

select pg_drop_replication_slot('slot_name');

References: