Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos 无法连接到通过brew服务运行的Postgres服务器_Macos_Postgresql_Homebrew - Fatal编程技术网

Macos 无法连接到通过brew服务运行的Postgres服务器

Macos 无法连接到通过brew服务运行的Postgres服务器,macos,postgresql,homebrew,Macos,Postgresql,Homebrew,我一直在寻找解决方案,但找不到有效的解决方案 我在MacBook中使用brew(brew安装postgres)安装了postgres,目前我正在使用brew服务运行它(brew服务列表将postgres显示为正在运行的服务)。然而,当我尝试运行psql时,我得到以下错误 psql:无法连接到服务器:没有这样的文件或目录 在本地运行并在Unix域上接受连接的服务器 套接字“/tmp/.s.PGSQL.5432” 有人已经解决了类似的问题吗?我在安装postgresql93时遇到了相同的错误。 检查

我一直在寻找解决方案,但找不到有效的解决方案

我在MacBook中使用brew(
brew安装postgres
)安装了postgres,目前我正在使用brew服务运行它(
brew服务列表
将postgres显示为正在运行的服务)。然而,当我尝试运行
psql
时,我得到以下错误

psql:无法连接到服务器:没有这样的文件或目录 在本地运行并在Unix域上接受连接的服务器 套接字“/tmp/.s.PGSQL.5432”


有人已经解决了类似的问题吗?

我在安装postgresql93时遇到了相同的错误。 检查
brew服务列表
~/Library/LaunchAgents/homebrew.mxcl.postgresql93.plist
)输出中指示的.plist文件时,我发现以下消息:

致命:数据目录“/usr/local/var/postgres”具有组或世界访问权限
详细信息:权限应为u=rwx(0700)

这让我得到了这个答案:

运行
sudo chmod-R 700/usr/local/var/postgres
后,我得到了一个不同的错误:

致命:无法打开目录“pg_tblspc”:没有此类文件或目录

这让我想到:


运行
mkdir/usr/local/var/postgres/pg_tblspc/
后,集群成功启动。

我遇到了相同的错误,我通过删除进程pid文件修复了它:


rm-f/usr/local/var/postgres/postmaster.pid

这里我将结合威尔逊和蚱蜢的两个答案

您可以使用
brew服务列表
检查postgres服务的plist文件,找到文件的位置,然后在您喜爱的编辑器中打开它

您应该看到
StandardErrorPath
的值如下所示:

<key>StandardErrorPath</key>
<string>/usr/local/var/log/postgres.log</string>
StandardErrorPath
/usr/local/var/log/postgres.log
然后您应该使用
tail-n100/usr/local/var/log/postgres.log

就我而言,错误如下:

2017-12-06 11:51:16.078 GMT[85476]致命:锁定文件“postmaster.pid”已存在 2017-12-06 11:51:16.078 GMT[85476]提示:数据目录“/usr/local/var/postgres”中是否有另一位邮政局长(PID 601)在运行

这是因为我不得不硬关机我的Mac和postgres没有机会清理PID文件。只需删除PID文件rm/usr/local/var/postgres/postmaster.PID并启动postgres
brew服务启动postgresql


警告一句:除非您确定postgres没有运行,否则不要删除此PID文件。您可以通过运行
brew服务停止postgresql
,然后等待
brew服务列表的结果显示posgres处于停止状态来完成此操作。

我今天遇到了这个问题。postgres停止接受连接,尽管homebrew认为它正在运行

为了修复它,我跑了

brew services restart -vvv postgresql
此命令的输出

==> Successfully stopped `postgresql` (label: homebrew.mxcl.postgresql)
==> Generated plist for postgresql:
   <?xml version="1.0" encoding="UTF-8"?>
   <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
   <plist version="1.0">
   <dict>
     <key>KeepAlive</key>
     <true/>
     <key>Label</key>
     <string>homebrew.mxcl.postgresql</string>
     <key>ProgramArguments</key>
     <array>
       <string>/usr/local/opt/postgresql/bin/postgres</string>
       <string>-D</string>
       <string>/usr/local/var/postgres</string>
     </array>
     <key>RunAtLoad</key>
     <true/>
     <key>WorkingDirectory</key>
     <string>/usr/local</string>
     <key>StandardErrorPath</key>
     <string>/usr/local/var/log/postgres.log</string>
   </dict>
   </plist>
果然

[4826] FATAL:  lock file "postmaster.pid" already exists
[4826] HINT:  Is another postmaster (PID 1489) running in data directory "/usr/local/var/postgres"?
所以,我删除了那个文件

rm /usr/local/var/postgres/postmaster.pid

一切又开始工作了。

对我有效的方法是删除
/usr/local/var/postgres/
文件夹,然后再次卸载和安装postgres

在我的例子中,
postmaster.pid
文件根本不存在。通过升级postgres使其正常工作

brew update
brew upgrade
然后,因为我将主版本从10升级到11,所以我还必须运行以下程序:

brew postgresql-upgrade-database

(来源)

使用命令更新它

  brew postgresql-upgrade-database
如果您有以下错误 未找到命令“brew”
,但可与以下设备一起安装: sudo apt安装linuxbrew包装程序

然后使用命令安装它

 sudo apt install linuxbrew-wrapper

在我自己的例子中,
postgres.log
文件包含以下
提示:端口5432上是否已运行另一个邮局主管?如果没有,请删除套接字文件“/tmp/.s.PGSQL.5432”,然后重试。
删除套接字文件并重新启动后,一切正常。请注意,这是一个隐藏文件,无法通过窗口浏览器看到。应通过命令行进行删除

以防安装了多个版本的postgresql。下面提到的命令将用于删除进程id(pid)并重新启动它。只需确保您选择了正确的版本

rm -f /usr/local/var/postgresql@9.6/postmaster.pid

brew services restart postgresql@9.6   

请参阅Eric Corner的回答,以确认问题是否与日志文件中的“lock file postmaster.pid已存在”有关。

您可能会看到libssl/libcrypto版本之间存在冲突

brew服务启动postgres
日志给了我nada,但手动启动
pg_ctl-D/usr/local/var/postgres start
指向:

/../openssl/lib/libcrypto.1.0.0.dylib中缺少定义_RAND_cleanup

尝试一下:

brew tap-new $USER/old-openssl
brew extract --version=1.0.2t openssl $USER/old-openssl
brew install openssl@1.0.2t

# and then either brew link openssl@1.0.2t or symlink the required files to current openssl
ln -s /usr/local/Cellar/openssl/openssl@1.0.2t/lib/libcrypto.1.0.0.dylib /usr/local/opt/openssl/lib/libcrypto.1.0.0.dylib
ln -s /usr/local/Cellar/openssl/openssl@1.0.2t/lib/libssl.1.0.0.dylib /usr/local/opt/openssl/lib/libssl.1.0.0.dylib

如果其他答案都不起作用

我看到了同样的信息和被接受的答案

rm-f/usr/local/var/postgres/postmaster.pid

没用。也没有

rm-f/usr/local/var/postgres@9.6/在我记得我安装了一个特定的版本后,postmaster.pid

我做了一个
cat/usr/local/var/log/postgresql@9.6.log
和saw:

FATAL:  lock file "postmaster.pid" already exists
HINT:  Is another postmaster (PID 1231) running in data directory "/usr/local/var/postgresql@9.6"?
**思考面**

关闭iOS模拟器。Postgres自行重启。


这是在桌面上,我们昨天断电了,因此根据其他答案,我怀疑根本原因是在没有给东西清理机会的情况下硬关机。

问题-macOS升级后Postgres不工作。

我刚升级到最新的macOS(大苏尔)

由于以下错误,使用postgresql本地实例作为数据库的我的节点应用程序无法启动:
error:connect-econnrefuse127.0.0.1:5432

显然,postgresql在我的机器上已无法正常运行

运行
brew服务列表
显示postgresql的错误:

brew reinstall postgresql
> ps aux|grep 1231 [...] /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/libexec/mobileassetd
Name          Status  User  Plist    
postgresql    error   ***** /Users/*****/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
$ brew services stop postgresql
$ brew postgresql-upgrade-database # may need to `rm-rf /usr/local/var/postgres.old` first
$ brew services start postgresql
brew reinstall postgresql