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...
7 Answers 7
My locale settings were not properly configured when PostgreSQL was installed. Purging and reinstalling didn't help. I followed the instructions here and that did the trick for me.
Essential parts of the linked information reproduced below:
The problem showed itself in the following manner:
warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
...
are supported and installed on your system.
The first one was very easy to solve by executing:
#dpkg-reconfigure locales
...and choosing the preferred locales.
But after that PostgreSQL still refused to start. This is due to the fact that the installation process tried to create a cluster at installation time but because of the bad locales this wasn't done. So we have to redo this step by executing:
#pg_createcluster 9.3 main --start
(For the 9.3 version of PostgreSQL)
After that step PostgreSQL starts flawlessly via
#/etc/init.d/postgresql start
-
2Saved my life. It's really sucky that purging and reinstalling doesn't help even when the locale is rectified. This wasted 2hrs of my life :(Escher– Escher2016年04月10日 17:15:42 +00:00Commented Apr 10, 2016 at 17:15
-
In case
pg_createcluster
tells you that the cluster already exists you need to drop it first (this will erase any data in it, so make sure you have a backup):pg_dropcluster 9.3 main
.Florian Brucker– Florian Brucker2016年12月02日 11:16:10 +00:00Commented Dec 2, 2016 at 11:16
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.
-
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...Inactivated Account– Inactivated Account2014年03月28日 14:51:25 +00:00Commented Mar 28, 2014 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– tdg52014年04月04日 16:09:11 +00:00Commented Apr 4, 2014 at 16:09
-
1My PG9.3 did not start after reboot. Adding the line "unix_socket_directories='/var/run/postgresql'" to 9.3's postgresql.conf solved it. Thanksalfonx– alfonx2014年06月13日 05:15:51 +00:00Commented Jun 13, 2014 at 5:15
-
Thanks! Been working on this for a while, glad to find this nugget!user3652621– user36526212015年01月12日 22:01:31 +00:00Commented Jan 12, 2015 at 22:01
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.
This seems to fix the problem on Ubuntu:
Edit postgresql.conf:
unix_socket_directories='/var/run/postgresql
Now do service postgresql start
I ́m new in PSQL but I solved the problem by editing start.conf I had commented the "auto" setting to manage the server manually, but it needs a value: auto, manual or disabled.
EGD.
On my side the start up script is incorrect. The configuration files are installed in /etc/postgresql/9.3/main but the script /usr/share/postgresql-common/init.d-functions is searching in
for c in /etc/postgresql/"2ドル"/*; do
Replace this line with
for c in /etc/postgresql/"2ドル"/main; do
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!
-
Are you sure it is 9.3 running? The version number seems suspicious...András Váczi– András Váczi2013年10月04日 21:49:21 +00:00Commented Oct 4, 2013 at 21:49
-
@dezso sorry forgot to change the version # when I pasted in those commands...this is all at v9.3...Inactivated Account– Inactivated Account2013年10月04日 22:39:17 +00:00Commented Oct 4, 2013 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– user355812014年07月07日 15:26:58 +00:00Commented Jul 7, 2014 at 15:26 -
1This may be an workaround but clearly not a good solution. This one like is fixing the problem dba.stackexchange.com/a/91511/8099sorin– sorin2015年02月09日 17:08:56 +00:00Commented Feb 9, 2015 at 17:08
/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?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
.