KVM的安裝
1、KVM環境配置html
一、修改內核模式爲兼容內核啓動python
查看系統內核信息linux
# uname -ashell
# vi /boot/grub/grub.conf centos
二、關閉selinux,重啓後生效服務器
# vi /etc/sysconfig/selinux 網絡
三、關閉防火牆app
# chkconfig ip6tables offssh
# chkconfig iptables off工具
四、重啓
五、查看是否支持虛擬化
# egrep -c '(vmx|svm)' /proc/cpuinfo
說明:
返回結果爲0則表示CPU不支持虛擬化,若是返回結果非0則表示CPU支持虛擬化。其中vmx爲Intel的CPU指令集,svm爲AMDl的CPU指令集。
2、安裝KVM
一、安裝KVM軟件包
# yum install kvm python-virtinst libvirt tunctl bridge-utils virt-manager qemu-kvm-tools virt-viewer virt-v2v -y
# yum install libguestfs-tools -y
二、查看虛擬機環境
重啓虛擬化接口服務
# /etc/init.d/libvirtd restart
# virsh -c qemu:///system list
# lsmod | grep kvm
# virsh --version
# virt-install --version
# ln -s /usr/libexec/qemu-kvm /usr/bin/qemu-kvm
KVM可視化管理工具
1、kvm管理工具
一、virt-manager
查看安裝版本
# rpm -qa | grep virt-manager
二、virt-manager使用
用xshell工具鏈接centos服務器
打開virt-manage
#virt-manager &
運行此命令,報錯以下:
# virt-manager X11 connection rejected because of wrong authentication. Traceback (most recent call last): File "/usr/share/virt-manager/virt-manager.py", line 383, in main() File "/usr/share/virt-manager/virt-manager.py", line 286, in main raise gtk_error RuntimeError: could not open display
解決辦法
參考博客:
http://blog.chinaunix.net/uid-28863090-id-4203482.html
# yum groupinstall Virtualization "Virtualization Client"
確認一下x11是否開啓了轉發的功能
# grep X11Forwarding –color /etc/ssh/sshd_config
查看一下是否安裝了這些包
# rpm -qa | grep xorg-x11
[root@localhost ~]# rpm -qa | grep xorg-x11 xorg-x11-font-utils-7.2-11.el6.x86_64 xorg-x11-server-utils-7.5-13.el6.x86_64 xorg-x11-drv-ati-firmware-7.1.0-3.el6.noarch xorg-x11-xinit-1.0.9-14.el6.x86_64 xorg-x11-xauth-1.0.2-7.1.el6.x86_64
而後在查看一下,$DISPLAY是否有參數;若是沒有的話就須要本身手動添加一個
# echo $DISPLAY 若是返回結果是空行的話,那就是代表沒有設置display
# DISPLAY=$yourserver_ip 這個寫服務器ip地址!
# export DISPLAY
# echo $DISPLAY
再次運行,顯示結果爲如下內容
報錯參考博客
http://blog.51cto.com/clovemfong/1201547
process 4619: D-Bus library appears to be incorrectly set up; failed to read machine uuid: Failed to open "/var/lib/dbus/machine-id": No such file or directory See the manual page for dbus-uuidgen to correct this issue. D-Bus not built with -rdynamic so unable to print a backtrace Aborted (core dumped)
解決辦法:
# mkdir -p /var/lib/dbus
# dbus-uuidgen > /var/lib/dbus/machine-id
成功打開頁面
#virt-manager &
若是出現亂碼現象
安裝virt-manager字體
#yum install dejavu-lgc-sans-fonts
配置建立一個新的虛擬機
導入存在的虛擬機磁盤
完成配置
環境配置完畢後,開始建立虛擬機。安裝centos7系統
修改網卡配置,改爲自動獲取IP地址
重啓網絡
#systemctl restart network
查看給分配的IP地址
Libvirt和Virt-manager工具會默認建立以客戶機名稱來命名的客戶機的XML配置文件和磁盤鏡像文件。
查看XML配置和鏡像文件
# cd /etc/libvirt/qemu
# ll
默認的磁盤鏡像文件儲存位置
# cd /var/lib/libvirt/images/
在virt-manager系統界面中創建一個到本地或遠程主機的鏈接
輸入centos7自動獲取的IP地址
好吧,鏈接報錯了。不知道如何解決……