How to change the Write Ahead Log directory
-
01-10-2020 - |
Question
How do you change the defined WAL directory?
During the installation I defined a directory, /var/lib/wal
and the $PGDATA/pg_xlog
has a symbolic link pointing to that directory.
How do I change the postgres setting to write the WAL files elsewhere - without having to re-install?
Solution
This can be done according to the documentation [here]:(http://www.postgresql.org/docs/9.1/static/wal-internals.html)
It is advantageous if the log is located on a different disk from the main database files. This can be achieved by moving the pg_xlog directory to another location (while the server is shut down, of course) and creating a symbolic link from the original location in the main data directory to the new location.
OTHER TIPS
It is very-very simple:
- Make sure your postgres is not running!
- mount your WAL disk to an easy accessible folder
- check the permissions of your WAL directory ($PG_DATA/pg_xlog/)
- copy or move all files from $PG_DATA/pg_xlog/ into this directory
- unmount the WAL disk and remount it to $PG_DATA/pg_xlog/
- Check the permissions and fix if necessary (of the directory and files inside)
- Start postgres again ^^
You are done!