# 无法增加 db\_shared\_buffers（总内存的0.1%）和 db\_work\_mem（总内存的0.03%）

**URL:** <https://meta.discourse.org/t/cant-increase-db-shared-buffers-0-1-of-total-ram-and-db-work-mem-0-03-of-total-ram/339404>\
**Category:** Support\
**Created:** [2024年十一月29日 22:02 UTC](https://meta.discourse.org/t/cant-increase-db-shared-buffers-0-1-of-total-ram-and-db-work-mem-0-03-of-total-ram/339404 "2024-11-29T22:02:27Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![markersocial](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/markersocial/32/170136_2.png) [@markersocial](https://meta.discourse.org/u/markersocial)\
**Post date:** [2024年十二月5日 08:10 UTC](https://meta.discourse.org/t/cant-increase-db-shared-buffers-0-1-of-total-ram-and-db-work-mem-0-03-of-total-ram/339404/5 "2024-12-05T08:10:20Z")

</div>

> [@mcdanlj](#):
>
> ## Kernel configuration
> 
> Redis（Discourse 构建所依赖的关键组件之一）[强烈建议在使用磁盘持久化时禁用透明大页](https://redis.io/docs/management/optimization/latency/#latency-induced-by-transparent-huge-pages)（Discourse 就是这样做的），我也允许内存超额分配。
> 
> ```plaintext
> echo 'sys.kernel.mm.transparent_hugepage.enabled=never' > /etc/sysctl.d/10-huge-pages.conf
> echo 'vm.overcommit_memory=1' > /etc/sysctl.d/90-vm_overcommit_memory.conf
> sysctl --system
> 
> ```

所以，如果其他人遇到此问题，以上方法解决了我的问题。我不再需要在启动器中编辑 shm-size。

这是在重建过程中注意到此警告后发现的：  
`WARNING 必须启用内存超额分配！否则，在内存不足的情况下，后台保存或复制可能会失败。禁用它也可能在内存不足的情况下导致失败，请参阅 https://github.com/jemalloc/jemalloc/issues/1328。要解决此问题，请将 'vm.overcommit_memory = 1' 添加到 /etc/sysctl.conf，然后重新启动或运行命令 'sysctl vm.overcommit_memory=1' 使其生效。`

---

_[View the full topic](https://meta.discourse.org/t/cant-increase-db-shared-buffers-0-1-of-total-ram-and-db-work-mem-0-03-of-total-ram/339404)._
