Type I:虛擬機(jī)直接運(yùn)行在系統(tǒng)硬件上,被稱為裸機(jī)型,沒有所謂的宿主機(jī)操作系統(tǒng)。他們直接控制硬件資源以及客戶機(jī)。這種方案的性能處于主機(jī)虛擬化與操作系統(tǒng)虛擬化之間。如xen和vmware ESX
Type II:虛擬機(jī)運(yùn)行在傳統(tǒng)操作系統(tǒng)上,同樣創(chuàng)建的是硬件全仿真實(shí)例,被稱為**托管(宿主)**型。Hypervisor構(gòu)建出一整套虛擬硬件平臺(tái),使用者根據(jù)需要安裝新的操作系統(tǒng)和應(yīng)用軟件,底層和上層的操作系統(tǒng)可以完全無關(guān)化。簡(jiǎn)單的說這類VMM通常就是宿主機(jī)操作系統(tǒng)上的一個(gè)應(yīng)用程序,像其他應(yīng)用程序一樣受宿主機(jī)操作系統(tǒng)的管理,通常抽象為進(jìn)程。如VMware workstation、KVM。主機(jī)虛擬化中VM的應(yīng)用程序調(diào)用硬件資源時(shí)需要經(jīng)過:VM內(nèi)核->Hypervisor->主機(jī)內(nèi)核,相對(duì)來說,性能是幾種虛擬化技術(shù)中最差的
文件位置/etc/libvirt/qemu/centos7.6-1.xml
[root@server5 ~]# head -20 /etc/libvirt/qemu/centos7.6-1.xml
<!--
WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE
OVERWRITTEN AND LOST. Changes to this xml configuration should be made using:virsh edit centos7.6-1 命令行修改方法
or other application using the libvirt API.
--><domaintype='kvm'><name>centos7.6-1</name><uuid>92891b9c-37cc-4511-9bf6-59a8170c434c</uuid><memoryunit='KiB'>1048576</memory><currentMemoryunit='KiB'>1048576</currentMemory><vcpuplacement='static'>1</vcpu><os><typearch='x86_64'machine='pc-i440fx-rhel7.0.0'>hvm</type><bootdev='hd'/></os><features><acpi/><apic/>[root@server5 ~]# virsh edit centos7.6-1
網(wǎng)絡(luò)配置文件/etc/libvirt/qemu/networks/
[root@server5 ~]# cd /etc/libvirt/qemu/networks/
[root@server5 networks]# ls
autostart default.xml
<!--
WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE
OVERWRITTEN AND LOST. Changes to this xml configuration should be made using:virsh net-edit default 命令行修改方法
or other application using the libvirt API.
--><network><name>default</name><uuid>481578d7-6728-48fa-8569-09eac31a0273</uuid><forwardmode='nat'/><bridgename='virbr0'stp='on'delay='0'/><macaddress='52:54:00:61:66:bb'/><ipaddress='192.168.122.1'netmask='255.255.255.0'><dhcp><rangestart='192.168.122.2'end='192.168.122.254'/></dhcp></ip></network>
存儲(chǔ)池配置文件/etc/libvirt/storage/
[root@server5 ~]# cd /etc/libvirt/storage/
[root@server5 storage]# ls
autostart home.xml
[root@server5 storage]# vim home.xml
<!--
WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE
OVERWRITTEN AND LOST. Changes to this xml configuration should be made using:virsh pool-edit home
or other application using the libvirt API.
--><pooltype='dir'><name>home</name><uuid>74ccd74f-30ea-4462-bc85-ca363520a1cf</uuid><capacityunit='bytes'>0</capacity><allocationunit='bytes'>0</allocation><availableunit='bytes'>0</available><source></source><target><path>/home</path></target></pool>
配置文件地址
[root@server5 ~]# cd /etc/libvirt/qemu/[root@server5 qemu]# vim centos7.6-1.xml </interface><interface type='network'><mac address='52:54:00:83:7b:f1'/><source network='default'/><model type='virtio'/><address type='pci' domain='0x0000' bus='0x00' slot='0x0a'function='0x0'/></interface>
創(chuàng)建虛擬網(wǎng)絡(luò)
virt-manager添加網(wǎng)絡(luò)
驗(yàn)證網(wǎng)絡(luò)可用性
[root@server5 ~]# ip a
8: virbr1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000link/ether 52:54:00:b6:35:e2 brd ff:ff:ff:ff:ff:ffinet 192.168.10.1/24 brd 192.168.10.255 scope global virbr1valid_lft forever preferred_lft forever
xshell連接新創(chuàng)建的網(wǎng)絡(luò)
生效:強(qiáng)制關(guān)機(jī),再次開機(jī)
查看ip地址
[root@localhost ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00inet 127.0.0.1/8 scope host lovalid_lft forever preferred_lft foreverinet6 ::1/128 scope host valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000link/ether 52:54:00:80:94:b0 brd ff:ff:ff:ff:ff:ff
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000link/ether 52:54:00:da:57:16 brd ff:ff:ff:ff:ff:ffinet 192.168.10.150/24 brd 192.168.10.255 scope global noprefixroute dynamic eth1valid_lft 2714sec preferred_lft 2714secinet6 fe80::82c0:907:6163:5dd8/64 scope link noprefixroute valid_lft forever preferred_lft forever查看網(wǎng)關(guān)
[root@localhost ~]# ip route
default via 192.168.10.1 dev eth1 proto dhcp metric 100
192.168.10.0/24 dev eth1 proto kernel scope link src 192.168.10.150 metric 100ping網(wǎng)關(guān)
[root@localhost ~]# ping 192.168.10.1150ping宿主機(jī)
[root@localhost ~]# ping 192.168.139.50ping宿主機(jī)的網(wǎng)關(guān)
[root@localhost ~]# ping 192.168.139.2ping域名
[root@localhost ~]# ping www.baidu.com虛擬機(jī)連接
[root@server5 ~]# ssh root@192.168.10.150
The authenticity of host '192.168.10.150 (192.168.10.150)' can't be established.
ECDSA key fingerprint is SHA256:0j755uJHNYtgaiAvD5muWjnq1Qxtuvo83VBMx2a85Wc.
ECDSA key fingerprint is MD5:17:5d:03:0d:b8:f5:6d:86:06:6e:35:1d:51:e7:56:a9.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.10.150' (ECDSA) to the list of known hosts.
root@192.168.10.150's password:
Last login: Sun Jan 2 19:48:52 2022
[root@localhost ~]#