CentOS7 CPU隔离配置
1. 修改grub
CentOS7中grub存放位置在:/etc/default/grub
初始内容如下:
1 [root@dellserver default]# cat grub 2 GRUB_TIMEOUT=5 3 GRUB_DISTRIBUTOR="$(sed \'s, release .*$,,g\' /etc/system-release)" 4 GRUB_DEFAULT=saved 5 GRUB_DISABLE_SUBMENU=true 6 GRUB_TERMINAL_OUTPUT="console" 7 GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap isolcpus=1--1 nohz_full=1--1 rcu_nocbs=1--1 default_hugepagesz=1GB hugepagesz=1GB hugepages=226 rhgb quiet" 8 GRUB_DISABLE_RECOVERY="true" 9 [root@dellserver default]#
修改后内容如下:
intel_pstate=disable 这个选项在amd的cpu上配置;在intelcpu上不要配置此选项,否则系统启动不来。
1 [root@dellserver default]# cat grub 2 GRUB_TIMEOUT=5 3 GRUB_DISTRIBUTOR="$(sed \'s, release .*$,,g\' /etc/system-release)" 4 GRUB_DEFAULT=saved 5 GRUB_DISABLE_SUBMENU=true 6 GRUB_TERMINAL_OUTPUT="console" 7 GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap isolcpus=1-31 nohz_full=1-31 rcu_nocbs=1-31 default_hugepagesz=1GB hugepagesz=1GB hugepages=226 rcu_nocb_poll audit=0 nosoftlockup nmi_watchdog=0 selinux=0 intel_pstate=disable rhgb quiet" 8 GRUB_DISABLE_RECOVERY="true" 9 [root@dellserver default]#
支持虚拟机的配置如下:
1 [root@dellserver ~]# cat /etc/default/grub 2 GRUB_TIMEOUT=5 3 GRUB_DISTRIBUTOR="$(sed \'s, release .*$,,g\' /etc/system-release)" 4 GRUB_DEFAULT=saved 5 GRUB_DISABLE_SUBMENU=true 6 GRUB_TERMINAL_OUTPUT="console" 7 GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet iommu=pt intel_iommu=on LANG=zh_CN.UTF-8 isolcpus=1-31 nohz_full=1-31 rcu_nocbs=1-31 default_hugepagesz=1GB hugepagesz=1GB hugepages=226 rcu_nocb_poll audit=0 nosoftlockup nmi_watchdog=0 selinux=0 intel_pstate=disable rhgb quiet" 8 GRUB_DISABLE_RECOVERY="true" 9 [root@dellserver ~]#
作用是将cpu的1-11 lcore在启动时分离开,不将进程跑在这些CPU的核上。
作用是在系统启动时将hugepage的默认大小设置为1GB,并创建8个1GB的hugepage。
2. 重新编译image
CentOS7.5的系统,在当前目录执行grub2-mkconfig -o /boot/grub2/grub.cfg得到结果如下:
1 [root@dellserver default]# grub2-mkconfig -o /boot/grub2/grub.cfg 2 Generating grub configuration file ... 3 Found linux image: /boot/vmlinuz-3.10.0-957.27.2.el7.x86_64 4 Found initrd image: /boot/initramfs-3.10.0-957.27.2.el7.x86_64.img 5 Found linux image: /boot/vmlinuz-3.10.0-693.el7.x86_64 6 Found initrd image: /boot/initramfs-3.10.0-693.el7.x86_64.img 7 Found linux image: /boot/vmlinuz-3.10.0-693.el7.x86_64.debug 8 Found linux image: /boot/vmlinuz-0-rescue-62e95b1bacd848bc81b207e1c62ec2e6 9 Found initrd image: /boot/initramfs-0-rescue-62e95b1bacd848bc81b207e1c62ec2e6.img 10 done 11 [root@dellserver default]#
CentOS7.4的系统,在当前目录执行grub2-mkconfig -o /etc/grub2-efi.cfg 得到结果如下:
1 [root@dellserver default]# grub2-mkconfig -o /etc/grub-efi.cfg 2 Generating grub configuration file ... 3 Found linux image: /boot/vmlinuz-3.10.0-957.27.2.el7.x86_64 4 Found initrd image: /boot/initramfs-3.10.0-957.27.2.el7.x86_64.img 5 Found linux image: /boot/vmlinuz-3.10.0-693.el7.x86_64 6 Found initrd image: /boot/initramfs-3.10.0-693.el7.x86_64.img 7 Found linux image: /boot/vmlinuz-3.10.0-693.el7.x86_64.debug 8 Found linux image: /boot/vmlinuz-0-rescue-62e95b1bacd848bc81b207e1c62ec2e6 9 Found initrd image: /boot/initramfs-0-rescue-62e95b1bacd848bc81b207e1c62ec2e6.img 10 done 11 [root@dellserver default]#
3. reboot
重启server后,配置生效。可用过cat /proc/cmdline查看结果:
1 [root@dellserver ~]# cat /proc/cmdline 2 BOOT_IMAGE=/vmlinuz-3.10.0-957.27.2.el7.x86_64 root=/dev/mapper/centos-root ro crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet iommu=pt intel_iommu=on LANG=zh_CN.UTF-8 isolcpus=1-31 nohz_full=1-31 rcu_nocbs=1-31 default_hugepagesz=1GB hugepagesz=1GB hugepages=226 rcu_nocb_poll audit=0 nosoftlockup nmi_watchdog=0 selinux=0 intel_pstate=disable rhgb quiet 3 [root@dellserver ~]#