警告:If you delete postmaster.pid without making sure there are really no 100 processes running you, could permanently corrupt your database.(如果邮局主管已退出,PostgreSQL应自动将其删除.).
解决方案:这解决了问题——我删除了这个文件,然后一切都正常了!
/usr/local/var/postgres/postmaster.pid
--
下面是我如何理解为什么需要删除这些内容的.
我使用以下命令查看是否有任何PG进程正在运行.对我来说没有,我甚至无法启动PG服务器:
ps auxw | grep post
我搜索了文件.s、 PGSQL.5432这是在上面的错误消息.我使用了以下命令:
sudo find / -name .s.PGSQL.5432 -ls
在搜索了我的整个电脑后,这没有显示任何内容,所以文件不存在,但显然psql
"希望"或"认为它在那里".
我查看了服务器日志(log),发现以下错误:
cat /usr/local/var/postgres/server.log
在服务器日志(log)的末尾,我看到了以下错误:
FATAL: pre-existing shared memory block (key 5432001, ID 65538) is still in use
HINT: If you're sure there are no old server processes still running, remove the shared memory block or just delete the file "postmaster.pid".
按照错误消息中的建议,我删除了邮局主管.pid文件与服务器位于同一目录中.日志(log)这解决了问题,我可以重新启动.
所以,似乎我的macbook冻结和硬重启导致Postgres认为即使在重启后,它的进程仍在运行.删除此文件已解决.希望这对其他人有帮助!很多人都有类似的问题,但大多数答案都与文件权限有关,而我的情况则不同.