我正在关注这个链接, https://docs.mongodb.com/v3.0/tutorial/transparent-huge-pages/
我得到了输出
cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never]
cat /sys/kernel/mm/transparent_hugepage/defrag
[always] madvise never
这就是我所做的
1)在/etc/init.d/disable-transparent-hugepages创建以下文件:
case $1 in
start)
if [ -d /sys/kernel/mm/transparent_hugepage ]; then
thp_path=/sys/kernel/mm/transparent_hugepage
elif [ -d /sys/kernel/mm/redhat_transparent_hugepage ]; then
thp_path=/sys/kernel/mm/redhat_transparent_hugepage
else
return 0
fi
echo 'never' > ${thp_path}/enabled
echo 'never' > ${thp_path}/defrag
unset thp_path
;;
esac
2)运行
sudo chmod 755 /etc/init.d/disable-transparent-hugepages
3)运行
sudo chkconfig --add disable-transparent-hugepages
4)运行
sudo mkdir /etc/tuned/no-thp
5)创建并编辑 /etc/tuned/no-thp/tuned.conf 以使其包含以下内容:
[main]
include=virtual-guest
[vm]
transparent_hugepages=never
6)运行
sudo tuned-adm profile no-thp
7)
cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never]
cat /sys/kernel/mm/transparent_hugepage/defrag
[always] madvise never
8)重启服务器后结果相同 请帮助我 谢谢
答案1
我在 #!/bin/bash 之后的 /etc/init.d/mongod 中添加了此内容
if test -f /sys/kernel/mm/transparent_hugepage/enabled; then
echo never > /sys/kernel/mm/transparent_hugepage/enabled
fi
if test -f /sys/kernel/mm/transparent_hugepage/defrag; then
echo never > /sys/kernel/mm/transparent_hugepage/defrag
fi
它工作得很好