Postgres used in Ubuntu 12.04
Solution 1
It turns out that postgres has an error during installation on the AWS version of ubuntu 12.04 I was getting a whole lot of these warnings
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
Which when postgres tries to install
Error: The locale requested by the environment is invalid.
Error: could not create default cluster. Please create it manually with
pg_createcluster 9.1 main --start
or a similar command (see 'man pg_createcluster').
So I found this link, Perl warning Setting locale failed unter Debian, which suggest setting the appropriate environment variables. Once set and the pg_createcluster command is run the postgres server was up and running.
Solution 2
Try removing postgresql completely
sudo apt-get purge postgresql postgresql-*
Check that you installed the locale files, which sometimes gives errors on Ubuntu server
sudo apt-get install language-pack-en-base
(replace en
with your language's code)
Now install postgresql once more and check that there aren't any errors in the output
sudo apt-get install postgresql-9.1
Solution 3
From the description it looks like the server package, is not installed.
You should run:
sudo apt-get install postgresql-9.1
Related videos on Youtube
Douglas Kastle
Updated on September 18, 2022Comments
-
Douglas Kastle over 1 year
I am trying to get django running on an ubuntu 12.04 release using postgres (clean install). To get it running it used to be that you would have to edit the
/etc/postgresql/9.1/main/pg_hba.conf
file. However when I look at this release there is no/etc/postgresql
directory only/etc/postgresql-common
and there doesn't appear to be a file that resemblespg_hba.conf
under that directory.Additionally while I have you ear this is the change I wanted to make:
# change local all all ident # to local all all trust
is this correct, I think I saw that it should be changed to peer (not trust), if correct, why?
Update: This is the version of postgres
psql (PostgreSQL) 9.1.3
-
Calab about 12 yearsYeah, I have done all that, my setup was all working on the 11.04 version of ubuntu (I added the user and the db, and that part still works) it just connecting django through to the postgres database isn't working the same way. Bare in mind if you do an upgrade of ubuntu the old will be there and working, it is in the clean install I am getting problems
-
Calab about 12 yearsHm, I think that being more specific about the "isn't working" bit would go a long way to making me understand the problem. :)
-
Calab about 12 yearsSorry dude not one of my more descriptive bug reports. What i was trying to say is that I can't find the pg_hba.conf file to edit, that's it. As a result I can't make the changes I know I need to make to make postgres work with django (that I know, which is probably not a lot), again bare in mine it is in a clean install, I have upgraded machines that still work.
-
Calab about 12 yearsOK. :) I don't think that the pg_hba.conf needs changing because of an ubuntu upgrade, but still, if that's your question then whenever you're looking for a file just
locate filename
in a terminal. Assumes you are diligently runningupdatedb
. Both commands have pretty informative manpages. -
Calab about 12 yearsI tried to do a recursive find of
pg_hba.conf
from/etc
down, no luck, but I think that was a waste of time because there is no/etc/postgresql
directory any more, just/etc/postgresql-common
I ranupdatedb
it worked fine but didn't give me any information I could use. -
Admin about 12 yearsOk that is begining to make sense a little bit. I try to add a user, and is asks for for a password twice and then asks me if I want to make that user an admin, to which I say yes (all as sudo) but at the end it complains
createuser: could not connect to database postgres: could not connect to server: No such file or directory
I'm not too sure what's happening here any more, like a broken record, it is a clean install this used to work. -
Admin about 12 yearsIf it's running, you should be able to find it. If it's not running you should first start it, obviously. The other way would be to look in /etc/init.d/post* and see what that does. (I installed pg from source and I don't know how the ubuntu vanilla version is configured and packaged) Packages sometimes make weird choices about location of configfiles and data directories (brr: /var ... )
-
Admin about 12 yearsOh and in answer to your question this is what I get where I run your command
ubuntu 13778 0.0 0.1 8068 652 pts/0 S+ 13:47 0:00 grep --color=auto postmaster
seems to suggest that psostgres isn't even running, but I have run the commandssudo /etc/init.d/postgresql start
andsudo /etc/init.d/postgresql restart
withe no complaint (and no comments, positive or negative) but still not running as a result -
Admin about 12 yearsYes, the problem seems to relate to the fact that postgres is not running, even though all the hooks for setup suggest that it should be, and doesn't actually complain when it is failing
-
Admin about 12 yearsDid the installer add a startup file to /etc/init.d/postg* ? try to execute that startup script with
sudo /etc/init.d/postgresql start
. (the exact name of the script may vary) -
Admin about 12 yearsGrr, rebooted system, and after ran the above command, then tried to access the postgres server no luck. I think it has been inferred so far but just so we are clear this is on AWS (as far as I know it should not make any difference) Also when I tried to run the above command there were no complaints when asked to execute, just nothing happened either.
-
Admin about 12 yearsYou do have the server installed, not just the client?
-
Douglas Kastle about 12 yearsThis is the command I used:
sudo apt-get install -y postgresql
and this is what it says when I run it again:postgresql is already the newest version.
-
Douglas Kastle about 12 yearsI had a check and yes it is installed (I ran your command), besides I thought that
sudo apt-get install postgresql
should pick up the most up to date version regardless of number -
Daniel Vérité about 12 yearsIf the postgresql-9.1 package is installed and /etc/postgresql has not been created, something must have went wrong during its installation. Is there also no /var/log/postgresql directory containing log files? Also no /var/lib/postgresql/9.1 (data directory)?
-
Douglas Kastle about 12 yearsYes you were correct, postgres did not install properly, I'll detail my fix above
-
Douglas Kastle about 12 yearsOh and thanks for the advice, sometimes you get a little too close to a problem to see how to fix it.
-
Geoff almost 12 yearsThanks! This fixed my issues on an EC2 default ubuntu 12.04 instance.
-
Jeremy about 11 yearsI had this same issue last week. Some additional info, as it appears the current package version (postgresql-9.1=9.1.9-0ubuntu12.04) doesn't even show the error messages. I had Same symptoms as question,
/etc/postgresql/<version>
didn't exist neither did/var/lib/postgresql/<version>
, but package reported as installed. I wound up installing the next previous version (9.1.3) which did show the error messages, but even with that I had to manually initialize the database and generate a server.crt. Fixing the locale and encoding environment variables would have been easier.