这个周末,我升级了OSX Catalina(到10.15.4(和XCode(从11.2到11.4(。我还运行了brew upgrade
,它可能已经升级了Postgres,但我不确定。无论如何,我目前安装了Postgres11.4。
但现在我无法连接到Postgres:
% brew services stop postgresql
% brew services start postgresql
% psql
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
我已经阅读了所有建议删除postmaster.pid
的答案,但我找不到要删除的postmaster.pid
文件——在/usr/local/var/postgres
或其他任何地方都找不到。
我该怎么办?
更新:如果我尝试从pg_ctl
(而不是brew services
(开始,那么我会看到这个错误:
% pg_ctl start -D /usr/local/var/postgres
waiting for server to start....2020-04-14 12:20:36.279 BST [99028] LOG: listening on IPv6 address "::1", port 5432
2020-04-14 12:20:36.279 BST [99028] LOG: listening on IPv4 address "127.0.0.1", port 5432
2020-04-14 12:20:36.280 BST [99028] LOG: listening on Unix socket "/tmp/.s.PGSQL.5432"
2020-04-14 12:20:36.290 BST [99028] LOG: redirecting log output to logging collector process
2020-04-14 12:20:36.290 BST [99028] HINT: Future log output will appear in directory "log".
dyld: lazy symbol binding failed: Symbol not found: _RAND_cleanup
Referenced from: /usr/local/Cellar/postgresql/11.4/bin/postgres
Expected in: /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib
dyld: Symbol not found: _RAND_cleanup
Referenced from: /usr/local/Cellar/postgresql/11.4/bin/postgres
Expected in: /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib
stopped waiting
所以我想知道这是否与libcrypto有关?
升级到MacOS 10.15.5后出现相同问题,但使用了postgres 9.4.18这个版本确实与libssl1.0.0.dylib.有依赖关系
> otool -L '/usr/local/Cellar/postgresql@9.4/9.4.18/bin/postgres'
/usr/local/Cellar/postgresql@9.4/9.4.18/bin/postgres:
/usr/lib/libxml2.2.dylib (compatibility version 10.0.0, current version 10.9.0)
/usr/lib/libpam.2.dylib (compatibility version 3.0.0, current version 3.0.0)
/usr/local/opt/openssl/lib/libssl.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/Kerberos.framework/Versions/A/Kerberos (compatibility version 5.0.0, current version 6.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.50.4)
/System/Library/Frameworks/LDAP.framework/Versions/A/LDAP (compatibility version 1.0.0, current version 2.4.0)
修复的是升级postgres。
> brew upgrade 'postgresql@9.4'
==> Upgrading 1 outdated package:
postgresql@9.4 9.4.18 -> 9.4.26
然后
> otool -L '/usr/local/Cellar/postgresql@9.4/9.4.26/bin/postgres'
/usr/local/Cellar/postgresql@9.4/9.4.26/bin/postgres:
/usr/lib/libxml2.2.dylib (compatibility version 10.0.0, current version 10.9.0)
/usr/lib/libpam.2.dylib (compatibility version 3.0.0, current version 3.0.0)
/usr/local/opt/openssl@1.1/lib/libssl.1.1.dylib (compatibility version 1.1.0, current version 1.1.0)
/usr/local/opt/openssl@1.1/lib/libcrypto.1.1.dylib (compatibility version 1.1.0, current version 1.1.0)
/System/Library/Frameworks/Kerberos.framework/Versions/A/Kerberos (compatibility version 5.0.0, current version 6.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.100.1)
/System/Library/Frameworks/LDAP.framework/Versions/A/LDAP (compatibility version 1.0.0, current version 2.4.0)
现在可以开始postgres了
> pg_ctl -D /usr/local/var/postgresql@9.4 start