MongoDB 7和8中transparent_hugepage的差异化

##

MongoDB 7/8中transparent_hugepage的差异化

1、官网概述

https://www.mongodb.com/zh-cn/docs/manual/administration/production-checklist-operations/

如果运行 MongoDB 8.0 或更高版本,请启用透明大页。
如果运行 MongoDB 7.0 或更早版本,请禁用透明大页。


已升级MongoDB 8.0中的 TCMalloc
从MongoDB 8.0开始, MongoDB使用 TCMalloc 的升级版本,可通过启用透明大页来提高性能。 如果您使用的是MongoDB 8.0或更高版本,请参阅启用透明大页 (THP)。

2、自管理部署遇到的问题

[root@mongodb01 ~]# mongosh
Current Mongosh Log ID: 67565f732b5f3074a9482f8a
Connecting to:          mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+2.2.12
Using MongoDB:          8.0.3
Using Mongosh:          2.2.12
mongosh 2.3.4 is available for download: https://www.mongodb.com/try/download/shell

For mongosh info see: https://docs.mongodb.com/mongodb-shell/

------
   The server generated these startup warnings when booting
   2024-12-09T11:09:39.273+08:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted
   2024-12-09T11:09:39.274+08:00: For customers running the current memory allocator, we suggest changing the contents of the following sysfsFile
   2024-12-09T11:09:39.274+08:00: For customers running the current memory allocator, we suggest changing the contents of the following sysfsFile
   2024-12-09T11:09:39.274+08:00: We suggest setting the contents of sysfsFile to 0.
   2024-12-09T11:09:39.274+08:00: Your system has glibc support for rseq built in, which is not yet supported by tcmalloc-google and has critical performance implic                      ations. Please set the environment variable GLIBC_TUNABLES=glibc.pthread.rseq=0
------

3、解决问题

3.1、第一个问题
   2024-12-09T11:09:39.274+08:00: Your system has glibc support for rseq built in, which is not yet supported by tcmalloc-google and has critical performance implic                      ations. Please set the environment variable GLIBC_TUNABLES=glibc.pthread.rseq=0
[root@mongodb01 ~]# vi /usr/lib/systemd/system/mongod.service
Environment="GLIBC_TUNABLES=glibc.pthread.rseq=0"

[root@mongodb01 ~]# systemctl daemon-reload
[root@mongodb01 ~]# systemctl restart mongod
3.2、第二个问题
   2024-12-09T11:09:39.274+08:00: For customers running the current memory allocator, we suggest changing the contents of the following sysfsFile
   2024-12-09T11:09:39.274+08:00: For customers running the current memory allocator, we suggest changing the contents of the following sysfsFile
echo always > /sys/kernel/mm/transparent_hugepage/enabled
echo defer+madvise > /sys/kernel/mm/transparent_hugepage/defrag

检查结果

[root@mongodb01 ~]# cat /sys/kernel/mm/transparent_hugepage/enabled && cat /sys/kernel/mm/transparent_hugepage/defrag && cat /sys/kernel/mm/transparent_hugepage/khugepaged/max_ptes_none && cat /proc/sys/vm/overcommit_memory
[always] madvise never
always defer [defer+madvise] madvise never
511
1
3.3、第三个问题
   2024-12-09T11:09:39.274+08:00: We suggest setting the contents of sysfsFile to 0.
grep "sysfsFile"  /mongodb/log/mongod.log

{"t":{"$date":"2024-12-09T11:11:55.214+08:00"},"s":"W",  "c":"CONTROL",  "id":8640302, "ctx":"initandlisten","msg":"We suggest setting the contents of sysfsFile to 0.","attr":{"sysfsFile":"/sys/kernel/mm/transparent_hugepage/khugepaged/max_ptes_none","currentValue":511},"tags":["startupWarnings"]}

[root@mongodb01 ~]# echo 0 > /sys/kernel/mm/transparent_hugepage/khugepaged/max_ptes_none

3.4、正确的值
[root@mongodb01 ~]#  cat /sys/kernel/mm/transparent_hugepage/enabled && cat /sys/kernel/mm/transparent_hugepage/defrag && cat /sys/kernel/mm/transparent_hugepage/khugepaged/max_ptes_none && cat /proc/sys/vm/overcommit_memory
[always] madvise never
always defer [defer+madvise] madvise never
0
1

3.5、检查结果
[root@mongodb01 ~]# systemctl restart mongod

[root@mongodb01 ~]# mongosh
Current Mongosh Log ID: 6756b9c9e1a99dc69fe94969
Connecting to:          mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+2.3.4
Using MongoDB:          8.0.4
Using Mongosh:          2.3.4

For mongosh info see: https://www.mongodb.com/docs/mongodb-shell/

------
   The server generated these startup warnings when booting
   2024-12-09T17:34:15.107+08:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted
------

Enterprise test>

4、官网解决方法

禁用:https://www.mongodb.com/zh-cn/docs/manual/tutorial/disable-transparent-huge-pages/

启用:https://www.mongodb.com/zh-cn/docs/manual/administration/tcmalloc-performance/

使用systemd

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值