虚拟映像优化
应优化虚拟机以在KVM管理程序上更高效地运行。 考虑到企业拥有大量的虚拟机管理程序和虚拟机,没有优化,性能可能会受到影响。 应在VM上进行的更改因系统内核设置而异。 在本节中,我将提供您可以采取的各种步骤来优化图像。
在进行CentOS或RedHat安装时,请选择“最小安装”,而不是其他任何内容。 此策略可减小图像的大小。 较小的图像克隆速度更快,即使您使用Kickstart,它们的安装速度也会更快。 此外,您只需要最少的软件包就可以减少安全风险。
# Configure tuned for virtual guest # tuned-adm profile virtual-guest # chkconfig tuned on
tuned是一个系统调优守护程序,它根据配置文件设置各种系统/内核参数。
禁用不需要的服务 保持启用它们会降低启动过程并存在安全风险。 以下是一些可能被关闭的服务:
# for svc in ip6tables cups abrtd abrt-ccpp atd kdump mdmonitor NetworkManager; do chkconfig $svc off; done root# for svc in ip6tables cups abrtd abrt-ccpp atd kdump mdmonitor NetworkManager; do service $svc stop; done # Disable IPv6 if you are not using it. # echo "NETWORKING_IPV6=no IPV6INIT=no" >> /etc/sysconfig/network # echo " # Disable IPv6. net.ipv6.conf.all.disable_ipv6 = 1 net.ipv6.conf.default.disable_ipv6 = 1 " >> /etc/sysctl.conf # smartd monitors hard drives; no need for that on a VM root# service smartd stop root# chkconfig --del smartd # Allow virsh shutdown to turn of the VM. # If we do a minimal CentOS install, acpid is not installed by default. # yum install acpid # chkconfig acpid on # service acpid start
要使用virsh console命令访问VM的控制台,必须通过串行控制台重定向VM控制台输出。 以下步骤说明如何执行此操作:
# Getting serial console to work on KVM with RHEL 6 and also with GRUB # Comment out splashimage and hiddenmenu # Remove 'rhgb' and 'quiet' from the kernel line # Add the 'serial' and the 'terminal' line # Add the last two 'console' parameters on the kernel line # Now try to access the serial console using 'virsh console <hostname>' # cat /etc/grub.conf # grub.conf generated by anaconda # # Note you do not have to rerun grub after making changes to this fil.e # NOTICE: You have a /boot partition. This means that # all kernel and initrd paths are relative to /boot/, e.g., # root (hd0,0) # kernel /vmlinuz-version ro root=/dev/mapper/vg_ns-lv_root # initrd /initrd-[generic-]version.img # boot=/dev/vda default=0 timeout=10 serial --unit=0 --speed=115200 terminal --timeout=5 serial console #splashimage=(hd0,0)/grub/splash.xpm.gz #hiddenmenu title CentOS (2.6.32-431.el6.x86_64) root (hd0,0) kernel /vmlinuz-2.6.32-431.el6.x86_64 ro root=/dev/mapper/vg_ns-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 rd_LVM_LV=vg_ns/lv_root crashkernel=auto KEYBOARDTYPE=pc KEYTABLE=us rd_LVM_LV=vg_ns/lv_swap rd_NO_DM console=tty0 console=ttyS0,115200 initrd /initramfs-2.6.32-431.el6.x86_64.img
本文暂时没有评论,来添加一个吧(●'◡'●)