2

I'm attempting to build a box via Fabric on Openstack. Part of the install involves installing and running PostgreSQL.

This command works fine:

$ sudo service postgresql initdb 

This command fails:

$ sudo service postgresql start

Log output of failure shows no issues when I run this command:

$ cat /var/lib/pgsql/pgstartup.log  

This command shows the following messages:

$ cat /var/lib/pgsql/data/pg_log/postgresql-Wed.log

LOG: could not open configuration file "/var/lib/pgsql/data/pg_hba.conf": Permission denied FATAL: could not load pg_hba.conf

My user while executing these commands has the following groups:

vagrant, wheel

My user is in the sudoers list under /etc/sudoers with these permissions:

vagrant  ALL=(ALL) NOPASSWD: ALL

perms on pgsql:

[root@integration ~]# ls -ltr /var/lib/pgsql/
total 12
drwx------.  2 postgres postgres 4096 Sep 13  2012 backups
-rw-------.  1 postgres postgres 1152 Jun 19 20:17 pgstartup.log
drwx------. 12 postgres postgres 4096 Jun 19 20:19 data

and sub dir data:

[root@integration ~]# ls -ltr /var/lib/pgsql/data/
total 76
-rw-------. 1 postgres postgres     4 Jun 19 20:17 PG_VERSION
drwx------. 2 postgres postgres  4096 Jun 19 20:17 pg_twophase
drwx------. 2 postgres postgres  4096 Jun 19 20:17 pg_tblspc
drwx------. 2 postgres postgres  4096 Jun 19 20:17 pg_stat_tmp
drwx------. 4 postgres postgres  4096 Jun 19 20:17 pg_multixact
-rw-------. 1 postgres postgres 16886 Jun 19 20:17 postgresql.conf
-rw-------. 1 postgres postgres  1631 Jun 19 20:17 pg_ident.conf
drwx------. 3 postgres postgres  4096 Jun 19 20:17 pg_xlog
drwx------. 2 postgres postgres  4096 Jun 19 20:17 pg_subtrans
drwx------. 2 postgres postgres  4096 Jun 19 20:17 pg_clog
drwx------. 5 postgres postgres  4096 Jun 19 20:17 base
drwx------. 2 postgres postgres  4096 Jun 19 20:17 global
-rw-------. 1 postgres postgres   241 Jun 19 20:17 pg_hba.conf
drwx------. 2 postgres postgres  4096 Jun 19 20:17 pg_log
-rw-------. 1 postgres postgres    57 Jun 19 20:19 postmaster.opts
1

I would try the following since it seems like you're attempting to start the PostgreSQL service with vagrant's credentials even though you're doing a sudo. This will just confirm that you can in fact start PostgreSQL.

$ sudo su -
$ service postgresql start

If you can start the service using the above commands then something is up with your vagrant account's ability to sudo and start the service.

  • as root user it still fails, error in pgstartup.log is "runuser: cannot set groups: Operation not permitted" – mconlin Jun 20 '13 at 13:06
  • this did get me on the correct path of digging into perms more, thank you! see answer below. – mconlin Jun 20 '13 at 13:42
  • @mconlin - Glad you solved you issue. Can you please mark your answer as the excepted once the timeout passes? That way others will know that you're issue's been resolved. – slm Jun 20 '13 at 13:46
1

This turned out to be an selinux issue. I disabled it and was well. Full config below.

For those of you that arent up on selinux (like me until today) the config can be found in:

 /etc/selinux/config

It can also be turned off temporarily like this:

echo 0 > /selinux/enforce

Full config

[root@integration selinux]# cat config 
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#   enforcing - SELinux security policy is enforced.
#   permissive - SELinux prints warnings instead of enforcing.
#   disabled - SELinux is fully disabled.
SELINUX=enforcing
# SELINUXTYPE= type of policy in use. Possible values are:
#   targeted - Only targeted network daemons are protected.
#   strict - Full SELinux protection.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.