# 关闭THP # root用户下 # 在 /etc/rc.local 最后添加如下代码 iftest -f /sys/kernel/mm/transparent_hugepage/enabled; then echo never > /sys/kernel/mm/transparent_hugepage/enabled fi iftest -f /sys/kernel/mm/transparent_hugepage/defrag; then echo never > /sys/kernel/mm/transparent_hugepage/defrag fi
echo never > /sys/kernel/mm/transparent_hugepage/enabled echo never > /sys/kernel/mm/transparent_hugepage/defrag
# 为什么要关闭 Transparent Huge Pages (THP) is a Linux memory management system that reduces the overhead of Translation Lookaside Buffer (TLB) lookups on machines with large amounts of memory by using larger memory pages. However, database workloads often perform poorly with THP, because they tend to have sparse rather than contiguous memory access patterns. You should disable THP on Linux machines to ensure best performance with MongoDB.
环境准备
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
tar xf mongodb-linux-x86_64-rhel70-4.2.17.tgz mv mongodb-linux-x86_64-rhel70-4.2.17 /usr/local/mongodb
** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine 建议使用xfs文件系统,但不影响使用
** WARNING: Access control is not enabled for the database. 配置密码之后开启安全
** WARNING: This server is bound to localhost. 配置文件中绑定IP就可以解决
** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'. ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'. 这两条参考上面关闭THP即可
** WARNING: soft rlimits too low. rlimits set to 31192 processes, 100001 files. Number of processes.... vim /etc/security/limits.conf # end of file mongod soft nofile 64000 mongod hard nofile 64000 mongod soft nproc 32000 mongod hard nproc 32000