【发布时间】:2021-03-16 14:41:02
【问题描述】:
我以前从未遇到过这样的问题 - 通常brew install postgres 工作正常,一切都很好。
我在这台机器上遇到过一些情况,我看到“Mac OSX 由于出现问题而重新启动”,通常有一个陈旧的 postmaster.pid 文件,我可以删除并重新启动 postgresql,一切都很好。
不再是 - 出了点问题,我不知道自制软件如何运作良好,无法解决此问题。
➜ ~ pg_ctl
zsh: command not found: pg_ctl
➜ ~ brew info postgresql
postgresql: stable 13.1 (bottled), HEAD
Object-relational database system
https://www.postgresql.org/
Not installed
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/postgresql.rb
License: PostgreSQL
==> Dependencies
Build: pkg-config ✔
Required: icu4c ✔, krb5 ✔, openssl@1.1 ✔, readline ✔
==> Options
--HEAD
Install HEAD version
==> Caveats
To migrate existing data from a previous major version of PostgreSQL run:
brew postgresql-upgrade-database
This formula has created a default database cluster with:
initdb --locale=C -E UTF-8 /usr/local/var/postgres
For more details, read:
https://www.postgresql.org/docs/13/app-initdb.html
To have launchd start postgresql now and restart at login:
brew services start postgresql
Or, if you don't want/need a background service you can just run:
pg_ctl -D /usr/local/var/postgres start
==> Analytics
install: 188,386 (30 days), 549,953 (90 days), 1,863,554 (365 days)
install-on-request: 180,714 (30 days), 528,971 (90 days), 1,789,016 (365 days)
build-error: 0 (30 days)
➜ ~ ls -ltra /usr/local/var
total 0
drwxrwxr-x 4 myhandle admin 128 Aug 21 2019 homebrew
drwxr-xr-x 4 myhandle admin 128 Apr 18 2020 log
drwxr-xr-x 15 root wheel 480 Dec 1 17:32 ..
drwxrwxr-x 4 root wheel 128 Dec 2 08:56 .
我在这里报告了这个问题 - https://discourse.brew.sh/t/postgress-install-fails-in-postinstall-step/6209
唯一的答案是“我在旧安装上运行了安装脚本”,这对我来说毫无意义 - 我尝试 brew postinstall postgres@12 想象这就是“旧安装”的意思,但我得到了完全相同的结果:
➜ ~ brew postinstall postgresql
==> Postinstalling postgresql
Warning: The post-install step did not complete successfully
You can try again using `brew postinstall postgresql`
➜ ~ brew postinstall postgresql@12
==> Postinstalling postgresql@12
Warning: The post-install step did not complete successfully
You can try again using `brew postinstall postgresql@12`
有什么想法吗?
更新:我开始觉得 /usr/local/var 和 /usr/local/bin 被我、自制软件或 postgres 桶弄糊涂了,因为错误消息与现实不符:
➜ ~ pg_ctl -D /usr/local/var/postgres start
pg_ctl: directory "/usr/local/var/postgres" does not exist
➜ ~ pg_ctl -D /usr/local/bin/postgres start
pg_ctl: could not open PID file "/usr/local/bin/postgres/postmaster.pid": Not a directory
➜ ~ mkdir /usr/local/bin/postgres
mkdir: /usr/local/bin/postgres: File exists
为什么 homebrew 建议从 /usr/local/var 运行 pg_ctl 但全新安装后这里不存在 postgres 进程?为什么我会在 /usr/local/bin 中找到它?然后,当我尝试从 bin/ 启动时,它要求 bin/ 中的 postmaster.pid 文件,但是 bin/ 中当然没有 postgres 目录,因为这些是进程本身...
【问题讨论】:
标签: postgresql macos homebrew