2021-05-12 14:32:11
Openstack之用apt-get安裝KVM
首先必須在VMware Workstation中開啟每個虛擬機器的虛擬化功能,一般來說支不支援虛擬化,取決於你的物理機的cpu是否支援,必須先在物理機的bios中開啟Intel-VT或者AMD-V選項,如果不知道cpu是否支援虛擬化,可以根據CPU型號自己查一下。
root@u-node3:/home/zxl# egrep -o "(vmx|svm)" /proc/cpuinfo
vmx
出現vmx則說明CPU為Intel系列支援intel-VT,如果是svm,則說明為AMD系列CPU,支援AMD-V虛擬化
Ubuntu自帶的source.list可能會安裝失敗,這裡安裝下載source.list,用sohu源和Ali雲源
root@u-node3:/home/zxl#vim /etc/apt/sources.list
deb http://mirrors.sohu.com/ubuntu/ precise main restricted
deb-src http://mirrors.sohu.com/ubuntu/ precise main restricted
deb http://mirrors.sohu.com/ubuntu/ precise-updates main restricted
deb-src http://mirrors.sohu.com/ubuntu/ precise-updates main restricted
deb http://mirrors.sohu.com/ubuntu/ precise universe
deb-src http://mirrors.sohu.com/ubuntu/ precise universe
deb http://mirrors.sohu.com/ubuntu/ precise-updates universe
deb-src http://mirrors.sohu.com/ubuntu/ precise-updates universe
deb http://mirrors.sohu.com/ubuntu/ precise multiverse
deb-src http://mirrors.sohu.com/ubuntu/ precise multiverse
deb http://mirrors.sohu.com/ubuntu/ precise-updates multiverse
deb-src http://mirrors.sohu.com/ubuntu/ precise-updates multiverse
deb http://mirrors.sohu.com/ubuntu/ precise-backports main restricted universe multiverse
deb-src http://mirrors.sohu.com/ubuntu/ precise-backports main restricted universe multiverse
deb http://mirrors.sohu.com/ubuntu/ precise-security main restricted
deb-src http://mirrors.sohu.com/ubuntu/ precise-security main restricted
deb http://mirrors.sohu.com/ubuntu/ precise-security universe
deb-src http://mirrors.sohu.com/ubuntu/ precise-security universe
deb http://mirrors.sohu.com/ubuntu/ precise-security multiverse
deb-src http://mirrors.sohu.com/ubuntu/ precise-security multiverse
deb http://extras.ubuntu.com/ubuntu precise main
deb-src http://extras.ubuntu.com/ubuntu precise main
deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
root@u-node3:/home/zxl# apt-get update
可以分別安裝如下的軟體
1、安裝kvm/qemu
sudo apt-get install kvm qemu
2、安裝libvirt
sudo apt-get install libvirt-bin libvirt-dev
3、網橋管理工具
sudo apt-get install bridge-utils
4、統一建模語言
sudo apt-get install uml-utilities
5、vnc 虛擬機器檢視工具
sudo apt-get install vncviewer vnc4server
qemu-kvm 和 qemu-system 是 KVM 和 QEMU 的核心包,提供 CPU、記憶體和 IO 虛擬化功能
libvirt-bin 就是 libvirt,用於管理 KVM 等 Hypervisor
virt-manager 是 KVM 圖形化管理工具
bridge-utils 和 vlan,主要是網路虛擬化需要,KVM 網路虛擬化的實現是基於 linux-bridge 和 VLAN
Ubuntu 預設不安裝圖形介面,可以手工安裝一下
sudo apt-get install xinit
sudo apt-get install gdm
sudo apt-get install kubuntu-deskt
安裝KVM
root@u-node3:/home/zxl# apt-get install qemu-kvm ubuntu-vm-builder bridge-utils
啟用KVM核心模組
root@u-node3:/home/zxl# modprobe kvm
root@u-node3:/home/zxl# modprobe kvm_intel
root@u-node3:/home/zxl# modprobe kvm_amd
驗證有沒有載入成功kvm模組
root@u-node4:/home/zxl# lsmod | grep kvm
kvm_intel 144426 0
kvm 468280 1 kvm_intel
檢查kvm是否安裝成功,輸出如下則成功
root@u-node3:/home/zxl# kvm-ok
INFO: /dev/kvm exists
KVM acceleration can be used
新增root使用者進入kvm組
root@u-node3:/home/zxl# adduser root kvm
安裝Libvirt
1:利用原始碼編譯安裝,但首先要自己安裝各種依賴,很麻煩,不是很推薦,然後下載原始碼(http://libvirt.org/sources/)解壓,用make:make install安裝
2:利用apt-get安裝,可以安裝一系列的輔助工具,強烈建議這樣安裝
root@u-node3:/home/zxl# apt-get install libvirt-bin qemu virt-manager
安裝完成後通過如下步驟檢查是否成功
root@u-node4:/home/zxl# virsh list
Id Name State
----------------------------------------------------
root@u-node4:/home/zxl# ps -aux |grep "libvirtd"
Warning: bad ps syntax, perhaps a bogus '-'? See http://procps.sf.net/faq.html
root 3969 0.2 0.4 265044 9444 ? Sl 09:30 0:00 /usr/sbin/libvirtd -d
root 4110 0.0 0.0 9392 932 pts/0 S+ 09:31 0:00 grep --color=auto libvirtd
則表示安裝成功
管理介面
root@u-node3:/home/zxl# virt-manager
可能會報錯,No DBUS daemon Running,則採用下面的進程啟動dbus進程
root@u-node3:/home/zxl# eval `dbus-launch --auto-syntax`
root@u-node3:/home/zxl# virt-manager
則表明安裝成功(但用Xsell遠端連線好像不能開啟,沒有反應)
本文永久更新連結地址:http://www.linuxidc.com/Linux/2017-08/146402.htm
相關文章