我们在 Ubuntu 机器上运行了 postgres 9.1。postgres 数据库大小为 155GB,大约有 13200 个表。Ubuntu 机器有 120GB RAM。Ubuntu 机器是一个 docker 容器。
当尝试备份数据库时,失败并显示:
pg_dump: WARNING: out of shared memory
pg_dump: SQL command failed
pg_dump: Error message from server: ERROR: out of shared memory
HINT: You might need to increase max_locks_per_transaction.
因此我们将的值增加到max_locks_per_transaction
1024 postgresql.conf
,但 postgres 却无法启动。
root@abc:# /etc/init.d/postgresql restart
* Restarting PostgreSQL 9.1 database server
* The PostgreSQL server failed to start. Please check the log output:
2018-02-04 03:27:22 UTC FATAL: could not create shared memory segment: Invalid argument
2018-02-04 03:27:22 UTC DETAIL: Failed system call was shmget(key=5432001, size=70123520, 03600).
2018-02-04 03:27:22 UTC HINT: This error usually means that PostgreSQL's request for a shared memory
segment exceeded your kernel's SHMMAX parameter. You can either reduce the request size or reconfigure
the kernel with larger SHMMAX. To reduce the request size (currently 70123520 bytes), reduce PostgreSQL's
shared memory usage, perhaps by reducing shared_buffers or max_connections. If the request size is
already small, it's possible that it is less than your kernel's SHMMIN parameter, in which case raising
the request size or reconfiguring SHMMIN is called for. The PostgreSQL documentation contains more information
about shared memory configuration.
因此,当我们尝试改变的值时SHMMAX
,它失败了:
# echo 1134217728 >/proc/sys/kernel/shmmax
bash: /proc/sys/kernel/shmmax: Read-only file system
知道哪里出了问题以及如何处理吗?