PostgreSQL启动报错“could not map anonymous shared memory: Cannot allo ...

打印 上一主题 下一主题

主题 713|帖子 713|积分 2143

PostgreSQL启动报错“could not map anonymous shared memory: Cannot allocate memory”

  1. 基础信息
  2. OS版本:Red Hat Enterprise Linux Server release 7.9 (Maipo)
  3. DB版本:16.2
  4. pg软件目录:/home/pg16/soft
  5. pg数据目录:/home/pg16/data
  6. 端口:5777
复制代码
报错

  1. [pg16@test ~]$ pg_ctl start
  2. waiting for server to start....2024-06-01 22:20:02.156 PDT [68668] DEBUG:  registering background worker "logical replication launcher"
  3. 2024-06-01 22:20:02.157 PDT [68668] DEBUG:  loaded library "pg_stat_statements"
  4. 2024-06-01 22:20:02.157 PDT [68668] FATAL:  could not map anonymous shared memory: Cannot allocate memory
  5. 2024-06-01 22:20:02.157 PDT [68668] 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 295698432 bytes), reduce PostgreSQL's shared memory usage, perhaps by reducing shared_buffers or max_connections.
  6. 2024-06-01 22:20:02.157 PDT [68668] LOG:  database system is shut down
  7. stopped waiting
  8. pg_ctl: could not start server
  9. Examine the log output.
复制代码
PostgreSQL 请求的共享内存段超出了当前可用的内存、互换空间或大页内存 (huge pages)。当前请求的内存大小为 295,698,432 字节(约 282 MB)。
分析记载

  1. [pg16@test ~]$ cat data/postgresql.conf |grep shared
  2. shared_buffers = 256MB                  # min 128kB
  3. #shared_memory_type = mmap              # the default is the first option
  4. dynamic_shared_memory_type = posix      # the default is usually the first option
  5. #min_dynamic_shared_memory = 0MB        # (change requires restart)
  6. #wal_buffers = -1                       # min 32kB, -1 sets based on shared_buffers
  7. shared_preload_libraries = 'pg_stat_kcache,pg_stat_statements,auto_explain'     # (change requires restart)
  8. [pg16@test ~]$ cat /proc/meminfo |grep Huge
  9. AnonHugePages:    942080 kB
  10. HugePages_Total:     150
  11. HugePages_Free:        7
  12. HugePages_Rsvd:        0
  13. HugePages_Surp:        0
  14. Hugepagesize:       2048 kB
复制代码
发现空闲的大页只有7个,不满足pg的启动需求,故报错。最终发现是别的数据库进程占用了,停了之后pg可以正常启动。
解决

  1. [pg16@test log]$ pg_ctl start
  2. waiting for server to start....2024-06-02 06:43:45.043 PDT [3636] DEBUG:  registering background worker "logical replication launcher"
  3. 2024-06-02 06:43:45.043 PDT [3636] DEBUG:  loaded library "pg_stat_statements"
  4. 2024-06-02 06:43:45.051 PDT [3636] LOG:  redirecting log output to logging collector process
  5. 2024-06-02 06:43:45.051 PDT [3636] HINT:  Future log output will appear in directory "log".
  6. done
  7. server started
复制代码
服膺:心存敬畏,行有所止。

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

东湖之滨

金牌会员
这个人很懒什么都没写!

标签云

快速回复 返回顶部 返回列表