postgresql Postgres 因“无法打开关系映射文件“global/pg_filenode.map”而失败”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7445935/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Postgres is failing with 'could not open relation mapping file "global/pg_filenode.map" '
提问by bullfight
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.
我在开发环境中安装 postgres 时遇到问题,我需要一些帮助来诊断它。我还没有找到解决方案的运气。
- I have postgres 9.0.4 installed with homebrew
- I am running on OS X 10.6.8 (Snow Leopard)
- 我安装了自制软件的 postgres 9.0.4
- 我在 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
但是 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 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.
我试图卸载并重新安装没有效果。关于如何解决这个问题的任何想法?它几乎阻止了我今天完成任何事情。
EDIT Solved
编辑解决
I am not sure what the source of my original problem was with 9.0.3 because I was getting this problem
我不确定 9.0.3 的原始问题的根源是什么,因为我遇到了这个问题
psql: FATAL: could not open relation mapping file "global/pg_filenode.map": No such file or directory
However as stated above it turns out the running process was for my previous postgres install of 9.0.3
然而,如上所述,运行过程是针对我之前安装的 9.0.3 的 postgres
I believe I had an old version org.postgresql.postgres.plist in ~/Library/LaunchAgents/
我相信我在 ~/Library/LaunchAgents/ 中有一个旧版本的 org.postgresql.postgres.plist
I had to:
我不得不:
- Remove and re-add the launch agent
- Kill the processes for 9.0.3
- Initialize the db
initdb /usr/local/var/postgres
- Restart my computer
- 删除并重新添加启动代理
- 杀死 9.0.3 的进程
- 初始化数据库
initdb /usr/local/var/postgres
- 重新启动我的电脑
and now I have it up and working.
现在我已经完成并工作了。
回答by bullfight
I am not sure what the source of my original problem was with 9.0.3 because I was getting this problem:
我不确定 9.0.3 的原始问题的根源是什么,因为我遇到了这个问题:
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
然而,如上所述,运行过程是针对我之前安装的 9.0.3 的 postgres
I believe I had an old version org.postgresql.postgres.plist in ~/Library/LaunchAgents/
我相信我在 ~/Library/LaunchAgents/ 中有一个旧版本的 org.postgresql.postgres.plist
I had to:
我不得不:
- Remove and re-add the launch agent
- Kill the processes for 9.0.3
- Initialize the db
initdb /usr/local/var/postgres
- Restart my computer
- 删除并重新添加启动代理
- 杀死 9.0.3 的进程
- 初始化数据库
initdb /usr/local/var/postgres
- 重新启动我的电脑
and now I have it up and working.
现在我已经完成并工作了。
回答by user4640867
That may be a permission issue, Please check the owner and group of configuration files in /var/lib/pgsql/9.3/data/
那可能是权限问题,请检查/var/lib/pgsql/9.3/data/中的配置文件的所有者和组
chown -R postgres:postgres /var/lib/pgsql/9.3/data/
solved the issue for me
为我解决了这个问题
回答by hd1
I just encountered this problem. Solved it by setting the owner of the postgres data directory to the unprivileged postgres user.
我刚遇到这个问题。通过将 postgres 数据目录的所有者设置为非特权 postgres 用户来解决它。
回答by Owen Pauling
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.
ps aux | grep postgres
透露我在上一次测试运行的临时数据目录上运行了另一个 postgres 实例。杀死这个进程解决了这个问题。
回答by 1valdis
Encountered this problem using mdillon/postgis:9.6
Docker image. Simple sudo docker restart <container id>
solved the problem.
使用mdillon/postgis:9.6
Docker 镜像遇到这个问题。简单的sudo docker restart <container id>
解决了问题。
回答by Raymond Gan
This (https://gist.github.com/olivierlacan/e1bf5c34bc9f82e06bc0) solved my problem! I first had to:
这(https://gist.github.com/olivierlacan/e1bf5c34bc9f82e06bc0)解决了我的问题!我首先必须:
- Delete Postgres.app from my Applications
- Delete /usr/local/var/postgres directory
initdb /usr/local/var/postgres/
- 从我的应用程序中删除 Postgres.app
- 删除 /usr/local/var/postgres 目录
initdb /usr/local/var/postgres/
Then I was able to start/stop Postgres with these 2 commands:
然后我可以使用以下 2 个命令启动/停止 Postgres:
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
回答by Chris
I had an old value of PGDATA confusing things.
我有一个旧的 PGDATA 值,令人困惑。
回答by raratiru
My step-by-step solution in fedora:
我在 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)
/bin/systemctl stop postgresql.service
(停止服务)rm -rf /var/lib/pgsql/data
(删除“数据”目录)postgresql-setup initdb
(重新创建“数据”目录)/bin/systemctl start postgresql.service
(启动服务)
It is also useful to check the permissions of the "data" directory:
检查“data”目录的权限也很有用:
chown -R postgres:postgres <path_to_data_dir>
chown -R postgres:postgres <path_to_data_dir>
(Kudos to @LuizFernandodaSilva & @user4640867)
(感谢@LuizFernandodaSilva 和@user4640867)
回答by RC_02
My solution to this problem:
I am running postgresql-9.3
我对这个问题的解决方案:
我正在运行 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
我的 plist 文件在以下目录中:/Library/LaunchDaemons/com.edb.launchd.postgresql-9.3.plist
Step 1 将停止 postgres
1. $ sudo launchctl stop com.edb.launchd.postgresql-9.3
使用以下命令启动 postgres命令(可以使用 $ brew info postgres 找到此位置)
2. $ postgres -D /usr/local/var/postgres
回答by MFARID
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.
我同意上述所有解决方案。我在服务器上运行 Postgres,问题是我使用了其他一些较旧版本的 Postgres 使用的端口号。
I only needed to change the port.
我只需要更改端口。