一、 kvm安装 简单的方法:yum install kvm 二、libvirt安装及升级 (1) yum install libvirt libvirt-Python -y (2)默认版本是0.8.1,功能很少,可升级到最新
wget ftp://libvirt.org/libvirt/libvirt-0.9.4.tar.gz cd libvirt-0.9.4 ./configure 以下是大部分可能出现的情况,如果已有安装某些包,可能不需要操作 1 gcc编译器没有安装 yum -y install gcc gcc-c++
2 libxml2 xml2-config >= 2.6.0 ... configure: error: Could not find libxml2 anywhere (see config.log for details). 3 configure: error: You must install the GnuTLS library in order to compile and run libvirt yum install gnutls-devel
4 configure: error: You must install device-mapper-devel/libdevmapper >= 1.0.0 to compile libvirt 5 You must install python-devel to build Python bindings yum install python-devel 6 configure: error: libnl-devel >= 1.1 is required for macvtap support yum install libnl-devel 至此./configure应该可以通过。懒人就用这个 yum install libxml2-devel gnutls-devel device-mapper-devel python-devel libnl-devel -y (3)make && make install 重启libvirtd service libvirtd restart 可能会报错:
1 error: Failed to connect socket to '/usr/local/var/run/libvirt/libvirt-sock': No such file or directory 2 libvirt: Remote error : unable to connect to '/usr/local/var/run/libvirt/libvirt-sock-ro': No such file or directory”
再做个链接 三、服务器网络配置-桥接,目的是使虚拟机通信方便 使用桥接模式,以centos上运行ubuntu虚拟机的网络配置为例 cd /etc/sysconfig/network-scripts cp ifcfg-eth0 ifcfg-br0 //复制后修改 修改 ifcfg-eth0为如下内容 DEVICE=eth0 HWADDR=00:E0:81:D2:7A:F1 //视具体情况定 ONBOOT=yes BRIDGE=br0 修改ifcfg-br0为如下内容 DEVICE=br0 TYPE=Bridge BOOTPROTO=static IPADDR=10.88.0.27 NETMASK=255.255.255.0 GATEWAY=10.88.0.1 ONBOOT=yes
重启网络服务 service network restart |