22

I'm upgrading to Postgres 9.2.2 (from 9.1.4). When I try to upgrade the DBs using:

pg_upgrade -b /usr/local/Cellar/postgresql/9.1.4/bin -B /usr/local/Cellar/postgresql/9.2.2/bin -d /usr/local/var/postgres91 -D /usr/local/var/postgres

I get the following error message:

Performing Consistency Checks
-----------------------------
Checking current, bin, and data directories                 ok

There seems to be a postmaster servicing the old cluster.
Please shutdown that postmaster and try again.
Failure, exiting

I've trying stopping the server, but cannot get the upgrade command to work. How to I shutdown the old postmaster?

Luciano
  • 1,771
  • 3
  • 12
  • 8

4 Answers4

13

The postmaster.pid should be inside the previous version's usr/local/var folder. Simply renaming this file should solve the problem.

Luciano
  • 1,771
  • 3
  • 12
  • 8
6

In OS X Yosemite, after having installed PostgreSQL via Homebrew:

launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
rm ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
Sarah Vessels
  • 161
  • 1
  • 3
2

On most unix systems you'll find a init script in /etc/init.d which you can use to start, restart, reload or stop unix services.

e.g.

sudo /etc/init.d/postgresql stop

If this is not available you can use pg_ctl stop

e.g.

su - postgres
bash-3.1$ pg_ctl stop  # normal stop
bash-3.1$ pg_ctl stop -m s # smart stop
bash-3.1$ pg_ctl stop -m f # fast stop
bash-3.1$ pg_ctl stop -m i # immediate stop

More about pg_ctl

http://www.postgresql.org/docs/9.1/static/app-pg-ctl.html

EDIT If you still get the error and you are sure the postmaster is no longer running (check with sudo ps aux | grep "postmaster" - should return one line only) you still have the pid file after a unclean shutdown

Remove the pidfile e.g.

> sudo -u postgres mv /var/lib/postgres/data-9.1/postmaster.pid /tmp
2

On Ubuntu, stop the PostgreSQL service before performing the upgrade. This will stop all instances of postgres regardless of the versions installed.

service postgresql stop

scarver2
  • 121
  • 2