Macos PostgreSQL server';Lion上的t关机(Mac OS 10.7)

Macos PostgreSQL server';Lion上的t关机(Mac OS 10.7),macos,postgresql,osx-lion,Macos,Postgresql,Osx Lion,我在Lion上使用自制软件安装了PostgreSQL。它启动正常,但不会关机。我试过: $ #started with $ pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start $ #tried stoping with $ pg_ctl -D /usr/local/var/postgres stop -m immediate waiting for server to shut down...

我在Lion上使用自制软件安装了PostgreSQL。它启动正常,但不会关机。我试过:

$ #started with
$ pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
$ #tried stoping with
$ pg_ctl -D /usr/local/var/postgres stop -m immediate
waiting for server to shut down................................... failed
pg_ctl: server does not shut down

我通过删除Launch Agent修复了此问题:

launchctl unload -w ~/Library/LaunchAgents/org.postgresql.postgres.plist
rm ~/Library/LaunchAgents/org.postgresql.postgres.plist

使用
-m immediate
关闭PostgreSQL Server是一种危险的做法, 因为“立即”模式将在不完全关闭的情况下中止所有服务器进程

这将导致重新启动时恢复运行。尝试使用参数
-m fast
关闭PostgreSQL。“快速”模式不会等待客户端断开连接,并将终止正在进行的在线备份。所有活动事务都将回滚,客户端将被强制断开连接

pg_ctl stop -D /usr/local/var/postgres -m fast 
有关pg_ctl的更多信息,请访问 这对我来说很有用
pg_ctl -D /Library/PostgreSQL/9.2/data/ start
pg_ctl-D/Library/PostgreSQL/9.2/data/start
pg_ctl-D/Library/PostgreSQL/9.2/data/stop


Source

如果您使用自制软件安装postgresql,那么正如Shevauns对Greg回答的评论所指出的,正确的过程是

launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
rm ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

问题是关于完全关闭,而是关于服务器关闭。无论如何,它已经修复,我已经更新了问题中的解决方案。这是正确的修复方法。它在OS X Snow Leopard上也对我有效。不过,您不需要删除plist,只需执行卸载。您可以通过发出:
$launchctl load重新启动它-w~/Library/LaunchAgents/org.postgresql.postgres.plist
@Greg:请添加您的解决方案作为答案并接受它,这样这些问题就不会出现在未回答的问题列表中。如果安装了homebrew,它可能看起来像这样:
~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
这对我也有效,except我的启动代理路径是:
~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
谢谢,这对我也很有用。我还必须使用Shevaunw发布的homebrew路径,这是什么导致这个问题首先发生的?关闭服务器的方式相当模糊。launchctl卸载+重新启动是从我这里形成的,不需要删除启动吗查根特
pg_ctl -D /Library/PostgreSQL/9.2/data/ stop
launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
rm ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist