Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I have successfully installed PostgreSQL 9.3 from the APT repository on 2 VM's running Ubuntu 12.04 and 13.04...however, I cannot get it to install properly on my host machine running Ubuntu 12.04.

The install (this time) seems to have gone ok, but perhaps there is an error I'm not understanding:

* No PostgreSQL clusters exist; see "man pg_createcluster"
Setting up postgresql-9.3 (9.3.0-2.pgdg12.4+1) ...
Creating new cluster 9.3/main ...
  config /etc/postgresql/9.3/main
  data   /var/lib/postgresql/9.3/main
  locale en_US.UTF-8
  port   5432
update-alternatives: using /usr/share/postgresql/9.3/man/man1/postmaster.1.gz to provide /usr/share/man/man1/postmaster.1.gz (postmaster.1.gz) in auto mode.

So I then try to add myself as a PostgreSQL user, but I get this:

createuser: could not connect to database postgres: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

I cannot see PostgreSQL running in system monitor, and there is no file in the /var/run/postgresql/ folder...completely empty.

EDIT: On the VM's, there is a file in /var/run/postgresql/ called 9.3-main.pid

There is nothing on the host machine log file located /var/log/postgresql

So... what's going on here that isn't going on in my VM's? Like I said, the other installations on the VM's, including PostGIS and PGAdmin came in perfect...no idea why this host machine isn't going through...

share|improve this question
    
Do you actually have a /var/run/postgresql directory? At one stage after succesful installation that folder was missing on my machine. What does the config say about which directory it should be using? –  Colin 't Hart Oct 2 '13 at 20:55
    
@Colin'tHart I do have that directory...however there is nothing in it...in the VM's, there is a file created called 9.3-main.pid Where would I find that config information? –  mapBaker Oct 2 '13 at 21:01
    
postgresql.conf in the config directory, which according to above, is /etc/postgresql/9.3/main. You should also look in the log files, probably in /var/log/postgresql. –  Colin 't Hart Oct 2 '13 at 21:10
    
@Colin'tHart The log file is empty...The config file - and I think this is what you're after - says # If external_pid_file is not explicitly set, no extra PID file is written. external_pid_file = '/var/run/postgresql/9.3-main.pid' –  mapBaker Oct 2 '13 at 21:16
    
Is there a socket file in that directory, or is it really completely empty? –  Colin 't Hart Oct 2 '13 at 21:37
show 3 more comments

3 Answers

up vote 3 down vote accepted

I've had several problems with the sockets file, in your case /var/run/postgresql/.s.PGSQL.5432

make sure /var/run/postgresql directory exists and is writable before starting postgresql for more info see this discussion.

also, when connecting use -h flag:

psql -h localhost 

and see if that resolves it.

share|improve this answer
add comment

Hopefully you've already solved this issue, but I'm running into a similar problem that seems to have a different source, and maybe my experience will help if you're still having a problem.

My problem with 9.3 on Ubuntu relates to the socket dir being a transient dir in /run. Basically, the init.d script is supposed to take care of creating the socket dir in /run/postgresql if it doesn't exist during the start action. This is always going to be the state of things after a reboot.

The problem is, however, that the init.d script will exit before executing the start action if the socket dir doesn't exist. This is because the call to pg_lsclusters will fail w/o the socket dir, which in turn prevents the start action from ever creating the socket dir.

I haven't figured out what the best solution is, but if I relocate the logic for creating the socket dir from the start action to before the call to pg_lsclusters, I am able to start the server after reboot without a problem.

Here is the portion of the start action that handles creating the socket dir:

# create socket directory
if [ -d /var/run/postgresql ]; then
  chmod 2775 /var/run/postgresql
else
  install -d -m 2775 -o postgres -g postgres /var/run/postgresql
  [ -x /sbin/restorecon ] && restorecon -R /var/run/postgresql || true
fi

I'll post an update if the root cause of this becomes clear to me, because this clearly can't be the expected behavior.

ADDENDUM:

I think the reason I was running into this problem is because I didn't have a good value configured for unix_socket_directories. On 9.2 this configuration option used to be unix_socket_directory, which I removed rather than switching to unix_socket_directories. Since I set a value for unix_socket_directories, I haven't had any issues with the server starting.

share|improve this answer
    
thank you @tdg5!!! I haven't resolved this, but I think it comes down to several bad installs on my machine. Installing from the PostgreSQL Apt Repository on a fresh install of ubuntu solved my problems... –  mapBaker Mar 28 at 14:51
3  
@mapBaker - I updated my response to include the root cause of the PG 9.3 startup problem in my particular situation. Perhaps it will be helpful for you as well. –  tdg5 Apr 4 at 16:09
    
My PG9.3 did not start after reboot. Adding the line "unix_socket_directories='/var/run/postgresql'" to 9.3's postgresql.conf solved it. Thanks –  alfonx Jun 13 at 5:15
add comment

All,

after some digging, I found (a) solution here:

http://ubuntuforums.org/showthread.php?t=869080

Which contained these instructions:

Run in terminal:

sudo mkdir -p /usr/local/pgsql/data
sudo chown -R postgres:postgres /usr/local/pgsql/
sudo su - postgres
cd /usr/lib/postgresql/9.3/bin/
./initdb -D /usr/local/pgsql/data
./postgres -D /usr/local/pgsql/data

Now my server is up and running!!!

EDIT: after a restart, the server is still not running...

Any thoughts as to why I needed to run this are appreciated!

share|improve this answer
    
Are you sure it is 9.3 running? The version number seems suspicious... –  dezso Oct 4 '13 at 21:49
    
@dezso sorry forgot to change the version # when I pasted in those commands...this is all at v9.3... –  mapBaker Oct 4 '13 at 22:39
    
You might need to specify the port. The default port is being used by your old installation of postgres. Your new installation is using port 5433 most likely, but this is something you can check for sure by reading the postgresql config file: /etc/postgresql/9.3/main/postgresql.conf –  user35581 Jul 7 at 15:26
    
Please use the edit link on your question to add additional information. The Post Answer button should be used only for complete answers to the question. –  Max Vernon Jul 8 at 13:03
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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