最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

KVM虛擬化基礎(chǔ)與實(shí)操過(guò)程

 更新時(shí)間:2025年09月03日 10:09:31   作者:yuxb73  
文章介紹了KVM虛擬化技術(shù)的基本概念、組成組件及常用命令,涵蓋宿主機(jī)、虛擬機(jī)、鏡像文件等術(shù)語(yǔ),詳解NFS配置與熱遷移流程,并分享通過(guò)命令行和圖形界面管理虛擬機(jī)的實(shí)踐經(jīng)驗(yàn)

KVM概念

KVM 核心概念

  • KVM的定義:基于 Linux 內(nèi)核的虛擬化技術(shù),本質(zhì)是一個(gè)內(nèi)核模塊,通過(guò)硬件虛擬化技術(shù)(如 Intel VT 或 AMD-V)實(shí)現(xiàn)對(duì)虛擬機(jī)的支持。
  • KVM 的組成:包括 KVM 內(nèi)核模塊、QEMU(用戶空間工具,負(fù)責(zé)模擬 I/O 設(shè)備等)、libvirt(管理虛擬機(jī)的 API 和工具)。

虛擬機(jī)相關(guān)術(shù)語(yǔ)

  • 宿主機(jī)(Host):運(yùn)行 KVM 的物理服務(wù)器。
  • 虛擬機(jī)(Guest):在宿主機(jī)上創(chuàng)建的虛擬系統(tǒng),如win7、vm2、vm3。
  • 鏡像文件(Image):虛擬機(jī)的磁盤(pán)文件,如 qcow2 格式文件,解釋其特點(diǎn)(動(dòng)態(tài)擴(kuò)展、支持快照等)。

命令行工具解析

常用

virsh

命令補(bǔ)充說(shuō)明:

  • virsh list --all:列出所有虛擬機(jī)(包括運(yùn)行和關(guān)閉狀態(tài)),幫助用戶快速了解虛擬機(jī)整體情況。
  • virsh start/shutdown/destroy:分別對(duì)應(yīng)啟動(dòng)、正常關(guān)閉、強(qiáng)制關(guān)閉虛擬機(jī),強(qiáng)調(diào)destroy的風(fēng)險(xiǎn)(類似拔電源,可能導(dǎo)致數(shù)據(jù)丟失)。
  • virsh dumpxml:導(dǎo)出虛擬機(jī)的 XML 配置文件,該文件記錄了虛擬機(jī)的硬件配置(CPU、內(nèi)存、磁盤(pán)、網(wǎng)絡(luò)等),可用于備份或修改配置。
  • 解釋qemu-img工具:用于管理虛擬機(jī)磁盤(pán)鏡像,如創(chuàng)建(create)、查看信息(info)等操作,說(shuō)明 qcow2 格式相比 raw 格式的優(yōu)勢(shì)(節(jié)省空間、支持壓縮等)。

KVM使用

圖形使用

圖形調(diào)出

可以安裝虛擬機(jī)

上傳鏡像才能安裝虛擬機(jī)

上傳鏡像

安裝虛擬機(jī)

后面直接前進(jìn)就可以

這之前會(huì)彈出是否禁用快捷方式

下面按照正常安裝win7就可以了

到這個(gè)界面用shift+f10

測(cè)試:安裝硬盤(pán)網(wǎng)卡

命令行使用

[root@KVM1 ~]# virsh list --all
 Id   名稱   狀態(tài)
----------------------
 5    win7   running

[root@KVM1 ~]# virsh vcpuinfo win7
VCPU:           0
CPU:            3
狀態(tài):       running
CPU 時(shí)間:   49.1s
CPU關(guān)系:      yyyy

VCPU:           1
CPU:            2
狀態(tài):       running
CPU 時(shí)間:   48.4s
CPU關(guān)系:      yyyy

[root@KVM1 ~]# virsh list
 Id   名稱   狀態(tài)
-------------------

[root@KVM1 ~]# virsh list --all
 Id   名稱   狀態(tài)
-------------------
 -    win7   關(guān)閉

調(diào)出圖形管理頁(yè)面

[root@KVM1 ~]# virsh list
 Id   名稱   狀態(tài)
-------------------

[root@KVM1 ~]# virt-manager
# 
[root@KVM1 ~]# virsh start win7
Domain 'win7' started

[root@KVM1 ~]# virsh list
 Id   名稱   狀態(tài)
----------------------
 6    win7   running

#重啟虛擬機(jī)win7
[root@KVM1 ~]# virsh reboot win7             
Domain 'win7' is being rebooted

#正常關(guān)機(jī),一般都是正常關(guān)機(jī)
[root@KVM1 ~]# virsh shutdown win7         
Domain 'win7' is being shutdown

#強(qiáng)制關(guān)閉虛擬機(jī)(拔電源),系統(tǒng)無(wú)法響應(yīng),實(shí)在沒(méi)辦法再?gòu)?qiáng)制關(guān)機(jī)
[root@KVM1 ~]# virsh destroy win7         
Domain 'win7' destroyed

#設(shè)置虛擬機(jī)隨著KVM一起開(kāi)機(jī)
[root@KVM1 ~]# virsh autostart win7
Domain 'win7' marked as autostarted

#列出隨著宿主機(jī)一起開(kāi)機(jī)的虛擬機(jī)有哪些
[root@KVM1 ~]# virsh list --autostart
 Id   名稱   狀態(tài)
----------------------
 6    win7   running

#關(guān)閉win7隨KVM一起啟動(dòng)
[root@KVM1 ~]# virsh autostart --disable win7
Domain 'win7' unmarked as autostarted

#觀察現(xiàn)象,win7從自啟動(dòng)列表中移除
[root@KVM1 ~]# virsh list --autostart
 Id   名稱   狀態(tài)
-------------------

#查看虛擬機(jī)win7配置文件
[root@KVM1 ~]# virsh dumpxml win7
<domain type='kvm' id='1'>
  <name>win7</name>
  <uuid>e0d07415-c249-4d81-9e68-de33a55bc7d1</uuid>
  <metadata>
    <libosinfo:libosinfo xmlns:libosinfo="http://libosinfo.org/xmlns/libvirt/domain/1.0">
      <libosinfo:os id="http://microsoft.com/win/7"/>
    </libosinfo:libosinfo>
  </metadata>
  <memory unit='KiB'>4194304</memory>
  <currentMemory unit='KiB'>4194304</currentMemory>
  <vcpu placement='static'>2</vcpu>
  <resource>
    <partition>/machine</partition>
  </resource>
  <os>
    <type arch='x86_64' machine='pc-q35-rhel8.6.0'>hvm</type>
    <boot dev='hd'/>
  </os>
  <features>
    <acpi/>
    <apic/>
    <hyperv mode='custom'>
      <relaxed state='on'/>
      <vapic state='on'/>
      <spinlocks state='on' retries='8191'/>
    </hyperv>
    <vmport state='off'/>
  </features>
  <cpu mode='custom' match='exact' check='full'>
    <model fallback='forbid'>EPYC-Milan</model>
    <vendor>AMD</vendor>
    <feature policy='require' name='x2apic'/>
    <feature policy='require' name='tsc-deadline'/>
    <feature policy='require' name='hypervisor'/>
    <feature policy='require' name='tsc_adjust'/>
    <feature policy='require' name='vaes'/>
    <feature policy='require' name='vpclmulqdq'/>
    <feature policy='require' name='spec-ctrl'/>
    <feature policy='require' name='arch-capabilities'/>
    <feature policy='require' name='ssbd'/>
    <feature policy='require' name='virt-ssbd'/>
    <feature policy='disable' name='vmcb-clean'/>
    <feature policy='require' name='rdctl-no'/>
    <feature policy='require' name='skip-l1dfl-vmentry'/>
    <feature policy='require' name='mds-no'/>
    <feature policy='require' name='pschange-mc-no'/>
    <feature policy='disable' name='pcid'/>
    <feature policy='disable' name='perfctr_core'/>
    <feature policy='disable' name='xsaveerptr'/>
    <feature policy='disable' name='amd-stibp'/>
    <feature policy='disable' name='svm'/>
    <feature policy='require' name='topoext'/>
    <feature policy='disable' name='npt'/>
    <feature policy='disable' name='nrip-save'/>
    <feature policy='disable' name='svme-addr-chk'/>
  </cpu>
  <clock offset='localtime'>
    <timer name='rtc' tickpolicy='catchup'/>
    <timer name='pit' tickpolicy='delay'/>
    <timer name='hpet' present='no'/>
    <timer name='hypervclock' present='yes'/>
  </clock>
  <on_poweroff>destroy</on_poweroff>
  <on_reboot>restart</on_reboot>
  <on_crash>destroy</on_crash>
  <pm>
    <suspend-to-mem enabled='no'/>
    <suspend-to-disk enabled='no'/>
  </pm>
  <devices>
    <emulator>/usr/libexec/qemu-kvm</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/win7.qcow2' index='3'/>
      <backingStore/>
      <target dev='sda' bus='sata'/>
      <alias name='sata0-0-0'/>
      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
    </disk>
    <disk type='file' device='cdrom'>
      <driver name='qemu' type='raw'/>
      <source file='/iso/cn_windows_7_enterprise_with_sp1_x64_dvd_u_677685.iso' index='2'/>
      <backingStore/>
      <target dev='sdb' bus='sata'/>
      <readonly/>
      <alias name='sata0-0-1'/>
      <address type='drive' controller='0' bus='0' target='0' unit='1'/>
    </disk>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/win7-1.qcow2' index='1'/>
      <backingStore/>
      <target dev='sdc' bus='sata'/>
      <alias name='sata0-0-2'/>
      <address type='drive' controller='0' bus='0' target='0' unit='2'/>
    </disk>
    <controller type='usb' index='0' model='ich9-ehci1'>
      <alias name='usb'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x1d' function='0x7'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci1'>
      <alias name='usb'/>
      <master startport='0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x1d' function='0x0' multifunction='on'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci2'>
      <alias name='usb'/>
      <master startport='2'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x1d' function='0x1'/>
    </controller>
    <controller type='usb' index='0' model='ich9-uhci3'>
      <alias name='usb'/>
      <master startport='4'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x1d' function='0x2'/>
    </controller>
    <controller type='sata' index='0'>
      <alias name='ide'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x1f' function='0x2'/>
    </controller>
    <controller type='pci' index='0' model='pcie-root'>
      <alias name='pcie.0'/>
    </controller>
    <controller type='pci' index='1' model='pcie-root-port'>
      <model name='pcie-root-port'/>
      <target chassis='1' port='0x10'/>
      <alias name='pci.1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0' multifunction='on'/>
    </controller>
    <controller type='pci' index='2' model='pcie-root-port'>
      <model name='pcie-root-port'/>
      <target chassis='2' port='0x11'/>
      <alias name='pci.2'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x1'/>
    </controller>
    <controller type='pci' index='3' model='pcie-root-port'>
      <model name='pcie-root-port'/>
      <target chassis='3' port='0x12'/>
      <alias name='pci.3'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x2'/>
    </controller>
    <controller type='pci' index='4' model='pcie-root-port'>
      <model name='pcie-root-port'/>
      <target chassis='4' port='0x13'/>
      <alias name='pci.4'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x3'/>
    </controller>
    <controller type='virtio-serial' index='0'>
      <alias name='virtio-serial0'/>
      <address type='pci' domain='0x0000' bus='0x02' slot='0x00' function='0x0'/>
    </controller>
    <interface type='network'>
      <mac address='52:54:00:2a:d9:94'/>
      <source network='default' portid='3f0a21b5-ffee-4b01-92f8-2c6d448c3fbc' bridge='virbr0'/>
      <target dev='vnet0'/>
      <model type='e1000e'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
    </interface>
    <interface type='network'>
      <mac address='52:54:00:9e:14:57'/>
      <source network='default' portid='571c14eb-d753-4446-9746-d680769a286d' bridge='virbr0'/>
      <target dev='vnet1'/>
      <model type='e1000e'/>
      <alias name='net1'/>
      <address type='pci' domain='0x0000' bus='0x04' slot='0x00' function='0x0'/>
    </interface>
    <serial type='pty'>
      <source path='/dev/pts/0'/>
      <target type='isa-serial' port='0'>
        <model name='isa-serial'/>
      </target>
      <alias name='serial0'/>
    </serial>
    <console type='pty' tty='/dev/pts/0'>
      <source path='/dev/pts/0'/>
      <target type='serial' port='0'/>
      <alias name='serial0'/>
    </console>
    <channel type='spicevmc'>
      <target type='virtio' name='com.redhat.spice.0' state='disconnected'/>
      <alias name='channel0'/>
      <address type='virtio-serial' controller='0' bus='0' port='1'/>
    </channel>
    <input type='tablet' bus='usb'>
      <alias name='input0'/>
      <address type='usb' bus='0' port='1'/>
    </input>
    <input type='mouse' bus='ps2'>
      <alias name='input1'/>
    </input>
    <input type='keyboard' bus='ps2'>
      <alias name='input2'/>
    </input>
    <graphics type='spice' port='5900' autoport='yes' listen='127.0.0.1'>
      <listen type='address' address='127.0.0.1'/>
      <image compression='off'/>
    </graphics>
    <sound model='ich9'>
      <alias name='sound0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x1b' function='0x0'/>
    </sound>
    <audio id='1' type='spice'/>
    <video>
      <model type='qxl' ram='65536' vram='65536' vgamem='16384' heads='1' primary='yes'/>
      <alias name='video0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0'/>
    </video>
    <redirdev bus='usb' type='spicevmc'>
      <alias name='redir0'/>
      <address type='usb' bus='0' port='2'/>
    </redirdev>
    <redirdev bus='usb' type='spicevmc'>
      <alias name='redir1'/>
      <address type='usb' bus='0' port='3'/>
    </redirdev>
    <memballoon model='virtio'>
      <alias name='balloon0'/>
      <address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x0'/>
    </memballoon>
  </devices>
  <seclabel type='dynamic' model='selinux' relabel='yes'>
    <label>system_u:system_r:svirt_t:s0:c619,c687</label>
    <imagelabel>system_u:object_r:svirt_image_t:s0:c619,c687</imagelabel>
  </seclabel>
  <seclabel type='dynamic' model='dac' relabel='yes'>
    <label>+107:+107</label>
    <imagelabel>+107:+107</imagelabel>
  </seclabel>
</domain>



#查看win7虛擬機(jī)配置的cpu數(shù)量
[root@KVM1 ~]# virsh vcpucount --active win7
2
#默認(rèn)磁盤(pán)存放目錄
[root@KVM1 ~]# cd /var/lib/libvirt/images/
[root@KVM1 images]# ls
win7-1.qcow2  win7.qcow2 		#win7虛擬機(jī)硬盤(pán)

#查看win7虛擬機(jī)磁盤(pán)長(zhǎng)列表信息
[root@KVM1 images]# ll -h
總用量 8.7G
-rw-------. 1 qemu qemu 21G 9月   2 11:21 win7-1.qcow2
-rw-------. 1 qemu qemu 42G 9月   2 11:34 win7.qcow2

#查看win7虛擬機(jī)硬盤(pán)簡(jiǎn)要信息,虛擬機(jī)關(guān)機(jī)狀態(tài)下看
#可能要關(guān)閉win7后才能查看
[root@KVM1 images]# qemu-img info win7.qcow2  
# 開(kāi)機(jī)狀態(tài)下可能不行
[root@KVM1 images]# qemu-img info win7.qcow2
qemu-img: Could not open 'win7.qcow2': Failed to get shared "write" lock
Is another process using the image [win7.qcow2]?

命令行創(chuàng)建虛擬機(jī)
# 目前所在位置
[root@KVM1 images]# pwd
/var/lib/libvirt/images

#給虛擬機(jī)VM2創(chuàng)建硬盤(pán)vm2.qcow2
[root@KVM1 images]# qemu-img create -f qcow2 vm2.qcow2 20G
Formatting 'vm2.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=21474836480 lazy_refcounts=off refcount_bits=16
[root@KVM1 images]# ls
vm2.qcow2  win7-1.qcow2  win7.qcow2

#顯示創(chuàng)建出來(lái)的新的虛擬機(jī)硬盤(pán)vm2.qcow2屬性
[root@KVM1 images]# qemu-img info vm2.qcow2
image: vm2.qcow2
file format: qcow2
virtual size: 20 GiB (21474836480 bytes)
disk size: 196 KiB
cluster_size: 65536
Format specific information:
    compat: 1.1
    compression type: zlib
    lazy refcounts: false
    refcount bits: 16
    corrupt: false
    extended l2: false
[root@KVM1 images]# cd /iso/
#上傳一個(gè)CentOS-7-x86_64-Minimal-1810.iso到/iso目錄

[root@KVM1 iso]# mkdir /disk
[root@KVM1 iso]# qemu-img create -f qcow2 /disk/vm2.qcow2 20G
Formatting '/disk/vm2.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=21474836480 lazy_refcounts=off refcount_bits=16
[root@KVM1 iso]# virt-install --name vm2 --memory 4096 --vcpus 2 --disk path=/disk/vm2.qcow2 --location /iso/CentOS-7-x86_64-Minimal-1810.iso --network network=default --noautoconsole

開(kāi)始安裝......
搜索文件 vmlinuz......                                    | 6.3 MB  00:00 
搜索文件 initrd.img......                                 |  50 MB  00:00 

域仍在運(yùn)行。安裝可能正在進(jìn)行中。
可以重新連接到控制臺(tái)以完成安裝過(guò)程。

#--name 指定虛擬機(jī)名字
#--memory 指定虛擬機(jī)內(nèi)存
#--vcpus 指定虛擬機(jī)的CPU數(shù)量
#--disk path 指定虛擬機(jī)的磁盤(pán)位置
#--location 指定光盤(pán)鏡像的位置
#--network 指定網(wǎng)絡(luò),KVM默認(rèn)有個(gè)網(wǎng)絡(luò)名為default的NAT網(wǎng)絡(luò)

#查看創(chuàng)建的vm2
[root@KVM1 iso]# virsh list
 Id   名稱   狀態(tài)
----------------------
 1    win7   running
 2    vm2    running

通過(guò)VNC連到虛擬機(jī)中去
# 創(chuàng)建個(gè)vm3虛擬機(jī),通過(guò)VNC管理
[root@KVM1 ~]# qemu-img create -f qcow2 /disk/vm3.qcow2 20G
Formatting '/disk/vm3.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=21474836480 lazy_refcounts=off refcount_bits=16
[root@KVM1 ~]# virt-install --name vm3 --memory 2048 --vcpus 1 --disk path=/disk/vm3.qcow2 --location /iso/CentOS-7-x86_64-Minimal-1810.iso --network network=default --noautoconsole --vnclisten=0.0.0.0 --vncport=5903 --vnc

開(kāi)始安裝......
搜索文件 vmlinuz......                                    | 6.3 MB  00:00 
搜索文件 initrd.img......                                 |  50 MB  00:00 

域仍在運(yùn)行。安裝可能正在進(jìn)行中。
可以重新連接到控制臺(tái)以完成安裝過(guò)程。

#--vnclisten 設(shè)置VNC監(jiān)聽(tīng)地址所有地址
#--vncport=5903 宿主機(jī)監(jiān)聽(tīng)到5093的VNC請(qǐng)求,轉(zhuǎn)到vm3虛擬機(jī)上

[root@KVM1 ~]# systemctl stop firewalld.service

vnc訪問(wèn):

KVM熱遷移實(shí)驗(yàn)

熱遷移原理

  • 說(shuō)明 KVM 熱遷移的概念:在虛擬機(jī)不中斷服務(wù)的情況下,將其從一個(gè)宿主機(jī)遷移到另一個(gè)宿主機(jī)。
  • 共享存儲(chǔ)(如 NFS)在熱遷移中的作用:虛擬機(jī)的磁盤(pán)文件存儲(chǔ)在共享存儲(chǔ)中,遷移時(shí)只需傳輸內(nèi)存狀態(tài)等數(shù)據(jù),確保遷移前后虛擬機(jī)訪問(wèn)的磁盤(pán)一致。
  • 熱遷移的大致流程:暫停源虛擬機(jī)→傳輸內(nèi)存數(shù)據(jù)→同步剩余數(shù)據(jù)→在目標(biāo)宿主機(jī)恢復(fù)虛擬機(jī)運(yùn)行→切換網(wǎng)絡(luò)連接。

準(zhǔn)備環(huán)境

克隆原有的KVM1到KVM2和NFS
修改克隆的主機(jī)名和ip地址
[root@KVM1 ~]# hostnamectl set-hostname KVM2
[root@KVM1 ~]# bash

# 把uuid刪掉另外把“IPADDR=”后的內(nèi)容改了保存即可
[root@KVM2 ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens160 
[root@KVM2 ~]# nmcli connection reload ens160
[root@KVM2 ~]# ip -br a
lo               UNKNOWN        127.0.0.1/8 ::1/128 
ens160           UP             192.168.108.102/24 fe80::20c:29ff:fe9f:e213/64 
virbr0           DOWN           192.168.122.1/24 

#kvm1配置完hosts后scp
[root@KVM1 ~]# vim /etc/hosts
[root@KVM1 ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

192.168.108.100 NFS
192.168.108.101 KVM1
192.168.108.102 KVM2

[root@KVM2 ~]# scp 192.168.108.101:/etc/hosts /etc/hosts
The authenticity of host '192.168.108.101 (192.168.108.101)' can't be established.
ECDSA key fingerprint is SHA256:MqzedPnQ99vEBryF/xQ5yZ1Crn6hD2rAnYXrp2n34kI.
Are you sure you want to continue connecting (yes/no/[fingerprint])? y
Please type 'yes', 'no' or the fingerprint: yes
Warning: Permanently added '192.168.108.101' (ECDSA) to the list of known hosts.
root@192.168.108.101's password: 
hosts                                         100%  221   106.2KB/s   00:00    

創(chuàng)建共享存儲(chǔ)NFS

NFS:
[root@NFS ~]# mkdir /nfs
[root@NFS ~]# vim /etc/exports
[root@NFS ~]# vim /etc/exports
[root@NFS ~]# cat /etc/exports
/nfs *(rw,no_root_squash,no_subtree_check)

#第一列:/nfs共享出去的目錄
#第二列:*代表允許所有網(wǎng)段訪問(wèn)
#rw: 掛載此目錄的客戶端對(duì)該共享目錄具有讀寫(xiě)權(quán)限
#sync:資料同步寫(xiě)入內(nèi)存和磁盤(pán)
#no_root_squash:客戶機(jī)用root訪問(wèn)該共享文件夾時(shí),不映射root用戶,root_squash:客戶機(jī)用root
訪問(wèn)該共享文件夾時(shí),將root用戶映射成匿名用戶
#no_subtree_check:不檢查父目錄權(quán)限

# 重啟NFS服務(wù)
[root@NFS ~]# systemctl restart nfs-server.service 
# 測(cè)試
[root@NFS ~]# showmount -e localhost
Export list for localhost:
/nfs *
[root@KVM2 ~]# showmount -e 192.168.108.100
Export list for 192.168.108.100:
/nfs *

# 停止防火墻服務(wù)
[root@NFS ~]# systemctl stop firewalld.service 

KVM1,KVM2分別創(chuàng)建/NFS目錄用于掛載NFS的/nfs目錄

[root@KVM1 ~]# mkdir /NFS
[root@KVM2 ~]# mkdir /NFS

KVM1上操作

將KVM2添加進(jìn)來(lái)

點(diǎn)擊連接后,后面會(huì)顯示框框,兩個(gè)框框分別輸入yes和密碼123

右擊Details兩個(gè)KVM改名字

KVM1,KVM2添加共享存儲(chǔ)NFS,先點(diǎn)KVM1操作

上傳CentOS鏡像,到KVM1,KVM1使用共享存儲(chǔ)創(chuàng)建虛擬機(jī)

鏡像上傳好后,點(diǎn)擊KVM1,創(chuàng)建虛擬機(jī)

選擇剛才上傳的鏡像

選擇安裝到共享存儲(chǔ)NFS

開(kāi)始遷移

KVM1和KVM2關(guān)閉防火墻

KVM1:
[root@KVM1 ~]# systemctl stop firewalld.service
KVM2:
[root@KVM2 ~]# systemctl stop firewalld.service

# 遷移前
[root@KVM1 ~]# virsh list
 Id   名稱        狀態(tài)
---------------------------
 2    centos7.0   running
[root@KVM2 ~]# virsh list
 Id   名稱   狀態(tài)
-------------------

# 遷移后
[root@KVM1 ~]# virsh list
 Id   名稱   狀態(tài)
-------------------
[root@KVM2 ~]# virsh list
 Id   名稱        狀態(tài)
---------------------------
 1    centos7.0   running


虛擬機(jī)從KVM1跑到KVM2

ping測(cè)試成功

總結(jié)

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • KVM安裝部署全過(guò)程

    KVM安裝部署全過(guò)程

    本文介紹KVM虛擬化技術(shù)的架構(gòu)與原理,闡述其與QEMU的協(xié)作機(jī)制,涵蓋Red Hat Linux下的安裝步驟、環(huán)境配置及web管理界面部署,重點(diǎn)說(shuō)明KVM支持硬件加速、資源超分和多種管理工具的集成應(yīng)用
    2025-09-09
  • KVM虛擬化基礎(chǔ)與實(shí)操過(guò)程

    KVM虛擬化基礎(chǔ)與實(shí)操過(guò)程

    文章介紹了KVM虛擬化技術(shù)的基本概念、組成組件及常用命令,涵蓋宿主機(jī)、虛擬機(jī)、鏡像文件等術(shù)語(yǔ),詳解NFS配置與熱遷移流程,并分享通過(guò)命令行和圖形界面管理虛擬機(jī)的實(shí)踐經(jīng)驗(yàn)
    2025-09-09
  • 詳解kvm部署三個(gè)虛擬機(jī)實(shí)現(xiàn) WordPress 實(shí)驗(yàn)

    詳解kvm部署三個(gè)虛擬機(jī)實(shí)現(xiàn) WordPress 實(shí)驗(yàn)

    這篇文章主要介紹了詳解kvm部署三個(gè)虛擬機(jī)實(shí)現(xiàn) WordPress 實(shí)驗(yàn),小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2018-11-11
  • kvm安裝和刪除虛擬機(jī)的方法

    kvm安裝和刪除虛擬機(jī)的方法

    Linux系統(tǒng)下常用的虛擬機(jī)是KVM(Kernel-based Virtual Machine的簡(jiǎn)稱,是一個(gè)開(kāi)源的系統(tǒng)虛擬化模塊)。這篇文章主要給大家介紹了kvm安裝和刪除虛擬機(jī)的方法,文中介紹的很詳細(xì),有需要的朋友們可以參考借鑒,下面來(lái)一起看看吧。
    2016-11-11
  • Centos7下搭建KVM虛擬機(jī)的方法

    Centos7下搭建KVM虛擬機(jī)的方法

    本篇文章主要介紹了Centos7下搭建KVM虛擬機(jī)的方法,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧。
    2017-03-03
  • KVM虛擬化安裝部署及管理教程

    KVM虛擬化安裝部署及管理教程

    這篇文章主要為大家介紹了KVM虛擬化,kvm的安裝部署及管理教程,文中示例過(guò)程 非常詳細(xì),有需要的朋友可以借鑒參考下,希望能夠有所幫助
    2021-10-10
  • kvm?透?jìng)黠@卡至win10虛擬機(jī)的方法

    kvm?透?jìng)黠@卡至win10虛擬機(jī)的方法

    這篇文章主要介紹了kvm?透?jìng)黠@卡至win10虛擬機(jī),本文通過(guò)命令腳本實(shí)例代碼相結(jié)合給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2022-09-09
  • ubuntu kylin虛擬機(jī)中安裝KVM

    ubuntu kylin虛擬機(jī)中安裝KVM

    這篇文章主要介紹了ubuntu kylin虛擬機(jī)中安裝KVM的相關(guān)資料,需要的朋友可以參考下
    2016-11-11
  • 詳解基于本地存儲(chǔ)的kvm虛擬機(jī)在線遷移

    詳解基于本地存儲(chǔ)的kvm虛擬機(jī)在線遷移

    本篇文章主要介紹了基于本地存儲(chǔ)的kvm虛擬機(jī)在線遷移,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2016-12-12
  • CentOS?8?安裝調(diào)試KVM的詳細(xì)步驟

    CentOS?8?安裝調(diào)試KVM的詳細(xì)步驟

    這篇文章主要介紹了CentOS?8?KVM?的安裝調(diào)試,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2022-04-04

最新評(píng)論

博爱县| 浏阳市| 克山县| 乡城县| 建水县| 皮山县| 婺源县| 尉犁县| 雅江县| 东兰县| 扶沟县| 鄂托克前旗| 满城县| 兴海县| 富裕县| 修水县| 徐闻县| 雅安市| 巢湖市| 陆良县| 广德县| 盱眙县| 永新县| 黄平县| 安远县| 板桥市| 西青区| 鄄城县| 江源县| 邵阳县| 崇州市| 青岛市| 民和| 晴隆县| 徐州市| 萝北县| 邵东县| 康定县| 宁晋县| 漳州市| 延寿县|