Linux虛擬機器安裝使用者指南
1. 安裝virt-manager
yum install virt-manager.x86_64
yum install virt-viewer.x86_64
yum install libvirt-devel.x86_64
yum install libvirt-python.x86_64
yum install libvirt.x86_64
2. 修改配置檔案以便使用vnc連線,vnc_listen改為0.0.0.0
/etc/libvirt/qemu.conf
vnc_listen ="0.0.0.0"
重啟libvirtd服務:
sudo service libvirtd restart
3. 建立一個虛擬硬碟centos7.img
qemu-img create-f qcow2 centos7.img 64G
不要事先建立qcow2格式的磁碟檔案,該檔案建立之後的初始大小隻有256kB。CentOS系統安裝時會因為磁碟空間不足而退出。
4. 通過virt-install建立虛擬機器
virt-install - Linux man page
General Options
General configuration parameters that apply to alltypes of guest installs.
-n NAME , --name=NAME(指定虛擬機器名字)
Name of the new guest virtual machine instance.This must be unique amongst all guests known to the hypervisor on theconnection, including those not currently active.Tore-define an existing guest, use the
-r MEMORY , --ram=MEMORY(指定記憶體大小)
Memory to allocate for guest instance in megabytes.If the hypervisor does not have enough free memory, it is usual for it toautomatically take memory away from the host operating system to satisfy thisallocation.
InstallationMethod options
-c CDROM , --cdrom=CDROM
File or device use as a virtual CD-ROM device forfully virtualized guests. It can be path to an ISO image, or toa CDROMdevice. It can also be a URL from which to fetch/access aminimal boot ISO image. The URLs take the same format as describedfor the "--location" argument. If a cdrom has beenspecified via the "--disk" option, andneither "--cdrom" nor any other install option isspecified, the "--disk" cdrom is used as the install media.
sudo virt-install \
-n centos7vm \
-r 4096 \
--vcpus=4 \
--hvm \
--accelerate \
--os-type=linux\
--disk path=/home/elvis/virtualmachine/centos7.img,size=80,bus=virtio,cache=none\
--vnc \
--networkbridge=virbr0 \
-c /home/elvis/virtualmachine/CentOS-7-x86_64-DVD-1511.iso
5. 安裝vnc客戶端:vncviewer
在Mac或Windows本機上採用vnc客戶端連線開發機KFC中正在啟動的虛擬機器,通過vnc介面操作安裝CentOS
VNC Viewer 連線成功後閃退的解決方法
VNC是個不錯的工具,採用VNC Viewer來連線一臺伺服器時,輸入密碼連上後直接閃退,可能是ColourLevel的問題。
Solution: 設定Option-->Advanced-->Expert找到ColourLevel,預設值是pal8,修改為rgb222或full。
6. 安裝CentOS
從CDROM裝完CentOS後,重新開機啟動後顯示:
Initial setup of CentOS Linux 7 (core)
1) [x] Creat user 2) [!] License information
(no user will be created) (license not accepted)
Please make your choice from above [‘q’ to quit |‘c’ to continue | ‘r’ to refresh]:
解決方法:
輸入“1”,按Enter鍵
輸入“2”,按Enter鍵
輸入“q",按Enter鍵
輸入“yes”,按Enter鍵
7. 停止虛擬機器
命令: sudo virsh stop centos7vm
8. 虛擬機器開機
命令: sudo virsh start centos7vm
開始之後就可以通過VNCViewer連結該虛擬機器了。