Eu enfrentei um problema semelhante no Fedora. Mesmo /var/log/audit/audit.log
não forneceu nenhuma pista, o motivo é o SElinux.
O diretório de espaço de tabela está ok.
[me@my /]$ ls -alr /psql
drwx------. 2 postgres postgres 4096 14.Mar 22.56 a
dr-xr-xr-x. 19 root root 4096 14.Mar 15.13 ..
drwxr-xr-x. 3 postgres postgres 4096 14.Mar 15.21 .
Mas o CREATE TABLESPACE falhou.
[me@my /]# psql -U postgres
postgres=# create tablespace test_index location '/psql/a';
ERROR: could not set permissions on directory "/psql/a": Permission denied
postgres=# \quit
Stracing confirmou um problema:
[me@my /]$ ps ax |grep postgres
18719 ? S 0:00 /usr/bin/postgres -D /var/lib/pgsql/data
18720 ? Ss 0:00 postgres: logger process
18722 ? Ss 0:00 postgres: checkpointer process
18723 ? Ss 0:00 postgres: writer process
18724 ? Ss 0:00 postgres: wal writer process
18725 ? Ss 0:00 postgres: autovacuum launcher process
18726 ? Ss 0:00 postgres: stats collector process
20446 ? Ss 0:00 postgres: postgres postgres [local] idle
strace failed:
[me@my /]$ sudo strace -p 20446
strace: Process 20446 attached
epoll_pwait(3, [{EPOLLIN, {u32=2672404064, u64=94302974355040}}], 1, -1, NULL, 8) = 1
recvfrom(11, "Q[me@my /]# setenforce 0
[me@my /]# sestatus
SELinux status: enabled
SELinuxfs mount: /sys/fs/selinux
SELinux root directory: /etc/selinux
Loaded policy name: targeted
Current mode: permissive
Mode from config file: enforcing
Policy MLS status: enabled
Policy deny_unknown status: allowed
Memory protection checking: actual (secure)
Max kernel policy version: 31
[me@my /]# psql -U postgres
psql (9.6.7)
postgres=# create tablespace test_index location '/psql/a';
CREATE TABLESPACE
epoll_pwait(3, [{EPOLLIN, {u32=3479758432, u64=94226472298080}}], 1, -1, NULL, 8) = 1
recvfrom(11, "Q[me@my /]$ ls -alr /psql
drwx------. 2 postgres postgres 4096 14.Mar 22.56 a
dr-xr-xr-x. 19 root root 4096 14.Mar 15.13 ..
drwxr-xr-x. 3 postgres postgres 4096 14.Mar 15.21 .
[me@my /]# psql -U postgres
postgres=# create tablespace test_index location '/psql/a';
ERROR: could not set permissions on directory "/psql/a": Permission denied
postgres=# \quit
[me@my /]$ ps ax |grep postgres
18719 ? S 0:00 /usr/bin/postgres -D /var/lib/pgsql/data
18720 ? Ss 0:00 postgres: logger process
18722 ? Ss 0:00 postgres: checkpointer process
18723 ? Ss 0:00 postgres: writer process
18724 ? Ss 0:00 postgres: wal writer process
18725 ? Ss 0:00 postgres: autovacuum launcher process
18726 ? Ss 0:00 postgres: stats collector process
20446 ? Ss 0:00 postgres: postgres postgres [local] idle
strace failed:
[me@my /]$ sudo strace -p 20446
strace: Process 20446 attached
epoll_pwait(3, [{EPOLLIN, {u32=2672404064, u64=94302974355040}}], 1, -1, NULL, 8) = 1
recvfrom(11, "Q[me@my /]# setenforce 0
[me@my /]# sestatus
SELinux status: enabled
SELinuxfs mount: /sys/fs/selinux
SELinux root directory: /etc/selinux
Loaded policy name: targeted
Current mode: permissive
Mode from config file: enforcing
Policy MLS status: enabled
Policy deny_unknown status: allowed
Memory protection checking: actual (secure)
Max kernel policy version: 31
[me@my /]# psql -U postgres
psql (9.6.7)
postgres=# create tablespace test_index location '/psql/a';
CREATE TABLESPACE
epoll_pwait(3, [{EPOLLIN, {u32=3479758432, u64=94226472298080}}], 1, -1, NULL, 8) = 1
recvfrom(11, "Q%pre%%pre%%pre%05create tablespace test_inde"..., 8192, 0, NULL, NULL) = 54
lseek(5, 0, SEEK_END) = 8192
chmod("/psql/a", 0700) = 0
mkdir("/psql/a/PG_9.6_201608131", 0700) = 0
symlink("/psql/a", "pg_tblspc/16454") = 0
%pre%05create tablespace test_inde"..., 8192, 0, NULL, NULL) = 54
lseek(5, 0, SEEK_END) = 8192
chmod("/psql/a", 0700) = -1 EACCES (Permission denied)
05create tablespace test_inde"..., 8192, 0, NULL, NULL) = 54
lseek(5, 0, SEEK_END) = 8192
chmod("/psql/a", 0700) = 0
mkdir("/psql/a/PG_9.6_201608131", 0700) = 0
symlink("/psql/a", "pg_tblspc/16454") = 0
%pre%05create tablespace test_inde"..., 8192, 0, NULL, NULL) = 54
lseek(5, 0, SEEK_END) = 8192
chmod("/psql/a", 0700) = -1 EACCES (Permission denied)
Desligar o SElinux finalmente resolveu o problema
%pre%
strace success:
%pre%
Observação: adicionar postgres
user a root
group não ajudou.