gpt4 book ai didi

ruby-on-rails - 我的 Postgres 端口文件应该是什么样的?

转载 作者:行者123 更新时间:2023-11-29 11:45:58 24 4
gpt4 key购买 nike

首先,如果“端口文件不是正确的术语”,我深表歉意,但 Postgres 不是我的强项之一。我试图找出这个端口文件应该是什么样子,因为它似乎已经从我的系统中消失了。请继续阅读以获取解释和我的(很可能不正确的)思路。

我将 Postgres 与一个 Rails 项目(通过 postgres gem)一起使用,它一直运行良好,直到昨天当我更新一些 HTML 时它停止工作。我用通常的方式重新启动了我的 Rails 服务器

rails s

只能得到:

/Users/pedr/.rvm/gems/ruby-1.9.3-p0/gems/activerecord-3.2.1/lib/active_record/connection_adapters/postgresql_adapter.rb:1161:in `initialize': could not connect to server: No such file or directory (PG::Error) \n \n
Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

我正在使用 Lunchy 来启动和停止 postgres,那里似乎没有问题。

但是我使用了以下终端命令来检查 Postgres 正在监听的端口:

sudo lsof -p 286| awk '$5 == "unix" && $NF ~ /\// { print $NF }'

它没有列出任何内容。所以我认为该端口已被删除。

我对端口的有限了解导致我在以下位置查找端口文件:

/tmp/.s.PGSQL.5432

有一个文件叫做:

.s.PGSQL.5432.lock

tmp directory

据我了解,此文件会阻止编辑丢失的端口文件。

我尝试使用 Time Machine 来查找这个丢失的文件,但 Time Machine 似乎没有在/tmp 目录中存储任何内容。

那么我怎样才能重新创建这个文件呢?它应该是什么样子?

[更新]

回应@wildplasser 的建议:

测试 postgres 是否正在运行:

ps aux | grep postgres

让我:

633 0.0 0.0 2442564 392 ?? Ss 9:23am 0:00.09 postgres: stats collector process 632 0.0 0.0 2446480 1516 ?? Ss 9:23am 0:00.09 postgres: autovacuum launcher process 631 0.0 0.0 2446348 520 ?? Ss 9:23am 0:00.32 postgres: wal writer process 630 0.0 0.0 2446348 580 ?? Ss 9:23am 0:00.48 postgres: writer process 520 0.0 0.1 2446348 3640 ?? S 9:22am 0:00.33 /usr/local/bin/postgres -D /usr/local/var/postgres -r /usr/local/var/postgres/server.log myusername 1187 0.0 0.0 2434892 540 s000 S+ 10:35am 0:00.00 grep postgres

测试Unix域套接字是否运行:

ls -l /tmp/ | grep PGSQL | grep -v grep

我什么也得不到。

postgres 是否在本地主机上监听互联网协议(protocol)?

psql -H localhost

让我:

psql: FATAL: database "localhost" does not exist

postgres 是否正在监听 Unix 域套接字?

psql -H /tmp/.s.PGSQL.5432

让我:

psql: FATAL: database "/tmp/.s.PGSQL.5432" does not exist

最佳答案

“端口文件”是 PostgreSQL 正在监听的 unix 套接字。它将在启动时创建它。停止 PostgreSQL 服务器,删除 .lock 文件(如果它仍然存在),重新启动 PG 并查看您的套接字是否恢复。

我很困惑,为什么它实际上不存在。我以前从未听说过这种情况。

关于ruby-on-rails - 我的 Postgres 端口文件应该是什么样的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11153417/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com