https://developer.aliyun.com/article/673007
#查看启用
sysctl -a | grep vm.nr_hugepages
cat /proc/meminfo | grep Huge
cat /proc/meminfo | grep HugePages_
#HugePages_Total值为0,则说明当前系统未启用HugePages功能
#查看大页内存总数
cat /proc/meminfo |grep -i huge
#显示如下
AnonHugePages: 421888 KB
Hugepages_Total: 0 启用数量
Hugepages_Free: 0
Hugepages_Rsvd:0
HugePagesize: 2048KB 页面大小 2M
开16个2MB大页内存
方法一:
sysctl vm.nr_hugepages=16 或者 sysctl -w vm.nr_hugepages=1024
sysctl vm.nr_hugepages=64
sysctl vm.nr_hugepages=128
执行 sysctl -p 使配置生效
方法二:
echo 16 >/sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages
或 echo 16 >/sys/device/system/node/$node/hugepages/hugepages-2048kb/nr_hugepages
通过cat /proc/meminfo |grep -i huge 就可以看到系统中空闲巨页、巨页总数为16
#查看容器内启用配置
(内部文件只读,需要外部启用)
echo always >/sys/kernel/mm/transparent_hugepage/enabled
echo always >/sys/kernel/mm/transparent_hugepage/defrag
volumes:
- "/dev/hugepages:/dev/hugepages"
#检查php-fpm的text大小
size /usr/local/sbin/php-fpm
#php 检查 huge_code_pages 确实已经开启
php -i | grep -i huge