I want to make my PostgreSQL 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.
from the master to the standby. So, that means that the only ways to stop streaming replication are to stop the slave server, to disable access to the master via the pg_hba. conf file (requiring the master configs be reloaded) or to set the trigger file on the slave to tell it to stop replicating the master.
Streaming replication, a standard feature of PostgreSQL, allows the updated information on the primary server to be transferred to the standby server in real time, so that the databases of the primary server and standby server can be kept in sync.
wal_level determines how much information is written to the WAL. The default value is replica , which writes enough data to support WAL archiving and replication, including running read-only queries on a standby server.
max_standby_streaming_delay applies when WAL data is being received via streaming replication. If this value is specified without units, it is taken as milliseconds. The default is 30 seconds. A value of -1 allows the standby to wait forever for conflicting queries to complete.
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:
Here is what I did:
pg_hba.conf
, remove:
host replication replicator x.x.x.x/32 md5
select pg_reload_conf()
standby.signal
Then slave will keep the data, but don't replica from master any more, and slave is writable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With