0

A freshly installed PostgreSQL (with configuration overwritten) won't start:

$ sudo service postgresql start
 * Starting PostgreSQL 9.1 database server
 * Error: could not read /etc/postgresql/9.1/main/postgresql.conf: Permission denied

Looks like it should be able to read it though:

$ ls -l postgresql.conf 
-rw------- 1 postgres postgres 19450 2012-06-14 10:07 postgresql.conf

But fine, I'll add chmod +r it to test if that works.

$ sudo chmod +r postgresql.conf 
$ sudo service postgresql start
 * Starting PostgreSQL 9.1 database server
 * The PostgreSQL server failed to start. Please check the log output:
Error: Could not open log file /var/log/postgresql/postgresql-9.1-main.log

Huh?

$ ls -l /var/log/postgresql/
total 4
-rw-r----- 1 postgres adm 827 2012-06-14 10:07 postgresql-9.1-main.log

I don't get it. What can be wrong here? This used to work before.

Can I maybe monitor what process attempts to open the file?


It's Ubuntu 11.10 on EC2, using Chef. For completeness, here's the recipe:

# Install PostgreSQL
package "postgresql-9.1"

# Stop server
service "postgresql" do
    action :stop
end

# Overwrite configuration (setting data dir)
template "/etc/postgresql/9.1/main/postgresql.conf" do
    source "postgresql-conf.erb"
    owner "postgres"
    group "postgres"
end

# Start server
service "postgresql" do
    action :start
end
2
  • 1
    First, please do not go randomly shotgunning permissions - that's NOT how you fix something, it's how you create an even bigger mess. Instead, proceed logically with troubleshooting: Postgres can not read/write log files it used to (and should) have access to. Why? Possible reasons: (1) Is the server tryng to start/run as the postgres user? (Check the startup scripts) ; Are there multiple users named postgres with different UIDs? (check /etc/passwd) ; etc…
    – voretaq7
    Jun 14, 2012 at 14:48
  • @voretaq7 I know, that was just a quick fix to try to get it to work. Once it works, I have time to figure out why exactly it doesn't work. Jun 14, 2012 at 15:34

1 Answer 1

2

The custom configuration file (postgresql.conf) pointed to a data directory that did not exist. Of course, that's a problem (which I solved by setting up the data directory), but it has nothing to do with the error printed. Once again, PostgreSQL errors not so helpful.

Update:

I got the same error when the data directory existed, but with incorrect ownership.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .