最近服务器被大量外借,所以想借此推进一下虚拟化技术。虚拟机软件特别选用了比较简单的Virtualbox。但是居然被告知软件装不上,无奈之下自己动手,中间确实遇到点小问题,记录下来以做备忘。
1. 安装软件环境
- yum install gcc
- yum install kernel-devel
- yum install kernel-headers
这里需要注意一下当前系统使用的kernel版本与安装相应kernel-headers和kernel-devel要对应上。如果找不到相应的包,那么就用yum install kernel把服务器也升级到同一个版本,然后选择新内核重启。(远程安装可以通过下面的对/boot/grub/grub.conf编辑实现切换指定内核)
2. 安装virtualbox软件
rpm -ivh VirtualBox-4.1-4.1.6_74727_rhel5-1.x86_64.rpm
但是随便调用了下vboxmanage list vms就发现驱动没有编译,根据提示执行编译命令,见到如下报错:
- [root@localhost home]# sudo /etc/init.d/vboxdrv setup
- Stopping VirtualBox kernel modules [确定]
- Uninstalling old VirtualBox DKMS kernel modules [确定]
- Removing old VirtualBox pci kernel module [确定]
- Removing old VirtualBox netadp kernel module [确定]
- Removing old VirtualBox netflt kernel module [确定]
- Removing old VirtualBox kernel module [确定]
- Trying to register the VirtualBox kernel modules using DKMS[失败]
- (Failed, trying without DKMS)
- Recompiling VirtualBox kernel modules [确定]
- Starting VirtualBox kernel modules [失败]
- (Running VirtualBox in a Xen environment is not supported)
3. 安装dkms
这个比较简单,到这里http://linux.dell.com/dkms/去下载一个安装就行了。
然后再执行驱动编译命令,发现还是出错:
- [root@localhost home]# sudo /etc/init.d/vboxdrv setup
- Stopping VirtualBox kernel modules [确定]
- Uninstalling old VirtualBox DKMS kernel modules [确定]
- Removing old VirtualBox pci kernel module [确定]
- Removing old VirtualBox netadp kernel module [确定]
- Removing old VirtualBox netflt kernel module [确定]
- Removing old VirtualBox kernel module [确定]
- Trying to register the VirtualBox kernel modules using DKMS[确定]
- Starting VirtualBox kernel modules [失败]
- (Running VirtualBox in a Xen environment is not supported)
4. 处理Xen环境问题
begin_msg "Starting VirtualBox kernel modules" if [ -d /proc/xen ]; then failure "Running VirtualBox in a Xen environment is not supported" fi
- [root@localhost ~]# uname -ar
- Linux localhost.localdomain 2.6.18-238.el5xen #1 SMP Thu Jan 13 16:41:45 EST 2011 x86_64 x86_64 x86_64 GNU/Linux
- [root@localhost ~]# vim /boot/grub/grub.conf
- default=0
- timeout=5
- splashp_w_picpath=(hd0,0)/boot/grub/splash.xpm.gz
- hiddenmenu
- title CentOS (2.6.18-238.el5xen)
- root (hd0,0)
- kernel /boot/xen.gz-2.6.18-238.el5
- module /boot/vmlinuz-2.6.18-238.el5xen ro root=LABEL=/ rhgb quiet
- module /boot/initrd-2.6.18-238.el5xen.img
- title CentOS-base (2.6.18-238.el5)
- root (hd0,0)
- kernel /boot/vmlinuz-2.6.18-238.el5 ro root=LABEL=/ rhgb quiet
- initrd /boot/initrd-2.6.18-238.el5.img
- virtualbox vt-x is not available
参考文档:
1. virtualbox 与kvm冲突的解决办法 http://blog.csdn.net/zlciai/article/details/5464415