我正在努力解决 mac Big Sur 上 postgres 的启动错误。
LaunchAgents
的符号链接退出为 homebrew.mxcl.postgresql.plist
但是当我跑步时
postgres -D /usr/local/var/postgres
我得到输出
FATAL: could not open directory "pg_notify": No such file or directory
LOG: database system is shut down
有人知道这个问题的解决方案吗?
我也遇到过同样的现象。 卸载postgresql,删除
/usr/local/var/postgres/
目录并重新安装即可解决问题。
$ ls /usr/local/var/postgres/
PG_VERSION global pg_ident.conf pg_multixact pg_wal postgresql.auto.conf
base pg_hba.conf pg_logical pg_subtrans pg_xact postgresql.conf
$ brew uninstall postgresql
$ rm -rf /usr/local/var/postgres
$ brew install postgresql
$ ls /usr/local/var/postgres/
PG_VERSION pg_commit_ts pg_ident.conf pg_notify pg_snapshots pg_subtrans pg_wal postgresql.conf
base pg_dynshmem pg_logical pg_replslot pg_stat pg_tblspc pg_xact
global pg_hba.conf pg_multixact pg_serial pg_stat_tmp pg_twophase postgresql.auto.conf
我尝试了这个问题中的几乎所有答案以及另一个问题,这些是最终对我启动 postgres 有用的步骤
需要根据 postgres 的安装位置和您的版本来更新路径。我在 m1 Monterey 上使用 postgresql@14 并使用自制软件安装它。
我终于找到了我需要使用这篇文章查看的路径。
tail /opt/homebrew/var/log/[email protected]
输出显示:
2023-02-03 15:33:49.294 CST [82651] FATAL: could not open directory "pg_notify": No such file or directory
2023-02-03 15:33:49.294 CST [82651] LOG: database system is shut down
进入 / 目录并
cd opt/homebrew/var/postgresql@14
创建丢失的目录(也许这对您来说是不同的目录)
mkdir pg_notify
对所有丢失的目录重复此过程。
pg_tblspc
, pg_replslot
, pg_twophase
, pg_stat_tmp
, pg_logical/snapshots
, pg_logical/mappings
, pg_commit_ts
, pg_snapshots
, & pg_commit_ts
但我建议你专门运行尾巴每次命令以确保您没有丢失与我不同的目录和文件。最终在创建每个丢失的目录后重复运行 tail 命令后,我得到了这个输出。
2023-02-03 15:49:18.909 CST [85772] LOG: redo done at 0/17211D8 system usage: CPU: user: 0.00 s, system: 0.00 s, elapsed: 0.00 s
2023-02-03 15:49:18.914 CST [85771] LOG: database system is ready to accept connections
然后我就能够在我的项目中创建和迁移我的数据库・ᴗ・
在 /opt/homebrew/var/postgresql@14 中执行 mkdir 的解决方案对我有用! 您必须创建以下目录: pg_tblspc pg_replslot pg_twophase pg_stat pg_逻辑/快照 pg_逻辑/映射/ pg_commit_ts 根据您的日志文件.. tail -n 10 /opt/homebrew/var/log/[email protected]