将在屏幕上列出所有可用内核:
复制代码
[root@server1 yum.repos.d]# yum search vzkernel
[...]
vzkernel.i686 : The Linux kernel
vzkernel.x86_64 : The Linux kernel
vzkernel-devel.i686 : Development package for building kernel modules to match the kernel
vzkernel-devel.x86_64 : Development package for building kernel modules to match the kernel
vzkernel-firmware.noarch : Firmware files used by the Linux kernel
vzkernel-headers.i686 : Header files for the Linux kernel for use by glibc
vzkernel-headers.x86_64 : Header files for the Linux kernel for use by glibc
[...]
[root@server1 yum.repos.d]#
选择其中之一,并按如下命令进行安装:
复制代码
yum install vzkernel
这一操作应该也会自动更新GRUB引导程序。无论如何,我们现在要打开/boot/grub/menu.lst;现在首个内核中应该已经包含有新的OpenVZ内核了。务必确保default值为0,这样首个内核(也就是OpenVZ内核)才会被自动引导并替换掉默认的CentOS内核。
复制代码
vi /boot/grub/menu.lst
# grub.conf generated by anaconda
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/mapper/vg_server1-lv_root
# initrd /initrd-[generic-]version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title OpenVZ (2.6.32-042stab057.1)
root (hd0,0)
kernel /vmlinuz-2.6.32-042stab057.1 ro root=/dev/mapper/vg_server1-lv_root rd_LVM_LV=vg_server1/lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto KEYBOARDTYPE=pc KEYTABLE=de rd_LVM_LV=vg_server1/lv_swap rd_NO_DM rhgb quiet
initrd /initramfs-2.6.32-042stab057.1.img
title CentOS (2.6.32-279.el6.x86_64)
root (hd0,0)
kernel /vmlinuz-2.6.32-279.el6.x86_64 ro root=/dev/mapper/vg_server1-lv_root rd_LVM_LV=vg_server1/lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto KEYBOARDTYPE=pc KEYTABLE=de rd_LVM_LV=vg_server1/lv_swap rd_NO_DM rhgb quiet
initrd /initramfs-2.6.32-279.el6.x86_64.img
现在我们需要安装几款OpenVZ用户工具:
复制代码
yum install vzctl vzquota
打开/etc/sysctl.conf并确保文件中包含以下设定:
复制代码
vi /etc/sysctl.conf
[...]
net.ipv4.ip_forward = 1
net.ipv4.conf.default.proxy_arp = 0
net.ipv4.conf.all.rp_filter = 1
kernel.sysrq = 1
net.ipv4.conf.default.send_redirects = 1
net.ipv4.conf.all.send_redirects = 0
net.ipv4.icmp_echo_ignore_broadcasts=1
net.ipv4.conf.default.forwarding=1










