Strange permission errors in new PostgreSQL installation
- by Bart van Heukelom
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