Postgres 失败并显示“无法打开关系映射文件“global/pg_filenode.map” '

发布于 2024-12-04 17:06:25 字数 1761 浏览 0 评论 0原文

我在开发环境中安装 postgres 时遇到问题,需要一些帮助来诊断它。我还没有找到解决方案。

  1. 我已经用自制软件安装了 postgres 9.0.4
  2. 我正在 OS X 10.6.8 (Snow Leopard) 上运行

我可以启动和停止服务器

$ pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
server starting

如果我尝试停止

$ pg_ctl -D /usr/local/var/postgres stop -s -m fast
pg_ctl: PID file "/usr/local/var/postgres/postmaster.pid" does not exist
Is server running?

好吧,这个丢失了

$ ls -l /usr/local/var/postgres/ | grep postmaster
$

但它肯定正在运行

$ ps aux | grep postgres
pschmitz   303   0.9  0.0  2445860   1428   ??  Ss    3:12PM   0:02.46 postgres: autovacuum launcher process       
pschmitz   304   0.9  0.0  2441760    428   ??  Ss    3:12PM   0:02.57 postgres: stats collector process       
pschmitz   302   0.0  0.0  2445728    508   ??  Ss    3:12PM   0:00.56 postgres: wal writer process       
pschmitz   301   0.0  0.0  2445728    560   ??  Ss    3:12PM   0:00.78 postgres: writer process       
pschmitz   227   0.0  0.1  2445728   2432   ??  S     3:11PM   0:00.42 /usr/local/Cellar/postgresql/9.0.3/bin/postgres -D /usr/local/var/postgres -r /usr/local/var/postgres/server.log

如果我尝试访问或使用它我明白了。

$psql
psql: FATAL:  could not open relation mapping file "global/pg_filenode.map": No such file or directory

但 global/pg_filenode.map 肯定存在,

$ls -l /usr/local/var/postgres/

...
-rw-------  1 pschmitz  staff   8192 Sep 16 15:48 pg_control
-rw-------  1 pschmitz  staff    512 Sep 16 15:48 pg_filenode.map
-rw-------  1 pschmitz  staff  12092 Sep 16 15:48 pg_internal.init

我尝试卸载并重新安装但没有效果。关于如何解决这个问题有什么想法吗? 它几乎阻止了我今天完成任何事情。

I'm having an issue with my install of postgres in my development environment and I need some help diagnosing it. I haven't yet had any luck in tracking down a solution.

  1. I have postgres 9.0.4 installed with homebrew
  2. I am running on OS X 10.6.8 (Snow Leopard)

I can start and stop the server

$ pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
server starting

If I try to stop though

$ pg_ctl -D /usr/local/var/postgres stop -s -m fast
pg_ctl: PID file "/usr/local/var/postgres/postmaster.pid" does not exist
Is server running?

Ok this is missing

$ ls -l /usr/local/var/postgres/ | grep postmaster
$

But it is definitely running

$ ps aux | grep postgres
pschmitz   303   0.9  0.0  2445860   1428   ??  Ss    3:12PM   0:02.46 postgres: autovacuum launcher process       
pschmitz   304   0.9  0.0  2441760    428   ??  Ss    3:12PM   0:02.57 postgres: stats collector process       
pschmitz   302   0.0  0.0  2445728    508   ??  Ss    3:12PM   0:00.56 postgres: wal writer process       
pschmitz   301   0.0  0.0  2445728    560   ??  Ss    3:12PM   0:00.78 postgres: writer process       
pschmitz   227   0.0  0.1  2445728   2432   ??  S     3:11PM   0:00.42 /usr/local/Cellar/postgresql/9.0.3/bin/postgres -D /usr/local/var/postgres -r /usr/local/var/postgres/server.log

And if I try to access or use it I get this.

$psql
psql: FATAL:  could not open relation mapping file "global/pg_filenode.map": No such file or directory

But global/pg_filenode.map definitely exists in

$ls -l /usr/local/var/postgres/

...
-rw-------  1 pschmitz  staff   8192 Sep 16 15:48 pg_control
-rw-------  1 pschmitz  staff    512 Sep 16 15:48 pg_filenode.map
-rw-------  1 pschmitz  staff  12092 Sep 16 15:48 pg_internal.init

I have attempted to uninstall and reinstall to no effect. Any ideas on how I can solve this?
It has pretty much prevented me from getting anything done today.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(14

淡笑忘祈一世凡恋 2024-12-11 17:06:25

我不确定 9.0.3 的原始问题根源是什么,因为我遇到了这个问题:

psql: FATAL:  could not open relation mapping file "global/pg_filenode.map": No such file or directory

但是如上所述,事实证明运行进程是针对我之前安装的 9.0.3 的 postgres

我相信我有一个旧的~/Library/LaunchAgents/ 中的版本 org.postgresql.postgres.plist

我必须:

  1. 删除并重新添加启动代理
  2. 终止 9.0.3 的进程
  3. 初始化数据库initdb /usr/local/var/postgres
  4. 重新启动我的计算机

,现在我可以正常工作了。

I am not sure what the source of my original problem was with 9.0.3 because I was getting this problem:

psql: FATAL:  could not open relation mapping file "global/pg_filenode.map": No such file or directory

However as stated above it turns out that the running process was for my previous postgres install of 9.0.3

I believe I had an old version org.postgresql.postgres.plist in ~/Library/LaunchAgents/

I had to:

  1. Remove and re-add the launch agent
  2. Kill the processes for 9.0.3
  3. Initialize the db initdb /usr/local/var/postgres
  4. Restart my computer

and now I have it up and working.

揽月 2024-12-11 17:06:25

使用 mdillon/postgis:9.6 Docker 映像遇到此问题。简单的 sudo docker restart 解决了问题。

Encountered this problem using mdillon/postgis:9.6 Docker image. Simple sudo docker restart <container id> solved the problem.

白龙吟 2024-12-11 17:06:25

这可能是权限问题,检查 /var/lib/pgsql/9.3/data/ 中配置文件的所有者和组

chown -R postgres:postgres /var/lib/pgsql/9.3/data/

That may be a permission issue, check the owner and group of configuration files in /var/lib/pgsql/9.3/data/

chown -R postgres:postgres /var/lib/pgsql/9.3/data/
请叫√我孤独 2024-12-11 17:06:25

我刚刚遇到这个问题。通过将 postgres 数据目录的所有者设置为非特权 postgres 用户解决了这个问题。

I just encountered this problem. Solved it by setting the owner of the postgres data directory to the unprivileged postgres user.

一身软味 2024-12-11 17:06:25

PS Aux | Grep Postgres揭示了我在先前的测试运行中在临时数据目录上运行的邮政postgres实例。杀死这一过程解决了问题。

ps aux | grep postgres revealed I had another instance of postgres running on a temp data directory from a previous test run. Killing this process fixed the problem.

泪是无色的血 2024-12-11 17:06:25

我在fedora中的逐步解决方案:

  • /bin/systemctl stop postgresql.service (停止服务)
  • rm -rf /var/lib/pgsql/data (删除“data”目录)
  • postgresql-setup initdb (重新创建“data”目录)
  • /bin/systemctl start postgresql.service (启动服务)

也很有用检查“数据”目录的权限:

chown -R postgres:postgres

(感谢 @LuizFernandodaSilva & @user4640867)

My step-by-step solution in fedora:

  • /bin/systemctl stop postgresql.service (Stop the service)
  • rm -rf /var/lib/pgsql/data (Remove the "data" direcotry)
  • postgresql-setup initdb (Recreate the "data" directory)
  • /bin/systemctl start postgresql.service (Start the service)

It is also useful to check the permissions of the "data" directory:

chown -R postgres:postgres <path_to_data_dir>

(Kudos to @LuizFernandodaSilva & @user4640867)

无所的.畏惧 2024-12-11 17:06:25

我对 PGDATA 的旧值感到困惑。

I had an old value of PGDATA confusing things.

霞映澄塘 2024-12-11 17:06:25

这(https://gist.github.com/olivierlacan/e1bf5c34bc9f82e06bc0)解决了我的问题!我首先必须:

  1. 从我的应用程序中删除 Postgres.app
  2. 删除 /usr/local/var/postgres 目录
  3. initdb /usr/local/var/postgres/

然后我能够使用这些启动/停止 Postgres 2 个命令:

开始:

pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start

停止:

pg_ctl -D /usr/local/var/postgres stop -s -m fast

This (https://gist.github.com/olivierlacan/e1bf5c34bc9f82e06bc0) solved my problem! I first had to:

  1. Delete Postgres.app from my Applications
  2. Delete /usr/local/var/postgres directory
  3. initdb /usr/local/var/postgres/

Then I was able to start/stop Postgres with these 2 commands:

Start:

pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start

Stop:

pg_ctl -D /usr/local/var/postgres stop -s -m fast
記憶穿過時間隧道 2024-12-11 17:06:25

我对这个问题的解决方案:

我正在运行 postgresql-9.3

我的 plist 文件位于以下目录中:/Library/LaunchDaemons/com.edb.launchd.postgresql-9.3.plist

第 1 步将停止 postgres
1. $ sudo launchctl stop com.edb.launchd.postgresql-9.3
使用以下命令启动postgres(可以使用$brew info postgres找到这个位置)
2. $ postgres -D /usr/local/var/postgres

My solution to this problem:

I am running postgresql-9.3

My plist file is in the following directory:/Library/LaunchDaemons/com.edb.launchd.postgresql-9.3.plist

Step 1 will stop postgres
1. $ sudo launchctl stop com.edb.launchd.postgresql-9.3
Start postgres using the following command (can find this location using $ brew info postgres)
2. $ postgres -D /usr/local/var/postgres

忆伤 2024-12-11 17:06:25

我同意上述所有解决方案。我在服务器上运行 Postgres,问题是我使用的端口号已被其他旧版本的 Postgres 使用。

我只需要更改端口。

I agree about all of the above solutions. I was running Postgres on a server, and the problem was that I was using a PORT number that was used by some other OLDER version of Postgres.

I only needed to change the port.

生死何惧 2024-12-11 17:06:25

我遇到了同样的错误psql:致命:无法打开关系映射文件“global/pg_filenode.map”:没有这样的文件或目录

感谢上面的注释#2:“杀死 9.0.3 的进程”

我之前配置并编译了 PostgreSQL。然后我决定重新配置,gmake,使用不同的文件路径安装gmake。新编译的程序在预期的文件路径中找不到“pg_filenode.map”。终止正在运行的 postgres 进程,清空 pgsql/data,并再次执行 initdb 允许创建新数据库。

I had the same error psql: FATAL: could not open relation mapping file "global/pg_filenode.map": No such file or directory.

Thanks for note #2 above: 'Kill the processes for 9.0.3'

I previously configured and compiled PostgreSQL. I then decided to reconfigure, gmake, gmake install with different file paths. The newly compiled program wasn't finding 'pg_filenode.map' in the expected filepath. Killing the running postgres process, emptying pgsql/data, and doing initdb again allowed creation of a new database.

原来是傀儡 2024-12-11 17:06:25

确保关闭防病毒软件。
就我而言,当我关闭防病毒软件(卡巴斯基)时,它工作得很好
参考:https://github.com/PostgresApp/PostgresApp/issues/610

Make sure to turn off you antivirus.
In my case when i turn off the antivirus(kaspersky) it worked fine
Ref : https://github.com/PostgresApp/PostgresApp/issues/610

一口甜 2024-12-11 17:06:25

只需使用命令行授予权限:

sudo chown -R $(whoami) /usr/local/*

just grant permission using the command line:

sudo chown -R $(whoami) /usr/local/*
一江春梦 2024-12-11 17:06:25

我在尝试安装并运行 postgresql 和 pgadmin4 时遇到了类似但不同的问题。确切的错误消息如下所示,我未能在网上找到有用的帖子(有类似错误但没有收到解决方案的人),因此我只是在这里分享我的经验。

could not open file "global/pg_filenode.map": operation not permitted

我的问题是由于 postgres 卸载不当而发生的。当我尝试在 pgadmin 中访问我的 postgres 服务器时,收到错误消息。
解决方案:
我按照此处的教程进行操作。之后,我使用以下脚本查找每个 postgres 相关文件并手动卸载它们。 (不包括 django 项目等中的项目)。请仔细检查您要删除的内容。

sudo find / -iname "*pgadmin*" -o -iname "*postgres*" -o -iname "*postgresapp*" 2>/dev/null

我重新安装了 postgresql 和 postgres.app,现在一切正常。

I was running into similar but different problem while trying to install and get postgresql and pgadmin4 running. The exact error message was as shown below and i failed to find helpful post online (people with similar error without receiving solutions) hence I am just gonna share my experience here.

could not open file "global/pg_filenode.map": operation not permitted

My problem happened because improper uninstallation of postgres. i got the error message when i tried to access my postgres server in pgadmin.
Solution:
i follow the tutorial here. after that, i used the following script to find every postgres related file and manually uninstall every of them. (excluding those in django projects or etc). pls carefully check about what you are deleting.

sudo find / -iname "*pgadmin*" -o -iname "*postgres*" -o -iname "*postgresapp*" 2>/dev/null

and i reinstalled postgresql and postgres.app and everything works fine now.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文