ubuntu16.04 下kvm安裝
1 檢查CPU虛擬化支援
egrep 'svm|vmx' /proc/cpuinfo
有輸出說明cpu支援虛擬化,在BIOS中開啟inter-VT
2 宿主機網橋設定
bridge不支援NetworkManager,所有在下面的操作前確保NetworkManager處於關閉狀態
cat /etc/NetworkManager/NetworkManager.conf
[main]
plugins=ifupdown,keyfile,ofono
dns=dnsmasq
[ifupdown]
managed=false
配置managed=false
systemctl stop NetworkManager.service
配置網橋
安裝bridge-utils
sudo apt-get install bridge-utils
建立網橋
brctl addbr br0
brctl addif br0 eno1
ifconfig eno1 0.0.0.0
ifconfig br0 192.168.100.20/24
新增預設閘道器
route add -net 0.0.0.0 netmask 0.0.0.0 gw 192.168.100.1
若要永久生效,則如下配置
cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
auto br0
iface br0 inet static
bridge_ports eno1
address 192.168.100.20
netmask 255.255.255.0
gateway 192.168.100.1
bridge_stp off
bridge_fd 0
dns-nameservers 8.8.8.8
重啟網路後,檢視網路
ifconfig
br0 Link encap:Ethernet HWaddr 1c:b7:2c:aa:3d:89
inet addr:192.168.100.20 Bcast:192.168.100.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2007114 errors:0 dropped:3179 overruns:0 frame:0
TX packets:2547163 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:14447174274 (14.4 GB) TX bytes:11544824281 (11.5 GB)
eno1 Link encap:Ethernet HWaddr 1c:b7:2c:aa:3d:89
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:11663933 errors:0 dropped:8384 overruns:0 frame:0
TX packets:2472983 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:16484732144 (16.4 GB) TX bytes:237579422 (237.5 MB)
Interrupt:20 Memory:f7f00000-f7f20000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:5895380 errors:0 dropped:0 overruns:0 frame:0
TX packets:5895380 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:9039764297 (9.0 GB) TX bytes:9039764297 (9.0 GB)
virbr0 Link encap:Ethernet HWaddr 00:00:00:00:00:00
inet addr:192.168.122.1 Bcast:192.168.122.255 Mask:255.255.255.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
以上說明網橋設定ok
2 安裝軟體包
apt install kvm qemu qemu-kvm
透過kvm-ok檢測kvm是否安裝好了
kvm-ok
INFO: /dev/kvm exists
KVM acceleration can be used
這樣說明已經安裝好了
apt install virtinst python-libvirt virt-viewer virt-manager (管理工具)
apt install bridge-utils (網橋管理)
3 建立虛擬磁碟
qemu-img create -f qcow2 /vm/kvm/instance-1.img 20G
建立一個20G大小,名稱為instance-001,格式為qcow2的虛擬磁碟
4 安裝GuestOS
本文采用的是非互動文字方式進行安裝,所以做一下操作
4.1 掛載iso映象
sudo mount /home/wangpei/iso/CentOS-7-x86_64-DVD-1708.iso /mnt/os -o loop
4.2 搭建ftp,允許匿名登入,匿名使用者家目錄指向/mnt
apt instal vsftp
vsftpd配置如下:
anonymous_enable=YES
anon_root=/mnt
4.3 在/mnt下建ks.cfg檔案內容如下:
bootloader --location=mbr --driveorder=vda --append="console=ttyS0 crashkernel=auto"
clearpart --all --initlabel
install
url --url=ftp://192.168.100.20/os
lang en_US.UTF-8
keyboard us
network --onboot yes --device eth0 --bootproto static --ip 192.168.100.115 --netmask 255.255.255.0 --gateway 192.168.100.1 --ipv6 auto --nameserver 8.8.8.8
rootpw --iscrypted $6$1Y6QA0TPid69iYMp$ygY0OFrw06w1oHuOC8D666fO5E9NNUMvCZuL7Uewcq8/Kz5RikrwJ9yOdouSQbTbeEIpzugqllTlSpIBVboQk0
#firewall --service=ssh
firewall --disabled
authconfig --enableshadow --passalgo=sha512
selinux --disabled
timezone --utc Asia/Shanghai
#zerombr
autopart
repo --name="CentOS" --baseurl=ftp://192.168.100.20/os --cost=100
%packages
@core
net-tools
vim
%end
reboot
5 建立虛擬機器
sudo virt-install
--connect qemu:///system
--virt-type kvm
--name instance-1
--metadata description="192.168.100.115"
--ram 2048
--vcpus 2
--disk "/vm/kvm/instance-1.img"
--location ftp://192.168.100.20/os
--extra-arg="ks=ftp://192.168.100.20/ks.cfg"
--nographic
-x console=ttyS0
--force
等到出現localhost login: 說明安裝好了
用virsh list --all檢視虛機例項
virsh list --all
Id Name State
----------------------------------------------------
57 centos7 running
71 instance-1 running
78 instance-2 running
80 instance-3 running
84 instance-4 running
87 ubuntu16.04 running
97 instance-5 running
99 instance-6 running
egrep 'svm|vmx' /proc/cpuinfo
有輸出說明cpu支援虛擬化,在BIOS中開啟inter-VT
2 宿主機網橋設定
bridge不支援NetworkManager,所有在下面的操作前確保NetworkManager處於關閉狀態
cat /etc/NetworkManager/NetworkManager.conf
[main]
plugins=ifupdown,keyfile,ofono
dns=dnsmasq
[ifupdown]
managed=false
配置managed=false
systemctl stop NetworkManager.service
配置網橋
安裝bridge-utils
sudo apt-get install bridge-utils
建立網橋
brctl addbr br0
brctl addif br0 eno1
ifconfig eno1 0.0.0.0
ifconfig br0 192.168.100.20/24
新增預設閘道器
route add -net 0.0.0.0 netmask 0.0.0.0 gw 192.168.100.1
若要永久生效,則如下配置
cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
auto br0
iface br0 inet static
bridge_ports eno1
address 192.168.100.20
netmask 255.255.255.0
gateway 192.168.100.1
bridge_stp off
bridge_fd 0
dns-nameservers 8.8.8.8
重啟網路後,檢視網路
ifconfig
br0 Link encap:Ethernet HWaddr 1c:b7:2c:aa:3d:89
inet addr:192.168.100.20 Bcast:192.168.100.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2007114 errors:0 dropped:3179 overruns:0 frame:0
TX packets:2547163 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:14447174274 (14.4 GB) TX bytes:11544824281 (11.5 GB)
eno1 Link encap:Ethernet HWaddr 1c:b7:2c:aa:3d:89
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:11663933 errors:0 dropped:8384 overruns:0 frame:0
TX packets:2472983 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:16484732144 (16.4 GB) TX bytes:237579422 (237.5 MB)
Interrupt:20 Memory:f7f00000-f7f20000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:5895380 errors:0 dropped:0 overruns:0 frame:0
TX packets:5895380 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:9039764297 (9.0 GB) TX bytes:9039764297 (9.0 GB)
virbr0 Link encap:Ethernet HWaddr 00:00:00:00:00:00
inet addr:192.168.122.1 Bcast:192.168.122.255 Mask:255.255.255.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
以上說明網橋設定ok
2 安裝軟體包
apt install kvm qemu qemu-kvm
透過kvm-ok檢測kvm是否安裝好了
kvm-ok
INFO: /dev/kvm exists
KVM acceleration can be used
這樣說明已經安裝好了
apt install virtinst python-libvirt virt-viewer virt-manager (管理工具)
apt install bridge-utils (網橋管理)
3 建立虛擬磁碟
qemu-img create -f qcow2 /vm/kvm/instance-1.img 20G
建立一個20G大小,名稱為instance-001,格式為qcow2的虛擬磁碟
4 安裝GuestOS
本文采用的是非互動文字方式進行安裝,所以做一下操作
4.1 掛載iso映象
sudo mount /home/wangpei/iso/CentOS-7-x86_64-DVD-1708.iso /mnt/os -o loop
4.2 搭建ftp,允許匿名登入,匿名使用者家目錄指向/mnt
apt instal vsftp
vsftpd配置如下:
anonymous_enable=YES
anon_root=/mnt
4.3 在/mnt下建ks.cfg檔案內容如下:
bootloader --location=mbr --driveorder=vda --append="console=ttyS0 crashkernel=auto"
clearpart --all --initlabel
install
url --url=ftp://192.168.100.20/os
lang en_US.UTF-8
keyboard us
network --onboot yes --device eth0 --bootproto static --ip 192.168.100.115 --netmask 255.255.255.0 --gateway 192.168.100.1 --ipv6 auto --nameserver 8.8.8.8
rootpw --iscrypted $6$1Y6QA0TPid69iYMp$ygY0OFrw06w1oHuOC8D666fO5E9NNUMvCZuL7Uewcq8/Kz5RikrwJ9yOdouSQbTbeEIpzugqllTlSpIBVboQk0
#firewall --service=ssh
firewall --disabled
authconfig --enableshadow --passalgo=sha512
selinux --disabled
timezone --utc Asia/Shanghai
#zerombr
autopart
repo --name="CentOS" --baseurl=ftp://192.168.100.20/os --cost=100
%packages
@core
net-tools
vim
%end
reboot
5 建立虛擬機器
sudo virt-install
--connect qemu:///system
--virt-type kvm
--name instance-1
--metadata description="192.168.100.115"
--ram 2048
--vcpus 2
--disk "/vm/kvm/instance-1.img"
--location ftp://192.168.100.20/os
--extra-arg="ks=ftp://192.168.100.20/ks.cfg"
--nographic
-x console=ttyS0
--force
等到出現localhost login: 說明安裝好了
用virsh list --all檢視虛機例項
virsh list --all
Id Name State
----------------------------------------------------
57 centos7 running
71 instance-1 running
78 instance-2 running
80 instance-3 running
84 instance-4 running
87 ubuntu16.04 running
97 instance-5 running
99 instance-6 running
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/27181165/viewspace-2150649/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- ubuntu16.04 下安裝mysqlUbuntuMySql
- UBuntu16.04下安裝Docker(親測)UbuntuDocker
- Ubuntu16.04下安裝gtsam-3.2.1Ubuntu
- ubuntu16.04下安裝NS3.27UbuntuS3
- ubuntu16.04系統下安裝dockerUbuntuDocker
- ubuntu安裝KVMUbuntu
- ubuntu16.04下的MySQL離線安裝UbuntuMySql
- ubuntu16.04安裝rosUbuntuROS
- 安裝kalibr Ubuntu16.04Ubuntu
- Ubuntu16.04安裝、使用typoraUbuntu
- ubuntu16.04 CUDA, CUDNN 安裝UbuntuDNN
- Ubuntu16.04雙系統安裝及解除安裝Ubuntu
- Ubuntu16.04下安裝破解secureCRT和secureFX的操作記錄UbuntuSecurecrt
- ubuntu16.04下CUDA9.1+OPENCV3.1安裝記錄UbuntuOpenCV
- kvm 安裝 windows 虛擬機器Windows虛擬機
- ubuntu16.04安裝Tomact8UbuntuMac
- ubuntu16.04 安裝 rime輸入法Ubuntu
- Linux 安裝 KVM 虛擬機器Linux虛擬機
- Ubuntu上安裝KVM並配置顯示卡直通Ubuntu
- Ubuntu16.04下安裝CUDA9.0和CUDNN7.0填坑UbuntuDNN
- Ubuntu16.04下安裝QQ的完整操作記錄(經驗證可用)Ubuntu
- Ubuntu16.04安裝最新版nodejsUbuntuNodeJS
- 華碩飛行堡壘安裝Ubuntu16.04Ubuntu
- 在Ubuntu16.04上安裝LEMP環境Ubuntu
- Ubuntu16.04安裝QQ(圖文說明)Ubuntu
- kvm之三:本地安裝虛擬機器虛擬機
- linux mint 19安裝 kvm 軟體包Linux
- 爛泥:KVM安裝centos6.5系統CentOS
- Ubuntu16.04環境下MySQL5.7安裝&配置以及遠端訪問UbuntuMySql
- ubuntu16.04 PHP7安裝與Nginx PHPUbuntuPHPNginx
- Ubuntu16.04 percona MySQL客戶端安裝UbuntuMySql客戶端
- KVM簡介,安裝及常見使用詳解
- Centos7 離線安裝 KVM,並安裝 Csr1000vCentOS
- win8.1平板安裝ubuntu16.04的折騰Ubuntu
- ubuntu16.04安裝cuda8+opencv3.4+tensorflowUbuntuOpenCV
- qemu-kvm安裝and配置橋接和SR-IOV橋接
- KVM之一:安裝準備(基於CentOS6.7)CentOS
- KVM 虛擬機器安裝配置在CentOS6.2虛擬機CentOS