Postgresql – Postgres replication not cleaning up WAL files

postgresqlreplicationwrite-ahead-logging

I'm not that great with postgres but i was able to setup replication following this tutorial:
https://www.howtoforge.com/tutorial/how-to-set-up-master-slave-replication-for-postgresql-96-on-ubuntu-1604/
It all works great but the amount of WAL files is getting ridiculous.
I assume the slave should tell them master to remove old files, but I'm not sure how to do that.
I have the same settings as in the tutorial. I've already tried to "manually" clean them, which lead to a ton of problems. But right now the i'm using 30GB of space for the files and i'm afraid to do any more massive imports into my db because i will run out of space

Best Answer

I think you're looking for the archive_cleanup_command setting in your recovery.conf file:

archive_cleanup_command = 'pg_archivecleanup archivelocation %r'

See the docs or this post for more info.