gpt4 book ai didi

postgresql - 带有 postgres 的 DOCKER 容器,警告 : could not open statistics file "pg_stat_tmp/global.stat": Operation not permitted

转载 作者:行者123 更新时间:2023-12-04 11:19:24 25 4
gpt4 key购买 nike

我有一个使用 .yml、Dockerfile(s) 等从几个不同的图像构建的 DOCKER 容器。到目前为止,一切都构建并运行良好,除了我在标题中看到的这个问题:

index-db_1   | 2021-02-22 23:18:33.388 UTC [31] WARNING:  could not open statistics file "pg_stat_tmp/global.stat": Operation not permitted
该数据库索引映射到主机上 Docker 包根目录中的一个文件夹,就数据库而言,其他一切似乎都可以正常工作。我使用的是 Mac,但如果我从 CLI 列出 DB 文件夹的权限,我会得到:
-rw-------@  1 sscotti  staff      3 Feb 22 11:01 PG_VERSION
drwx------@ 6 sscotti staff 192 Feb 22 11:54 base
drwx------@ 60 sscotti staff 1920 Feb 22 16:00 global
drwx------@ 2 sscotti staff 64 Feb 22 11:01 pg_commit_ts
drwx------@ 2 sscotti staff 64 Feb 22 11:01 pg_dynshmem
-rw-------@ 1 sscotti staff 4782 Feb 22 11:02 pg_hba.conf
-rw-------@ 1 sscotti staff 1636 Feb 22 11:01 pg_ident.conf
drwx------@ 5 sscotti staff 160 Feb 22 17:46 pg_logical
drwx------@ 4 sscotti staff 128 Feb 22 11:01 pg_multixact
drwx------@ 2 sscotti staff 64 Feb 22 11:01 pg_notify
drwx------@ 2 sscotti staff 64 Feb 22 11:01 pg_replslot
drwx------@ 2 sscotti staff 64 Feb 22 11:01 pg_serial
drwx------@ 2 sscotti staff 64 Feb 22 11:01 pg_snapshots
drwx------@ 2 sscotti staff 64 Feb 22 16:00 pg_stat
drwx------@ 5 sscotti staff 160 Feb 22 17:50 pg_stat_tmp
drwx------@ 3 sscotti staff 96 Feb 22 11:01 pg_subtrans
drwx------@ 2 sscotti staff 64 Feb 22 11:01 pg_tblspc
drwx------@ 2 sscotti staff 64 Feb 22 11:01 pg_twophase
drwx------@ 4 sscotti staff 128 Feb 22 11:01 pg_wal
drwx------@ 3 sscotti staff 96 Feb 22 11:01 pg_xact
-rw-------@ 1 sscotti staff 88 Feb 22 11:01 postgresql.auto.conf
-rw-------@ 1 sscotti staff 28073 Feb 22 11:01 postgresql.conf
-rw-------@ 1 sscotti staff 36 Feb 22 16:00 postmaster.opts
-rw------- 1 sscotti staff 94 Feb 22 16:00 postmaster.pid
pg_stat 文件夹实际上是空的。
和 pg_stat_temp 有:
-rw-------  1 sscotti  staff   1952 Feb 22 17:54 db_0.stat
-rw------- 1 sscotti staff 20360 Feb 22 17:54 db_13395.stat
-rw------- 1 sscotti staff 1151 Feb 22 17:54 global.stat
.yml 文件有这个:
  index-db:
image: postgres
restart: unless-stopped
volumes:
- ./OrthancIndex:/var/lib/postgresql/data
鉴于它是一个 Docker 容器,这是可以忽略的东西吗?
在 UBUNTU 上添加关于相同设置的评论。
数据库文件夹:
drwx------ 19 systemd-coredump root 4096 Jun 30 13:12 OrthancIndex
数据库:
drwx------ 6 systemd-coredump systemd-coredump  4096 Jun 11 13:00 base
drwx------ 2 systemd-coredump systemd-coredump 4096 Jun 30 13:12 global
drwx------ 2 systemd-coredump systemd-coredump 4096 Mar 12 16:12 pg_commit_ts
drwx------ 2 systemd-coredump systemd-coredump 4096 Mar 12 16:12 pg_dynshmem
-rw------- 1 systemd-coredump systemd-coredump 4782 Mar 12 16:12 pg_hba.conf
-rw------- 1 systemd-coredump systemd-coredump 1636 Mar 12 16:12 pg_ident.conf
drwx------ 4 systemd-coredump systemd-coredump 4096 Jul 1 13:27 pg_logical
drwx------ 4 systemd-coredump systemd-coredump 4096 Mar 12 16:12 pg_multixact
drwx------ 2 systemd-coredump systemd-coredump 4096 Mar 12 16:12 pg_notify
drwx------ 2 systemd-coredump systemd-coredump 4096 Mar 12 16:12 pg_replslot
drwx------ 2 systemd-coredump systemd-coredump 4096 Mar 12 16:12 pg_serial
drwx------ 2 systemd-coredump systemd-coredump 4096 Mar 12 16:12 pg_snapshots
drwx------ 2 systemd-coredump systemd-coredump 4096 Jun 30 13:12 pg_stat
drwx------ 2 systemd-coredump systemd-coredump 4096 Jul 1 13:29 pg_stat_tmp
drwx------ 2 systemd-coredump systemd-coredump 4096 Jun 24 21:04 pg_subtrans
drwx------ 2 systemd-coredump systemd-coredump 4096 Mar 12 16:12 pg_tblspc
drwx------ 2 systemd-coredump systemd-coredump 4096 Mar 12 16:12 pg_twophase
-rw------- 1 systemd-coredump systemd-coredump 3 Mar 12 16:12 PG_VERSION
drwx------ 3 systemd-coredump systemd-coredump 4096 Jul 1 12:37 pg_wal
drwx------ 2 systemd-coredump systemd-coredump 4096 Mar 12 16:12 pg_xact
-rw------- 1 systemd-coredump systemd-coredump 88 Mar 12 16:12 postgresql.auto.conf
-rw------- 1 systemd-coredump systemd-coredump 28073 Mar 12 16:12 postgresql.conf
-rw------- 1 systemd-coredump systemd-coredump 36 Jun 30 13:12 postmaster.opts
-rw------- 1 systemd-coredump systemd-coredump 94 Jun 30 13:12 postmaster.pid
pg_stat_temp
-rw------- 1 systemd-coredump systemd-coredump  2660 Jul  1 13:30 db_0.stat
-rw------- 1 systemd-coredump systemd-coredump 31157 Jul 1 13:30 db_13395.stat
-rw------- 1 systemd-coredump systemd-coredump 1151 Jul 1 13:30 global.stat
我实际上在 UBUNTU 上遇到了同样的错误:
postgres_index-db_1   | 2021-07-01 18:06:45.140 UTC [266] WARNING:  could not open statistics file "pg_stat_tmp/global.stat": Operation not permitted
postgres_index-db_1 | 2021-07-01 18:13:45.583 UTC [273] WARNING: could not open statistics file "pg_stat_tmp/global.stat": Operation not permitted
postgres_index-db2_1 | 2021-07-01 18:19:43.716 UTC [282] WARNING: could not open statistics file "pg_stat_tmp/global.stat": Operation not permitted
postgres_index-db2_1 | 2021-07-01 18:21:43.749 UTC [284] WARNING: could not open statistics file "pg_stat_tmp/global.stat": Operation not permitted
虽然这里的用户和组是 systemd-coredump。

最佳答案

使用本地卷挂载需要 postgres 容器内的用户映射。 https://hub.docker.com/_/postgres里面有一段标题为 的自述文件任意--用户备注它描述了问题的解决方案。
列出的一个建议是使用 docker 卷,初始化已挂载的卷的内容,关闭容器镜像,运行递归所有权更改,然后正常重启容器。

$ docker volume create pgdata
$ docker run -it --rm -v pgdata:/var/lib/postgresql/data -e POSTGRES_PASSWORD=mysecretpassword postgres
The files belonging to this database system will be owned by user "postgres".
...
( once it's finished initializing successfully and is waiting for connections, stop it )
$ docker run -it --rm -v pgdata:/var/lib/postgresql/data bash chown -R 1000:1000 /var/lib/postgresql/data
$ docker run -it --rm --user 1000:1000 -v pgdata:/var/lib/postgresql/data postgres

关于postgresql - 带有 postgres 的 DOCKER 容器,警告 : could not open statistics file "pg_stat_tmp/global.stat": Operation not permitted,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66325175/

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