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...
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 thepg_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 defaultstart.conf
file itself...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"