Postgres used in Ubuntu 12.04

5,214

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
Share:
5,214

Related videos on Youtube

Douglas Kastle
Author by

Douglas Kastle

Updated on September 18, 2022

Comments

  • Douglas Kastle
    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 resembles pg_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
    Calab about 12 years
    Yeah, 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
    Calab about 12 years
    Hm, I think that being more specific about the "isn't working" bit would go a long way to making me understand the problem. :)
  • Calab
    Calab about 12 years
    Sorry 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
    Calab about 12 years
    OK. :) 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 running updatedb. Both commands have pretty informative manpages.
  • Calab
    Calab about 12 years
    I 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 ran updatedb it worked fine but didn't give me any information I could use.
  • Admin
    Admin about 12 years
    Ok 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
    Admin about 12 years
    If 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
    Admin about 12 years
    Oh 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 commands sudo /etc/init.d/postgresql start and sudo /etc/init.d/postgresql restart withe no complaint (and no comments, positive or negative) but still not running as a result
  • Admin
    Admin about 12 years
    Yes, 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
    Admin about 12 years
    Did 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
    Admin about 12 years
    Grr, 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
    Admin about 12 years
    You do have the server installed, not just the client?
  • Douglas Kastle
    Douglas Kastle about 12 years
    This 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
    Douglas Kastle about 12 years
    I 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é
    Daniel Vérité about 12 years
    If 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
    Douglas Kastle about 12 years
    Yes you were correct, postgres did not install properly, I'll detail my fix above
  • Douglas Kastle
    Douglas Kastle about 12 years
    Oh and thanks for the advice, sometimes you get a little too close to a problem to see how to fix it.
  • Geoff
    Geoff almost 12 years
    Thanks! This fixed my issues on an EC2 default ubuntu 12.04 instance.
  • Jeremy
    Jeremy about 11 years
    I 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.