Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Starting PostgreSQL server failed after modification of postgresql.conf using the sudo command

I wanted to change the "shared_buffers" parameter in my postgresql.conf file.

The problem is that I used the sudo command and it gave the ownership to the root.

-rw-rw-rw-   1 root root  13661 Mar 14 15:36 postgresql.conf

Then I used the following command to get back the ownership to postmaster :

sudo chown postgres:postgres /var/lib/pgsql/data/postgresql.conf

So I tried the command :

postgres -D /var/lib/pgsql/data

I was badly surprised to still get the following error message

postgres cannot access the server configuration file "/var/lib/pgsql/data/postgresql.conf": Permission denied

below id the result of the "ls" command in the directory realted to postgreSQL :

sudo ls -l /var/lib/pgsql/data/
total 208
drwx------  19 postgres postgres   4096 Mar 13 17:23 base
drwx------   2 postgres postgres   4096 Mar 14 14:30 global
drwx------   2 postgres postgres   4096 Mar  5 14:26 pg_clog
-rw-------   1 postgres postgres   3365 Mar  1  2006 pg_hba.conf
-rw-------   1 postgres postgres   3182 Mar  1  2006 pg_hba.conf.old
-rw-------   1 postgres postgres   1460 Feb 24  2006 pg_ident.conf
drwx------   2 postgres postgres 139264 Mar 14 00:00 pg_log
drwx------   4 postgres postgres   4096 Feb 24  2006 pg_multixact
drwx------   2 postgres postgres   4096 Mar 14 10:42 pg_subtrans
drwx------   2 postgres postgres   4096 Feb 24  2006 pg_tblspc
drwx------   2 postgres postgres   4096 Feb 24  2006 pg_twophase
-rw-------   1 postgres postgres      4 Feb 24  2006 PG_VERSION
drwx------   3 postgres postgres   4096 Mar 14 14:30 pg_xlog
-rw-rw-rw-   1 postgres postgres  13661 Mar 14 15:36 postgresql.conf
-rw-------   1 postgres postgres     49 Jan  2 17:15 postmaster.opts

If someone have an idea of could be the way to fix this problem.

Thanks in advance.

Fred

like image 682
Fred FLECHE Avatar asked Mar 14 '12 15:03

Fred FLECHE


1 Answers

Check how is SELinux running:

# sestatus

If it is in enforcing mode check the log:

# less /var/log/audit/audit.log

If you find SELinux blocking then temporarily disable SELinux just to confirm it is the culprit:

# setenforce 0

Now try to start the server. If it works then reenable SELinux:

# setenforce 1

Search for how to restore SELinux settings for that file.

like image 192
Clodoaldo Neto Avatar answered Nov 15 '22 05:11

Clodoaldo Neto