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]# 

 

 

修改后內容如下:

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 ~]# 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM