【发布时间】:2021-12-10 05:13:27
【问题描述】:
我注意到有几个关于 Postgres (10) 由于共享内存而无法启动的问题;尽管如此,我还是无法让它运行。现在每次我尝试启动集群时都会收到此错误:
2021-10-24 10:13:43.269 UTC [11253] FATAL: could not map anonymous shared memory: Cannot allocate memory
2021-10-24 10:13:43.269 UTC [11253] HINT: This error usually means that PostgreSQL's request for a shared memory segment exceeded available memory, swap space, or huge pages. To reduce the request size (currently 5507432448 bytes), reduce PostgreSQL's shared memory usage, perhaps by reducing shared_buffers or max_connections.
我尝试检查和修改内核的shmall参数,但没有成功。
~$ cat /proc/sys/kernel/shmall
18446744073692774399
~$ cat /proc/sys/kernel/shmmax
18446744073692774399
我无法将内存减少到配置文件中,因为这些是我必须使用的设置,尽管我尝试过但没有成功(我什至使用了最小值)。
感谢您的帮助!
编辑 1:
好吧,我发现了一些奇怪的东西:
- 我从系统中彻底清除了 postgresql
- 我重新安装了 postgresql
- 启动集群,一切顺利
- 停止集群并使用我需要的设置编辑配置文件
- 尝试再次启动集群,但出现同样的错误
- 恢复到默认配置文件,但仍然出现相同的错误。为什么会这样?
系统有 16 GB 的 RAM。
编辑 2:添加细节
好的,基本上我必须通过移动数据目录来迁移 postgresql 数据库。这是唯一可以做的事情。完全移动数据文件夹后出现错误。 我注意到没有交换内存,所以我创建了它,但仍然是同样的错误。
两台服务器之间的共享内存和段基本相同。当我启动集群时它立即失败,所以也许这可以为你提供线索。目标服务器是一台 EC2 机器。
我不知道我还能做什么..
编辑 3:其他细节
这是命令 lsipc 显示的内容:
RESOURCE DESCRIPTION LIMIT USED USE%
MSGMNI Number of message queues 32000 0 0.00%
MSGMAX Max size of message (bytes) 8192 - -
MSGMNB Default max size of queue (bytes) 16384 - -
SHMMNI Shared memory segments 4096 0 0.00%
SHMALL Shared memory pages 18446744073692774399 0 0.00%
SHMMAX Max size of shared memory segment (bytes) 18446744073692774399 - -
SHMMIN Min size of shared memory segment (bytes) 1 - -
SEMMNI Number of semaphore identifiers 32000 0 0.00%
SEMMNS Total number of semaphores 1024000000 0 0.00%
SEMMSL Max semaphores per semaphore set. 32000 - -
SEMOPM Max number of operations per semop(2) 500 - -
SEMVMX Semaphore max value 32767 - -
这些值与我尝试迁移的源计算机相同。数据目录与原始目录相同,但每次使用此命令时:
sudo pg_ctlcluster 10 main start
我得到同样的错误。我真的需要帮助!
【问题讨论】:
-
它应该至少使用默认配置文件。
-
感谢您的帮助。我用原始配置文件替换了我的配置文件,但仍然出现同样的错误。
-
更改内存设置后报告的数字5507432448是否会改变?如果不是,那么您正在更改的配置文件不是正确的。
-
是的,默认配置文件的值更小。
-
ipcs -a显示什么?
标签: linux postgresql amazon-ec2 shared-memory postgresql-10