Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Just upgraded Ubuntu to latest version but now I have two instance of Postgres.

8.4 and 9.1

The problem is that I do not know on what port the second one is running ?

How can I detect on what port is running....

IF i run cristi@cristi-hp:/usr/share/postgresql-common$ sudo -u postgres psql psql (8.4.8) Type "help" for help.

how can I use psql for 9.1 ?

both appear to run: cristi@cristi-hp:/usr/share/postgresql-common$ sudo /etc/init.d/postgresql start [sudo] password for cristi: * Starting PostgreSQL 8.4 database server [ OK ] * Starting PostgreSQL 9.1 database server

Thanks...

share|improve this question
add comment

2 Answers

up vote 4 down vote accepted

Ubuntu being a Debian-based system has the ability to run multiple instances of Postgres as you are seeing. Generally unless configured otherwise the first instance started will have the default Postgres port and each subsequent instance will take the next higher port if it is available. These ports can be defined in the config files under /etc/postgresql/<version>/<cluster>/ so that they don't change should you need to but I'd actually need to. In fact a cursory look at the /etc/init.d/postgresql would also show you that you can set environment variables through /etc/postgresql/<version>/<cluster>/environment.

The package managers were even nice enough to include /usr/share/doc/postgresql-common/README.Debian.gz which has a section that quickly explains how the cluster management is handled including the pg_lsclusters command which will give you the Postgres version and port number along with other nice details about each configured cluster.

To answer question in comment regarding stopping an instance... You can edit the start.conf file under /etc/postgresql/<version>/<cluster>/ and change it from auto to disabled or manual. To quote the default start.conf file itself...

# Automatic startup configuration
# auto: automatically start/stop the cluster in the init script
# manual: do not start/stop in init scripts, but allow manual startup with
#         pg_ctlcluster
# disabled: do not allow manual startup with pg_ctlcluster (this can be easily
#           circumvented and is only meant to be a small protection for
#           accidents).
share|improve this answer
    
Thank you ! One more thing I would like to know...how can i remove the automated startup of one of them...i do not need both up and running when i start my computer –  Cris Oct 22 '11 at 14:50
add comment

If you just want to find the port and/or layout of what's currently running, all you need to do is run "pg_lsclusters"

rtreat@xdw1:~$ pg_lsclusters
Version Cluster   Port Status Owner    Data directory                     Log file
9.0     data1     5432 online postgres /var/lib/postgresql/9.0/data1      /var/log/postgresql/postgresql-9.0-data1.log
9.0     data2     5488 online postgres /var/lib/postgresql/9.0/data2      /var/log/postgresql/postgresql-9.0-data2.log
9.0     data3     5499 online postgres /var/lib/postgresql/9.0/data3      /var/log/postgresql/postgresql-9.0-data3.log
9.0     sanitize1 6544 online postgres /var/lib/postgresql/9.0/sanitize1  /var/log/postgresql/postgresql-9.0-sanitize1.log
9.0     sanitize2 6543 online postgres /var/lib/postgresql/9.0/sanitize2  /var/log/postgresql/postgresql-9.0-sanitize2.log
share|improve this answer
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.