Postgresql server installation keeps failing due to postgresql-common error
Solution 1:
The problem was that postgres
user was not getting created.(Looks like an error with the package configuration scripts, not sure though) I then created the user manually using:
sudo useradd -r -s /bin/false postgres
The above command is to create a user, without home directory.(Courtesy)
After that I tried to install again, and it succeeded, without any problems.
N.B:
Some guys at the Ubuntu IRC channel helped me with the solution.
Update:
After restart postgresql
server was not accessible, so tried to restart postgresql
server, and got the following error:
$ sudo service postgresql restart
[sudo] password for username:
* Restarting PostgreSQL 8.4 database server
* The PostgreSQL server failed to start. Please check the log output:
2014-04-03 09:54:22 IST FATAL: could not create lock file "/var/run/postgresql/.s.PGSQL.5432.lock": Permission denied
[fail]
Solved it by editing the postgresql.conf
file. We have to look for the line that begins with that begins unix_socket_directory
and change it to read as the following:
unix_socket_directory='/tmp'
Now start the postgresql server using:
sudo service postgresql start
The problem was because
the default directory for lock files in Ubuntu was changed to /var/run/postgresql, which is not world-writable. However, simply changing write permissions on the directory does not work; they are reset when the default init script runs.
Courtesy: http://eclecticquill.com/2013/02/26/postgresql-fails-to-start-on-ubuntu-12-10/
Got more info from this link:
But if you are trying a to run an instance of the PostgreSQL server owned by your local user, you need to ensure that the unix socket directory is writable by the user that owns the PostgreSQL server process. Try:
unix_socket_directory='/tmp'
In short:
We had to do that because we created the postgres
user manually.