Re: Postgresql fails to start?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Dianne Yumul <dianne(at)wellsgaming(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Postgresql fails to start?
Date: 2005-06-07 17:58:35
Message-ID: 15103.1118167115@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Dianne Yumul <dianne(at)wellsgaming(dot)com> writes:
> # rm -f pgstartup.log
> # /etc/rc.d/init.d/postgresql start
> /usr/bin/chcon: can't apply partial context to unlabeled file
> /home/postgres/pgstartup.log
> Starting postgresql service: [FAILED]
> # ps aux | grep postmaster
> postgres 10470 34.1 0.6 112404 5248 pts/0 S 09:24 0:02
> /usr/bin/postmaster -p 5432 -D /home/postgres/data
> root 10480 0.0 0.0 3756 668 pts/0 R+ 09:24 0:00 grep
> postmaster

Odd. I don't see any reason that you'd not get the OK message, given
that the postmaster started. I've seen reports of that before, eg,
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=152931
but it's far from clear why some people see this and some don't.
In any case I suspect that the FAILED message is unrelated to the chcon
problem.

> ls -Z /home/postgres/pgstartup.log
> Gives:
> Sorry, this option can only be used on a SELinux kernel.

> But after setting selinux to permissive mode, ls -Z
> /home/postgres/pgstartup.log gives:

> -rw------- postgres postgres system_u:object_r:postgresql_log_t
> /home/postgres/pgstartup.log

There is something very flaky about either your kernel or your selinux
utilities. Are you up-to-date on kernel version? (Let's see ... my
FC3 machine is at 2.6.11-1.14_FC3, and I think I may be behind ...)

I tried to reproduce the problem by doing what the initscript does,
without any success:

[tgl(at)rh1 ~]$ sudo mkdir /home/postgres
[tgl(at)rh1 ~]$ sudo chown postgres:postgres /home/postgres
[tgl(at)rh1 ~]$ PGLOG=/home/postgres/pgstartup.log
[tgl(at)rh1 ~]$ sudo touch "$PGLOG"
[tgl(at)rh1 ~]$ sudo ls -Z $PGLOG
-rw-r--r-- root root root:object_r:user_home_t /home/postgres/pgstartup.log
[tgl(at)rh1 ~]$ sudo chown postgres:postgres "$PGLOG"
[tgl(at)rh1 ~]$ sudo chmod go-rwx "$PGLOG"
[tgl(at)rh1 ~]$ sudo /usr/bin/chcon -u system_u -r object_r -t postgresql_log_t "$PGLOG"
[tgl(at)rh1 ~]$ sudo ls -Z $PGLOG
-rw------- postgres postgres system_u:object_r:postgresql_log_t /home/postgres/pgstartup.log
[tgl(at)rh1 ~]$ uname -r
2.6.11-1.14_FC3
[tgl(at)rh1 ~]$ rpm -qf /usr/bin/chcon
coreutils-5.2.1-31

so I suspect that what you are running into is either a kernel bug or a
chcon bug; it'd be worth making sure both kernel and coreutils are up to
date. If you try the sequence by hand, what do you get?

>> Oh, and is the message really complaining
>> about /home/postgres/pgstartup.log? AFAICS the initscript should be
>> messing with /var/lib/pgsql/pgstartup.log.

> Sorry, I forgot to mention that I changed some of the defaults via
> /etc/sysconfig/pgsql/postgresql file, which looks like this:
> PGDATA=/home/postgres/data
> PGLOG=/home/postgres/pgstartup.log

That is going to give you some problems if you have SELinux in
enforcement mode, because the standard policy will disallow the postgres
daemon from writing anywhere under /home. You can fix this by fooling
around with the policy and/or manually relabeling the database directory
and files, but the path of least resistance is probably to leave the
database directory in the normal place.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Michael Fuhr 2005-06-07 18:02:54 Re: Password authentication failed for user
Previous Message Martijn van Oosterhout 2005-06-07 17:51:12 Re: Issue with adding ORDER BY to EXCEPT.