升级到 Postgres 9.2 时无法关闭旧的 postmaster

Luc*_*ano 14 postgresql postgresql-9.2

我正在升级到 Postgres 9.2.2(从 9.1.4)。当我尝试使用以下方法升级数据库时:

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
Run Code Online (Sandbox Code Playgroud)

我收到以下错误消息:

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
Run Code Online (Sandbox Code Playgroud)

我正在尝试停止服务器,但无法使升级命令起作用。如何关闭旧的邮政局长?

Luc*_*ano 11

postmaster.pid应该是以前版本的内部usr/local/var文件夹。只需重命名此文件即可解决问题。


小智 5

在 OS X Yosemite 中,通过 Homebrew 安装 PostgreSQL 后:

launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
rm ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
Run Code Online (Sandbox Code Playgroud)


Mic*_*eim 1

在大多数 UNIX 系统上,您会发现一个 init 脚本,/etc/init.d可用于启动、重新启动、重新加载或停止 UNIX 服务。

例如

sudo /etc/init.d/postgresql stop
Run Code Online (Sandbox Code Playgroud)

如果这不可用,您可以使用pg_ctl stop

例如

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
Run Code Online (Sandbox Code Playgroud)

更多关于pg_ctl

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

编辑 如果您仍然收到错误并且您确定 postmaster 不再运行(检查sudo ps aux | grep "postmaster"- 应该仅返回一行),则在不干净的关闭后您仍然拥有 pid 文件

删除pid文件例如

> sudo -u postgres mv /var/lib/postgres/data-9.1/postmaster.pid /tmp
Run Code Online (Sandbox Code Playgroud)