Pg_xlog automatic cleaning

Does anyone know how to automatically clear pg_xlog in PostgreSQL 9.5? Since I turned on the replication disk, it was full up to 200G in 2 weeks. Therefore, I manually cleaned it with the following commands:

sudo service portgesql stop sudo /usr/lib/postgresql/9.5/bin/pg_controldata /var/lib/postgresql/9.5/main/ | grep Next | grep -v Multi sudo -u postgres /usr/lib/postgresql/9.5/bin/pg_resetxlog -o 44842 -x 575323138 -f /var/lib/postgresql/9.5/main/ sudo service portgesql start 

Of course, I can automate it using a bash script, but the problem here is that you need to stop PotgreSQL. Are there other ways to clear this without stopping PostgreSQL?

+5
source share
1 answer

Worrying a little about the fact that you are deleting files from pg_xlog, they are necessary to restore your database. Please do not tell me that this is a production :)

In any case, there is a more fundamental reason why WALs assemble at such a speed that is associated with the recently introduced "replication slots" in PostgreSQL.

The replication slot will store WAL logs until they are applied to DR so that your WALS are not applied to the backup computer. Most likely, if you delete WALS, then they will never be applied :) and, thus, a full-time cycle comes.

You can also control the number of WALS in this directory by the "wal_keep_segments" parameter, although I'm not sure how much of its role is in 9.5 with a replica and a replication slot.

In any case, you definitely need to stop deleting the WAL and restore your DR with the new synchronization of your wizard.

+3
source

All Articles