在centos7安裝KVM及使用圖形化界面生成與管理虛機


一、VMware虛擬機上的CPU開啟支持虛擬化

 二、Virsh的安裝

      1)安裝kvm和libvirted

#yum install  -y qemu-kvm openssl  #安裝虛擬化工具軟件包和遠程連接 
#
yum install -y libvirt #安裝virt-install工具,用來創建虛擬機
#yum install -y virt-manager #安裝KVM 圖形化管理工具

     2)  啟動libvirtd,並將它設為開機啟動    

#systemctl start libvirtd && systemctl enable libvirtd

     3) 啟動后使用ifconfig查看,發現會多出來一塊virbr0的網卡說明libvirtd啟動成功,如果默認沒有ifconfig命令,使用yum install -y net-tools安裝,如果能看見virbr0,就表示成功 

#yum install -y net-tools
#ifconfig
eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.129  netmask 255.255.255.0  broadcast 192.168.0.255
        inet6 fe80::20c:29ff:fef9:6739  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:f9:67:39  txqueuelen 1000  (Ethernet)
        RX packets 13022  bytes 15452626 (14.7 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 5237  bytes 568995 (555.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 0  (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0 virbr0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255
        ether 00:00:00:00:00:00  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

      4) SecureCRT通過virt-manager啟用圖形化界面

         1、windows安裝Xming 
           下載地址:https://sourceforge.net/projects/xming/ 
           下載完安裝好啟動就行了。 

          2、設置一下SecureCRT的會話選項   

                     

 

             3. vi /etc/ssh/sshd_config,確定下圖的設置為yes 

 

                       

 

              4、CentOS7.2最小化安裝后(不用安裝GUI),需要安裝支持圖形幾個X11的rpm包,其中xorg-x11-server-utils是圖形化主安裝包,而xorg-x11-apps則包含了測試要用的的xclock命令。     

[root@localhost ~]# yum install -y xorg-x11-server-utils xorg-x11-apps xorg-x11-utils

              5、Windows主機上雙擊運行Xmanager - Passive,會在任務欄中出現Xmanager - Passive的圖標,鼠標懸浮其上會顯示圖形化監聽的設備為[:0.0]

         

            6、在linux主機上以root用戶執行xhost +命令打開x-window的訪問權限(會提示xhost:  unable to open display "",不用管它)。如果服務器是圖形化界面啟動的,xhost +命令可以不用執行,如果不是,則運行下面的命令

[root@localhost ~]# xhost +
access control disabled, clients can connect from any host

            7、切換到其他需要執行圖形化命令的用戶,如virt-manager,定義圖形化顯示的地址變量,其中ip地址為運行CRT的windows主機地址,監聽設備為上面Xmanager - Passive的監聽的設備

[root@localhost ~]$  export DISPLAY=192.168.2.11:0.0

           8、啟用virt-manager命令

#virt-manager

     

   

 報錯匯總:

 錯誤一:        

# virt-manager 

Unable to initialize GTK: could not open display

    確保有安裝xorg-x11-xauth

    #yum -y install xorg-x11-xauth

   退出secureCRT后從新登錄,然后再調用virt-manager即可。

 錯誤二:

# virt-manager 

process 2827: 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

確保libvirtd開啟狀態:

# /etc/init.d/libvirtd status libvirtd is stopped # /etc/init.d/libvirtd start

 

 三、新建一台KVM虛機

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM