Domanda

I've enabled the archive_mode with wal_level = hot_standby on a master server. I intended to send the wal logs to a nfs share with:

archive_command = 'test ! -f /mnt/psql_wal/%f && cp -i %p /mnt/psql_wal/%f'

But it keeps telling me this:

sh: /var/lib/pgsql/archive_wal.sh: Permission denied
LOG:  archive command failed with exit code 126
DETAIL:  The failed archive command was: test ! -f /mnt/psql_wal/000000010000000000000001 && cp -i pg_xlog/000000010000000000000001 /mnt/psql_wal/000000010000000000000001
cp: failed to access ‘/mnt/psql_wal/000000010000000000000001’: Permission denied

Basic nfs permissions issue, you may think, but no. The following command works:

sudo -H -u postgres cp -i /var/lib/pgsql/data/pg_xlog/000000010000000000000001 /mnt/psql_wal/000000010000000000000001

Is the archive command running under a different user?

È stato utile?

Soluzione

You are probably a victim of selinux or something like it, in which the same system OS account can have different permissions depending whether it is running as a deamon or from a command line (and, it often seems, depending on the barometric pressure, the phase of the moon, and what you had for breakfast).

You can turn it off, or put it into permissive mode where it allows the access and just logs a gripe.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a dba.stackexchange
scroll top