0

I'm looking for a reference and ways to separating the WAL transaction Logs and the data into two different disk for postgres.

1 Answers1

1

That can be done when you create the cluster:

initdb --waldir=/somewhere/else datadir

But you can also do it later:

  • stop the server

  • move pg_wal somewhere else

  • create a symbolic link pg_wal instead that points to the new location

Note that a pg_basebackup will not preserve the symbolic link, so if you want to create a standby where pg_wal is a symbolic link, you'll need to use the --waldir option of pg_basebackup.

Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263
  • Will try it. Actually doing DRBD replcation as well for /dev/sdb as postgres data and /dev/sdc for the wal log and /dev/sda will be for the system. – Ershad Ahamed Sep 17 '20 at 12:05
  • I tried the below but doesn't worked #pg_ctl initdb -X /var/lib/pg_wal -D /var/lib/pgsql/data (pg_ctl: invalid option -- 'X' Try "pg_ctl --help" for more information.) – Ershad Ahamed Sep 18 '20 at 07:04
  • The `pg_ctl` documentation will tell you that you have to use `-o` to separate `pg_ctl` options from `initdb` options. – Laurenz Albe Sep 18 '20 at 07:48
  • 1
    Please note `initdb` will only affect master/leader node. In order to make it effective on replica nodes too, we need to use `--waldir=waldir` in [pg_backup](https://www.postgresql.org/docs/13/app-pgbasebackup.html) – anasanjaria Sep 22 '22 at 06:40
  • 1
    @anasanjaria That is a useful comment. I took the liberty to add it to the answer. – Laurenz Albe Sep 22 '22 at 06:45