I'm trying to setup postgresql db - version 10 with high availability setup and also want to use custom directories for data,archive and wal directories
After i have initiated db using below command,i have modified the DATADIR path in systemd file and trying to restart the postgresql service but unfortunatley its is failing
/usr/bin/initdb -D /data/dbdata/testdata --locale en_GB.UTF-8 --waldir=/data/wals/testwals
postgresql systemd file as below
cat /lib/systemd/system/postgresql.service
[Unit]
Description=PostgreSQL database server
After=network.target
[Service]
Type=notify
User=postgres
Group=postgres
Environment=PG_OOM_ADJUST_FILE=/proc/self/oom_score_adj
Environment=PG_OOM_ADJUST_VALUE=0
Environment=PGDATA=/data/dbdata/testdata
ExecStartPre=/usr/libexec/postgresql-check-db-dir %N
ExecStart=/usr/bin/postmaster -D ${PGDATA}
ExecReload=/bin/kill -HUP $MAINPID
KillMode=mixed
KillSignal=SIGINT
# No artificial start/stop timeout (rhbz#1525477, pgrpms#2786).
TimeoutSec=0
[Install]
WantedBy=multi-user.target
journaltl log output as below
: Starting PostgreSQL database server...
[54185]: 2021-06-17 14:40:58.953 UTC [54185] LOG: listening on IPv4 address "0.0.0.0", port 5432
[54185]: 2021-06-17 14:40:58.953 UTC [54185] LOG: listening on IPv6 address "::", port 5432
[54185]: 2021-06-17 14:40:58.955 UTC [54185] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
[54185]: 2021-06-17 14:40:58.957 UTC [54185] LOG: listening on Unix socket "/tmp/.s.PGSQL.5432"
[54185]: 2021-06-17 14:40:58.969 UTC [54185] LOG: redirecting log output to logging collector process
[54185]: 2021-06-17 14:40:58.969 UTC [54185] HINT: Future log output will appear in directory "log".
: postgresql.service: Main process exited, code=exited, status=1/FAILURE
: postgresql.service: Killing process 54187 (postmaster) with signal SIGKILL.
: postgresql.service: Failed with result 'exit-code'.
: Failed to start PostgreSQL database server.
From the postgresql log file
# cat /data/dbdata/testdata/log/postgresql-Thu.log
**2021-06-17 14:40:58.972 UTC [54188] FATAL: required WAL directory "pg_wal" does not exist**
2021-06-17 14:40:58.973 UTC [54185] LOG: startup process (PID 54188) exited with exit code 1
2021-06-17 14:40:58.973 UTC [54185] LOG: aborting startup due to startup process failure
2021-06-17 14:40:58.975 UTC [54185] LOG: database system is shut down
But i can able to see the pg_wal is exist as a symbolic link and which is pointing to wal directory which used during db initialization
[testdata]# ls -la pg_wal
lrwxrwxrwx. 1 postgres postgres 19 Jun 17 07:10 pg_wal -> /data/wals/kongwals
[root@ip-10-0-1-120 kongdata]# ls -la /data/wals/kongwals
total 16384
drwx------. 3 postgres postgres 60 Jun 17 07:10 .
drwx------. 3 postgres postgres 22 Jun 17 07:10 ..
-rwx------. 1 postgres postgres 16777216 Jun 17 13:23 000000010000000000000001
drwx------. 2 postgres postgres 6 Jun 17 07:10 archive_status
[tstdata]# ls -la /data/wals
total 0
drwx------. 3 postgres postgres 22 Jun 17 07:10 .
drwx------. 6 postgres postgres 59 Jun 16 13:22 ..
drwx------. 3 postgres postgres 60 Jun 17 07:10 kongwals
NOTE:
/data/wals is a mountpoint.So do i need to set selinux context for this mountpoint?