Type I:虛擬機直接運行在系統硬件上,被稱為裸機型,沒有所謂的宿主機操作系統。他們直接控制硬件資源以及客戶機。這種方案的性能處于主機虛擬化與操作系統虛擬化之間。如xen和vmware ESX
Type II:虛擬機運行在傳統操作系統上,同樣創建的是硬件全仿真實例,被稱為**托管(宿主)**型。Hypervisor構建出一整套虛擬硬件平臺,使用者根據需要安裝新的操作系統和應用軟件,底層和上層的操作系統可以完全無關化。簡單的說這類VMM通常就是宿主機操作系統上的一個應用程序,像其他應用程序一樣受宿主機操作系統的管理,通常抽象為進程。如VMware workstation、KVM。主機虛擬化中VM的應用程序調用硬件資源時需要經過:VM內核->Hypervisor->主機內核,相對來說,性能是幾種虛擬化技術中最差的
文件位置/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
網絡配置文件/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>
存儲池配置文件/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>
創建虛擬網絡
virt-manager添加網絡
驗證網絡可用性
[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連接新創建的網絡
生效:強制關機,再次開機
查看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查看網關
[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網關
[root@localhost ~]# ping 192.168.10.1150ping宿主機
[root@localhost ~]# ping 192.168.139.50ping宿主機的網關
[root@localhost ~]# ping 192.168.139.2ping域名
[root@localhost ~]# ping www.baidu.com虛擬機連接
[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 ~]#