Thread: postgresql-ctl systemd failed: permission denied

postgresql-ctl systemd failed: permission denied

From
arnaud gaboury
Date:
On Fedora 22

% pg_ctl -V
pg_ctl (PostgreSQL) 9.4.4

----------------------------------------------------------------
% systemctl status postgresql.service -l
● postgresql.service - PostgreSQL database server
   Loaded: loaded (/etc/systemd/system/postgresql.service; enabled;
vendor preset: disabled)
   Active: failed (Result: exit-code) since Tue 2015-07-28 11:50:01
CEST; 19min ago

Jul 28 11:49:56 poppy systemd[1]: Starting PostgreSQL database server...
Jul 28 11:49:57 poppy postgresql-ctl[307]: FATAL:  42501: could not
open log file "/storage/log/postgresql/postgresql-Tue.log": Permission
denied
Jul 28 11:49:57 poppy postgresql-ctl[307]: LOCATION:  logfile_open,
syslogger.c:1160
Jul 28 11:50:01 poppy postgresql-ctl[307]: pg_ctl: could not start server
----------------------------------------------------------------

% ls -al /storage/log
drwxr-xr-x 1 postgres postgres    0 Jul 28 11:29 postgresql/


I have found a few entries on the web but with no clear fix. I even
saw this was a bug.

Can anyone tell me more and how to fix if it is possible?

Thank you
--

google.com/+arnaudgabourygabx


Re: postgresql-ctl systemd failed: permission denied

From
Francisco Olarte
Date:
Hi Arnaud...

On Tue, Jul 28, 2015 at 12:13 PM, arnaud gaboury
<arnaud.gaboury@gmail.com> wrote:
> On Fedora 22
...
> Jul 28 11:49:57 poppy postgresql-ctl[307]: FATAL:  42501: could not
> open log file "/storage/log/postgresql/postgresql-Tue.log": Permission
> denied
> Jul 28 11:49:57 poppy postgresql-ctl[307]: LOCATION:  logfile_open,
> syslogger.c:1160
> Jul 28 11:50:01 poppy postgresql-ctl[307]: pg_ctl: could not start server
> ----------------------------------------------------------------

> % ls -al /storage/log
> drwxr-xr-x 1 postgres postgres    0 Jul 28 11:29 postgresql/

May be stating the obvious, but can you try 'touch
/storage/log/postgresql/postgresql-Tue.log" as postgres to see it it
works. Also, doing the ls -al on /storage/log/postgresql, in case it
has a previous read only file for Tue, and may be even a lsattr on the
paths ( listing the fs type will be useful too, maybe Fedora is using
some extended thingies ).

Francisco Olarte.


Re: postgresql-ctl systemd failed: permission denied

From
arnaud gaboury
Date:


On Tue, Jul 28, 2015 at 1:26 PM, Francisco Olarte <folarte@peoplecall.com> wrote:
Hi Arnaud...

On Tue, Jul 28, 2015 at 12:13 PM, arnaud gaboury
<arnaud.gaboury@gmail.com> wrote:
> On Fedora 22
...
> Jul 28 11:49:57 poppy postgresql-ctl[307]: FATAL:  42501: could not
> open log file "/storage/log/postgresql/postgresql-Tue.log": Permission
> denied
> Jul 28 11:49:57 poppy postgresql-ctl[307]: LOCATION:  logfile_open,
> syslogger.c:1160
> Jul 28 11:50:01 poppy postgresql-ctl[307]: pg_ctl: could not start server
> ----------------------------------------------------------------

> % ls -al /storage/log
> drwxr-xr-x 1 postgres postgres    0 Jul 28 11:29 postgresql/

May be stating the obvious, but can you try 'touch
/storage/log/postgresql/postgresql-Tue.log" as postgres to see it it
works.
% ls -al /storage/log/postgresql 
total 0
drwxrwxr-x 1 postgres postgres  36 Jul 28 13:27 ./
drwxr-x--- 1 root     wheel    208 Jul 27 13:34 ../
-rw-rw-r-- 1 postgres postgres   0 Jul 28 13:27 postgresql-Tue.log

Still permission denied


 
Also, doing the ls -al on /storage/log/postgresql, in case it
has a previous read only file for Tue, and may be even a lsattr on the
paths

# lsattr /storage/log      
---------------- /storage/log/django_slacklog
---------------- /storage/log/wiki
---------------- /storage/log/nginx
---------------- /storage/log/php-fpm
---------------- /storage/log/phppgadmin
---------------- /storage/log/postgresql
---------------- /storage/log/xdebug
---------------- /storage/log/psqlStat
---------------- /storage/log/psqlReport
---------------- /storage/log/dovecot
---------------- /storage/log/vsftpd
---------------- /storage/log/fail2ban
---------------- /storage/log/wtmp
---------------- /storage/log/btmp

( listing the fs type will be useful too, maybe Fedora is using
some extended thingies ).

Francisco Olarte.



--

Re: postgresql-ctl systemd failed: permission denied

From
Albe Laurenz
Date:
arnaud gaboury wrote:
> On Fedora 22
> 
> % pg_ctl -V
> pg_ctl (PostgreSQL) 9.4.4
> 
> ----------------------------------------------------------------
> % systemctl status postgresql.service -l
> ● postgresql.service - PostgreSQL database server
>    Loaded: loaded (/etc/systemd/system/postgresql.service; enabled;
> vendor preset: disabled)
>    Active: failed (Result: exit-code) since Tue 2015-07-28 11:50:01
> CEST; 19min ago
> 
> Jul 28 11:49:56 poppy systemd[1]: Starting PostgreSQL database server...
> Jul 28 11:49:57 poppy postgresql-ctl[307]: FATAL:  42501: could not
> open log file "/storage/log/postgresql/postgresql-Tue.log": Permission
> denied
> Jul 28 11:49:57 poppy postgresql-ctl[307]: LOCATION:  logfile_open,
> syslogger.c:1160
> Jul 28 11:50:01 poppy postgresql-ctl[307]: pg_ctl: could not start server
> ----------------------------------------------------------------
> 
> % ls -al /storage/log
> drwxr-xr-x 1 postgres postgres    0 Jul 28 11:29 postgresql/
> 
> 
> I have found a few entries on the web but with no clear fix. I even
> saw this was a bug.
> 
> Can anyone tell me more and how to fix if it is possible?

What file system is that? ext4?

What do you get for:
  ls -l /storage/log/postgresql/postgresql-Tue.log
Perhaps the file exists and you don't have permissions to open it.

If not, does the following succeed as user "postgres":
  touch /storage/log/postgresql/postgresql-Tue.log
Do you get the same error message?

What do you get for:
  getfacl -p /storage/log/postgresql
  getfattr -d /storage/log/postgresql
Maybe some weird permissions or attributes are set.

Another idea: the file system could be mounted read-only.

Yours,
Laurenz Albe

Re: postgresql-ctl systemd failed: permission denied

From
arnaud gaboury
Date:


On Tue, Jul 28, 2015 at 1:31 PM, Albe Laurenz <laurenz.albe@wien.gv.at> wrote:
arnaud gaboury wrote:
> On Fedora 22
>
> % pg_ctl -V
> pg_ctl (PostgreSQL) 9.4.4
>
> ----------------------------------------------------------------
> % systemctl status postgresql.service -l
> ● postgresql.service - PostgreSQL database server
>    Loaded: loaded (/etc/systemd/system/postgresql.service; enabled;
> vendor preset: disabled)
>    Active: failed (Result: exit-code) since Tue 2015-07-28 11:50:01
> CEST; 19min ago
>
> Jul 28 11:49:56 poppy systemd[1]: Starting PostgreSQL database server...
> Jul 28 11:49:57 poppy postgresql-ctl[307]: FATAL:  42501: could not
> open log file "/storage/log/postgresql/postgresql-Tue.log": Permission
> denied
> Jul 28 11:49:57 poppy postgresql-ctl[307]: LOCATION:  logfile_open,
> syslogger.c:1160
> Jul 28 11:50:01 poppy postgresql-ctl[307]: pg_ctl: could not start server
> ----------------------------------------------------------------
>
> % ls -al /storage/log
> drwxr-xr-x 1 postgres postgres    0 Jul 28 11:29 postgresql/
>
>
> I have found a few entries on the web but with no clear fix. I even
> saw this was a bug.
>
> Can anyone tell me more and how to fix if it is possible?

What file system is that? ext4?

What do you get for:
  ls -l /storage/log/postgresql/postgresql-Tue.log
Perhaps the file exists and you don't have permissions to open it.

If not, does the following succeed as user "postgres":
  touch /storage/log/postgresql/postgresql-Tue.log
Do you get the same error message?

What do you get for:
  getfacl -p /storage/log/postgresql

 % getfacl -p /storage/log/postgresql
# file: /storage/log/postgresql
# owner: postgres
# group: postgres
user::rwx
group::rwx
other::r-x

  getfattr -d /storage/log/postgresql
Maybe some weird permissions or attributes are set.

Another idea: the file system could be mounted read-only.

No, it has been working for long until recently.  
% egrep " ro,|,ro " /proc/mounts does not return the path


Yours,
Laurenz Albe



--

Re: postgresql-ctl systemd failed: permission denied

From
CaT
Date:
On Tue, Jul 28, 2015 at 01:31:29PM +0200, arnaud gaboury wrote:
> On Tue, Jul 28, 2015 at 1:26 PM, Francisco Olarte <folarte@peoplecall.com>
> wrote:
>
> > Hi Arnaud...
> >
> > On Tue, Jul 28, 2015 at 12:13 PM, arnaud gaboury
> > <arnaud.gaboury@gmail.com> wrote:
> > > On Fedora 22
> > ...
> > > Jul 28 11:49:57 poppy postgresql-ctl[307]: FATAL:  42501: could not
> > > open log file "/storage/log/postgresql/postgresql-Tue.log": Permission
> > > denied
> > > Jul 28 11:49:57 poppy postgresql-ctl[307]: LOCATION:  logfile_open,
> > > syslogger.c:1160
> > > Jul 28 11:50:01 poppy postgresql-ctl[307]: pg_ctl: could not start server
> > > ----------------------------------------------------------------
> >
> > > % ls -al /storage/log
> > > drwxr-xr-x 1 postgres postgres    0 Jul 28 11:29 postgresql/
> >
> > May be stating the obvious, but can you try 'touch
> > /storage/log/postgresql/postgresql-Tue.log" as postgres to see it it
> > works.
>
> % ls -al /storage/log/postgresql
> total 0
> drwxrwxr-x 1 postgres postgres  36 Jul 28 13:27 ./
> drwxr-x--- 1 root     wheel    208 Jul 27 13:34 ../
> -rw-rw-r-- 1 postgres postgres   0 Jul 28 13:27 postgresql-Tue.log
>
> Still permission denied

If the logfile is being written to as the user postgres then .. is what
is preventing it. Only root and wheel have access so unless postgres is
in group wheel you need to

chmod o+x /storage/log at least.

--
  "A search of his car uncovered pornography, a homemade sex aid, women's
  stockings and a Jack Russell terrier."
    - http://www.dailytelegraph.com.au/news/wacky/indeed/story-e6frev20-1111118083480


Re: postgresql-ctl systemd failed: permission denied

From
arnaud gaboury
Date:


On Tue, Jul 28, 2015 at 1:37 PM, arnaud gaboury <arnaud.gaboury@gmail.com> wrote:


On Tue, Jul 28, 2015 at 1:31 PM, Albe Laurenz <laurenz.albe@wien.gv.at> wrote:
arnaud gaboury wrote:
> On Fedora 22
>
> % pg_ctl -V
> pg_ctl (PostgreSQL) 9.4.4
>
> ----------------------------------------------------------------
> % systemctl status postgresql.service -l
> ● postgresql.service - PostgreSQL database server
>    Loaded: loaded (/etc/systemd/system/postgresql.service; enabled;
> vendor preset: disabled)
>    Active: failed (Result: exit-code) since Tue 2015-07-28 11:50:01
> CEST; 19min ago
>
> Jul 28 11:49:56 poppy systemd[1]: Starting PostgreSQL database server...
> Jul 28 11:49:57 poppy postgresql-ctl[307]: FATAL:  42501: could not
> open log file "/storage/log/postgresql/postgresql-Tue.log": Permission
> denied
> Jul 28 11:49:57 poppy postgresql-ctl[307]: LOCATION:  logfile_open,
> syslogger.c:1160
> Jul 28 11:50:01 poppy postgresql-ctl[307]: pg_ctl: could not start server
> ----------------------------------------------------------------
>
> % ls -al /storage/log
> drwxr-xr-x 1 postgres postgres    0 Jul 28 11:29 postgresql/
>
>
> I have found a few entries on the web but with no clear fix. I even
> saw this was a bug.
>
> Can anyone tell me more and how to fix if it is possible?

What file system is that? ext4?

What do you get for:
  ls -l /storage/log/postgresql/postgresql-Tue.log
Perhaps the file exists and you don't have permissions to open it.

If not, does the following succeed as user "postgres":
  touch /storage/log/postgresql/postgresql-Tue.log
Do you get the same error message?

What do you get for:
  getfacl -p /storage/log/postgresql

 % getfacl -p /storage/log/postgresql
# file: /storage/log/postgresql
# owner: postgres
# group: postgres
user::rwx
group::rwx
other::r-x

  getfattr -d /storage/log/postgresql
Maybe some weird permissions or attributes are set.

Another idea: the file system could be mounted read-only.

No, it has been working for long until recently.  
% egrep " ro,|,ro " /proc/mounts does not return the path


It may be a systemd story. On another machine, with systemd 222, postgresql.service is starting fine. Same permisssions/settings on log directories
On the system with issue, Fedora 22 is running systemd 219.13 


Re: postgresql-ctl systemd failed: permission denied

From
arnaud gaboury
Date:


On Tue, Jul 28, 2015 at 1:43 PM, CaT <cat@zip.com.au> wrote:
On Tue, Jul 28, 2015 at 01:31:29PM +0200, arnaud gaboury wrote:
> On Tue, Jul 28, 2015 at 1:26 PM, Francisco Olarte <folarte@peoplecall.com>
> wrote:
>
> > Hi Arnaud...
> >
> > On Tue, Jul 28, 2015 at 12:13 PM, arnaud gaboury
> > <arnaud.gaboury@gmail.com> wrote:
> > > On Fedora 22
> > ...
> > > Jul 28 11:49:57 poppy postgresql-ctl[307]: FATAL:  42501: could not
> > > open log file "/storage/log/postgresql/postgresql-Tue.log": Permission
> > > denied
> > > Jul 28 11:49:57 poppy postgresql-ctl[307]: LOCATION:  logfile_open,
> > > syslogger.c:1160
> > > Jul 28 11:50:01 poppy postgresql-ctl[307]: pg_ctl: could not start server
> > > ----------------------------------------------------------------
> >
> > > % ls -al /storage/log
> > > drwxr-xr-x 1 postgres postgres    0 Jul 28 11:29 postgresql/
> >
> > May be stating the obvious, but can you try 'touch
> > /storage/log/postgresql/postgresql-Tue.log" as postgres to see it it
> > works.
>
> % ls -al /storage/log/postgresql
> total 0
> drwxrwxr-x 1 postgres postgres  36 Jul 28 13:27 ./
> drwxr-x--- 1 root     wheel    208 Jul 27 13:34 ../
> -rw-rw-r-- 1 postgres postgres   0 Jul 28 13:27 postgresql-Tue.log
>
> Still permission denied

If the logfile is being written to as the user postgres then .. is what
is preventing it. Only root and wheel have access so unless postgres is
in group wheel you need to

chmod o+x /storage/log at least.

 % ls -al postgresql 
total 0
drwxrwxr-x 1 postgres postgres  36 Jul 28 13:27 ./
drwxr-x--x 1 root     wheel    208 Jul 27 13:34 ../
-rw-rw-r-x 1 postgres postgres   0 Jul 28 13:27 postgresql-Tue.log*

% sudo systemctl status postgresql
...............
Jul 28 13:47:40 poppy systemd[1]: Started PostgreSQL database server.

Thank you so much. Again, permission story 


--
  "A search of his car uncovered pornography, a homemade sex aid, women's
  stockings and a Jack Russell terrier."
    - http://www.dailytelegraph.com.au/news/wacky/indeed/story-e6frev20-1111118083480



--