Ubuntu – I can’t get Postgres configured correctly

init.dpostgresqlUbuntu

I have spent quite a bit of time wrestling with this postgresql update, but I just can't quite get it configured correctly. I recently upgraded from 9.0 to 9.1, and I can't get Postgres 9.1 configured correctly.

I wanted it to start on start up, so I went and found the postgres file in etc/init.d and replaced it with the script that came with the source files (the linux script found in /contrib/start-scripts).

I only changed some of the stuff as follows:

# Installation prefix
prefix="/usr/local/pgsql"

# Data directory
PGDATA="/var/lib/postgresql/9.1/main"

# Who to run the postmaster as, usually "postgres".  (NOT "root")
PGUSER=postgres

# Where to keep a log file
PGLOG="/var/log/postgresql/9.1"

Then I installed and ran chkconfig --add postgresql. From what I could see, the rhN directories seemed to have been updated. But, unfortunately, Postgresqk didn't work, it does not start up, or at least, I don't think it starts up. Did I miss a step?

Also, when I run /usr/local/pgsql/bin/psql , the error says:

Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

Whereas running the old server's psql command when it's not running gives:

Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

What is that domain socket directory, and do I need to change it?

So, how do I get it to start up, if it helps, I am running Ubuntu 10.04 LTS.

Lastly, I know it's bad etiquette to ask multiple questions, but I figured it would be rude to make another question for a small question like this: I also want to make it so that if I enter a postgres command (e.g. psql) into the terminal, it should run the new postgres command, not the old one like it does now. Where do I change this?

Thanks for all your help.

Best Answer

Then I installed and ran chkconfig --add postgresql

You need also turn on it:

chkconfig postgresql on

Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

Did you start the postgresql?

$ ps -ef | grep postgre

What is that domain socket directory, and do I need to change it?

It contains the Unix domain socket which server is to listen for connections from the clients. You don't need to change (it can be done with unix_socket_directory).


Now, the problem is that, I still need to write out the full location of the directory when running a command. Hmm, how do I fix this.

Add it to the $PATH environment variable by inserting/appending the belows line to ~/.profile in your $HOME:

export PATH=$PATH:/usr/local/pgsql/bin

Make this take effect with:

$ source ~/.profile

or:

$ . ~/.profile

You can also add to /etc/profile for global usage.