当前位置:网站首页>KVM virtualization
KVM virtualization
2022-07-05 03:34:00 【xiaotanggao】
KVM virtualization
Virtualization technology
Virtualization technology is The abstraction of resources , Such as virtual machine , Virtual memory, etc
virtualization (Virtualization) Technology first appeared in 20 century 60 s IBM Mainframe systems , stay 70 s System370 It is becoming popular in the series , These machines pass through a kind of machine called ** Virtual machine monitor (Virtual Machine Monitor,VMM)** The program generates many virtual machines that can run independent operating system software on the physical hardware (Virtual Machine) example
VMM The virtual machine monitor is also called Hypervisor, It is a software layer introduced for virtualization . It has downward control over actual physical resources , Show up N Logical resources .
The actual physical environment in which the virtual machine monitor runs , be called The host machine ; The virtual logical host , be called The client .
classification
From the perspective of resource provision
- Platform virtualization : hold CPU, Memory , Peripherals are provided to virtual machines as resources . In the same X86 On the platform , You can virtual multiple X86 platform , Each platform can run its own completely independent operating system . Such as QEMU,KVM,VMware And other virtual machines managed
- Operating system virtualization : If the operating system and the system calls it provides are used as resources , Virtualization is represented by operating system virtualization , for example Linux Container virtualization technology is in the same Linux On the operating system , Virtualize multiple identical operating systems , Each application considers itself running in a separate OS. Such as LXC or Docker And other containers managed
From the implementation of virtualization, it can be divided into
- Type I: The virtual machine runs directly on the system hardware , go by the name of Bare pager type , There is no so-called host operating system . They directly control hardware resources and clients . The performance of this solution is between host virtualization and operating system virtualization . Such as xen and vmware ESX
- Type II: Virtual machines run on traditional operating systems , Also created is a hardware full simulation instance , go by the name of ** trusteeship ( host )** type .Hypervisor Build a complete set of virtual hardware platform , Users install new operating systems and application software as needed , The underlying and upper operating systems can be completely independent . Simply put, this kind of VMM It is usually an application on the host operating system , Like other applications, it is managed by the host operating system , It is usually abstracted as a process . Such as VMware workstation、KVM. In host virtualization VM When calling hardware resources, the application program of :VM kernel ->Hypervisor-> Host kernel , relatively speaking , Performance is the worst of several virtualization technologies
Hypervisor Comparison of management tools
Tools | manufacturer | Lord CPU | The goal is CPU | Main system | Target system |
---|---|---|---|---|---|
qemu | Febrice,Bellard | Inter,AMD,ARM | x86/x86-64/ARM | Windows,Linux,Mac OS | Linux |
kvm | Red Hat | Inter/AMD | x86/x86-64 | Linux | Windows/Linux |
Xen | University of Cambridge ,Inter/AMD | Inter/AMD | x86/x86-64 | Windows/Linux/Solaris | Windows/Linux |
Hyper-V | Microsoft | Inter/AMD | x86/x86-64 | Windows | Windows/Linux |
VMware ESXi Server | VMware | Inter/AMD | x86/x86-64 | Bare metal installation | Windows/Linux |
Oracle VM | Oracle | Inter/AMD | x86/x86-64 | Bare metal installation | Windows/Linux |
KVM framework
KVM The kernel module
- It belongs to the standard Linux Part of the kernel , It is a module that provides virtualization function , The main be responsible for CPU And the virtualization of memory
- Essentially ,KVM It is the driver for managing virtual hardware devices , The driver uses a character device **/dev/kvm**( from KVM Create by itself ) As Management interface , Mainly responsible for vCPU The creation of , Virtual memory allocation ,vCPU Register reading and writing and vCPU Operation of
QEMU
QEMU It is a user mode tool , It can provide Device simulation The function of , Including simulation BIOS、 data bus 、 disk 、 network card 、 The graphics card 、 Sound card 、 keyboard 、 Mouse, etc. .
We know KVM Only responsible for CPU And the virtualization of memory , After loading it , Users can further create virtual machines through tools (KVM Provide the interface ), But only KVM It's not enough , Users cannot directly control the kernel to do things (KVM Interface only , How to create a virtual machine , Distribute vCPU Waiting is not on it ), You have to have a tool that runs in user space ,KVM Of the developers chose the more mature open source virtualization software QEMU As a tool , And modified it , At last formed QEMU-KVM.
stay QEMU-KVM in ,KVM Running in kernel space ,QEMU Run in user space , The actual simulation is created , Manage all kinds of virtual hardware ,QEMU take KVM Integrated into , adopt /ioctl call /dev/kvm, So that CPU The part of the instruction is left to the kernel module ,KVM Realized CPU And the virtualization of memory , but kvm You can't virtualize other hardware devices , therefore qemu And simulation IO equipment ( disk , network card , Video card, etc ) The role of ,KVM add QEMU After that is server virtualization in the full sense . however , because qemu simulation io The reason for the low efficiency of the equipment , Now, semi virtualized virtio Way to virtual IO equipment .
KVM Responsible for providing cpu, Virtual memory
QEMU Responsible for removing CPU And out of memory Virtual of other devices And right Creation and call of various virtual devices
libvirt
- libvirt It's a free set 、 Open source support Linux Under the mainstream virtualization management program C function library , Its aim is to include KVM Various virtualization hypervisors, including, provide a set of convenience 、 Reliable programming interface . The current mainstream Linux The default virtualization management tool on the platform virt-manager,virsh And so on libvirt Development .
- libvirt It is a virtual machine management system for various virtualization platforms API library . Some common virtual machine management tools, such as virsh( similar vim Editor ),virt-install,virt-manager And cloud computing framework platform ( Such as OpenStack,OpenNebula,Eucalyptus etc. ) Are used at the bottom libvirt Application program interface provided .
- libvirt It mainly consists of three parts :API library , A daemon libvirtd And a default command line management tool virsh.
summary
- QEMU Is a stand-alone virtualization solution , Does not depend on KVM( It can do it by itself CPU And memory simulation , It's just less efficient ). and KVM It's another virtualization solution , Yes CPU It's more efficient to carry out virtual operation ( Hardware assisted virtualization ), But it doesn't provide virtualization for other devices , Borrowed QEMU The code is customized , therefore KVM The solution must depend on QEMU. Even later RedHat It was developed later libvirt, I can only simply think that libvirt It's a virtual machine management tool , Still need to go through user space QEMU Come and KVM Interact .
KVM Virtual machine deployment
Environmental preparation
- Linux The host needs to be installed Graphic desktop
To minimize the ——> graphics
yum groupinstall -y “GNOME desktop ”
restart
startx Temporarily open the terminal ( Not recommended )
systemctl set-default graphical.targer
[[email protected] ~]# systemctl get-default
graphical.target
Pay attention to reasonable distribution CPU, Memory , Disk space, etc
Make sure to turn on hardware assisted virtualization
[[email protected] ~]# lscpu|grep ' virtualization '
virtualization : VT-x
Virtualization type : Completely
- see CPU Supported features (vmx:INTEL Virtualization capabilities |svm:AMD Virtualization capabilities )
[[email protected] ~]# grep -E 'svm|vmx' /proc/cpuinfo
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon nopl xtopology tsc_reliable nonstop_tsc eagerfpu pni pclmulqdq vmx ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 invpcid rdseed adx smap clflushopt xsaveopt xsavec xgetbv1 arat pku ospke md_clear spec_ctrl intel_stibp flush_l1d arch_capabilities
install kvm
Clean up KVM Related pre installed environment
[[email protected] ~]# yum remove `rpm -qa |egrep 'qemu|virt|kvm'`
[[email protected] ~]# rm -rf /var/lib/libvirt/
[[email protected] ~]# rm -rf /etc/libvirt/
View groups
[[email protected] ~]# yum grouplist
install kvm grouping ( All packages that can be translated into virtualization will be installed )
[[email protected] ~]# yum install *qemu* *virt* librbd1-devel -y
Turn on libvirt
[[email protected] ~]# systemctl start libvirtd
[[email protected] ~]# systemctl enable libvirtd
[[email protected] ~]# systemctl status libvirtd
[[email protected] ~]# virsh list --all
Id name state
----------------------------------------------------
Make sure kvm Module has been loaded
[[email protected] ~]# lsmod |grep kvm
kvm_intel 188740 0
kvm 637515 1 kvm_intel
irqbypass 13503 1 kvm
Set firewall rules
[[email protected] ~]# systemctl start firewalld.service
[[email protected] ~]# systemctl enable firewalld.service
[[email protected] ~]# firewall-cmd --zone=public --add-masquerade --permanent
success
[[email protected] ~]# firewall-cmd --zone=public --add-masquerade
success
[[email protected] ~]# firewall-cmd --zone=public --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: ens33
sources:
services: dhcpv6-client ssh
ports:
protocols:
masquerade: yes
forward-ports:
source-ports:
icmp-blocks:
rich rules:
Guest OS install
Graphical installation
- Call up virtual system manager
[[email protected] ~]# virt-manager
- Upload system image
[[email protected] ~]# rz
[[email protected] ~]# ls
anaconda-ks.cfg public video file music
CentOS-7-x86_64-Minimal-2009.iso Templates picture download desktop
- Use mirror installation
- Custom configuration ( Click... After configuration : Start installation in the upper left corner )
- You can refer to CentOS7 Installation
Command line installation
- Help information
[[email protected] ~]# virt-install --help
# Only common models are reserved
usage: virt-install --name NAME --memory MB STORAGE INSTALL [options]
Options :
-h, --help show this help message and exit
-n NAME, --name NAME Client instance name
--memory MEMORY Configure guest memory allocation. Ex:
--memory 1024 (in MiB)
--memory 512,maxmemory=1024
--vcpus VCPUS Number of vcpus to configure for your guest. Ex:
--vcpus 5
--vcpus 5,maxvcpus=10,cpuset=1-4,6,8
--cdrom CDROM Optical drive installation media
--disk DISK Specify various options for storage . for example :
--disk size=10 ( Create... In the default location 10GiB Mirror image )
--disk /my/existing/disk,cache=none
--disk device=cdrom,bus=scsi
--disk=?
-w NETWORK, --network NETWORK
Configure the client network interface . for example :
--network bridge=mybr0
--network network=my_libvirt_virtual_net
--network
--graphics GRAPHICS Configure client display settings . for example :
--graphics vnc
--graphics spice,port=5901,tlsport=5902
--graphics none
--graphics vnc,password=foobar,port=5910,keymap=ja
--arch ARCH simulation CPU framework
--autostart Automatically start the domain when the host starts .
--noautoconsole Do not automatically try to connect to the client console
- Installation example
[[email protected] ~]# virt-install \
--name=centos7.6-1 \
--vcpus=1 \
--ram=1024 \
--arch=x86_64 \
--os-type=linux \
--os-variant=rhel7 \
--graphics vnc,listen=0.0.0.0,port=5901,keymap=en-us \
--disk path=/var/lib/libvirt/images/centos7.6-1.img,size=3,format=qcow2 \
--cdrom=/home/CentOS-7-x86_64-Minimal-2009.iso \
--network bridge=virbr0
The selection ( Empty indicates that ) | Replaceable |
---|---|
–graphics vnc,listen=0.0.0.0, port=5901,keymap=en-us | –nographics |
–noautoconsole | |
–network bridge=virbr0 | –bridge=virbr0 |
–ram=1024 | –memory 512,maxmemory=1024 |
–vcpus=1 | –vcpus 1,maxvcpus=4 |
–autostart |
Basic use
- View client
View running virtual machines
[[email protected] ~]# virsh list
Id name state
----------------------------------------------------
View all virtual machines
[[email protected] ~]# virsh list --all
Id name state
----------------------------------------------------
- centos7.6-1 close
View domain information
[[email protected] ~]# virsh dominfo centos7.6-1
Id: 1
name : centos7.6-1
UUID: 92891b9c-37cc-4511-9bf6-59a8170c434c
OS type : hvm
state : running
CPU: 1
CPU Time : 20.5s
Maximum memory : 1048576 KiB
Memory used : 1048576 KiB
persistent : yes
Auto start : Ban
Preservation of Management : no
Security mode : none
Security DOI: 0
Check the virtual machine resource usage
[[email protected] ~]# virt-top
- Start the client
Start virtual machine
[[email protected] ~]# virsh start centos7.6-1
Domain centos7.6-1 Started
[[email protected] ~]# virsh list
Id name state
----------------------------------------------------
1 centos7.6-1 running
Set power on self start
[[email protected] ~]# virsh autostart centos7.6-1
Domain centos7.6-1 Mark as auto start
[[email protected] ~]# virsh dominfo centos7.6-1
Id: 1
name : centos7.6-1
UUID: 92891b9c-37cc-4511-9bf6-59a8170c434c
OS type : hvm
state : running
CPU: 1
CPU Time : 20.7s
Maximum memory : 1048576 KiB
Memory used : 1048576 KiB
persistent : yes
Auto start : Enable
Preservation of Management : no
Security mode : none
Security DOI: 0
- Modify the configuration file /etc/libvirt/qemu/centos7.6-1.xml
file location /etc/libvirt/qemu/centos7.6-1.xml
[[email protected] ~]# 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 Command line modification method or other application using the libvirt API. -->
<domain type='kvm'>
<name>centos7.6-1</name>
<uuid>92891b9c-37cc-4511-9bf6-59a8170c434c</uuid>
<memory unit='KiB'>1048576</memory>
<currentMemory unit='KiB'>1048576</currentMemory>
<vcpu placement='static'>1</vcpu>
<os>
<type arch='x86_64' machine='pc-i440fx-rhel7.0.0'>hvm</type>
<boot dev='hd'/>
</os>
<features>
<acpi/>
<apic/>
[[email protected] ~]# virsh edit centos7.6-1
- Network profile /etc/libvirt/qemu/networks/
[[email protected] ~]# cd /etc/libvirt/qemu/networks/
[[email protected] 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 Command line modification method or other application using the libvirt API. -->
<network>
<name>default</name>
<uuid>481578d7-6728-48fa-8569-09eac31a0273</uuid>
<forward mode='nat'/>
<bridge name='virbr0' stp='on' delay='0'/>
<mac address='52:54:00:61:66:bb'/>
<ip address='192.168.122.1' netmask='255.255.255.0'>
<dhcp>
<range start='192.168.122.2' end='192.168.122.254'/>
</dhcp>
</ip>
</network>
- Storage pool Profile /etc/libvirt/storage/
[[email protected] ~]# cd /etc/libvirt/storage/
[[email protected] storage]# ls
autostart home.xml
[[email protected] 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. -->
<pool type='dir'>
<name>home</name>
<uuid>74ccd74f-30ea-4462-bc85-ca363520a1cf</uuid>
<capacity unit='bytes'>0</capacity>
<allocation unit='bytes'>0</allocation>
<available unit='bytes'>0</available>
<source>
</source>
<target>
<path>/home</path>
</target>
</pool>
- CPU Hot add
[[email protected] ~]# lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 1
On-line CPU(s) list: 0
Command line add
[[email protected] ~]# virsh setvcpus centos7.6-1 2 --live
[[email protected] ~]# lscpu
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 2
On-line CPU(s) list: 0,1
- Memory balloon
KVM Memory balloon technology can adjust the memory used by virtual machines on demand , So as to improve the utilization of memory .linux Memory balloons are supported by default
Semi virtualization driven
Full virtualization driven
Semi virtualization driven
The operating system is modified through the driver , namely Virtio technology ,, Virtual machines directly access the virtualization layer , The steps are reduced , High conversion efficiency
Configure the semi virtualization driver
Network selection virtio
The client checks to see if it supports semi virtualized drivers
[[email protected] ~]# virt-what kvm [[email protected] ~]# ethtool -i eth0 driver: virtio_net version: 1.0.0 firmware-version: expansion-rom-version: bus-info: 0000:00:03.0 supports-statistics: no supports-test: no supports-eeprom-access: no supports-register-dump: no supports-priv-flags: no
Software access :http://www.linux-kvm.org/page/WindowsGuestDrivers/Download_Drivers
To configure
Add network card
virt-manager Graphical configuration
[[email protected] ~]# cd /etc/sysconfig/network-scripts/
[[email protected] network-scripts]# ls
[[email protected] network-scripts]# cp ifcfg-eth0 ifcfg-ens9
Modify the corresponding configuration file
- virsh Command line add
Make sure the client is running
[[email protected] ~]# virsh list
Id name state
----------------------------------------------------
1 centos7.6-1 running
Check the existing network card
[[email protected] ~]# virsh domiflist centos7.6-1
Interface type Source model MAC
-------------------------------------------------------
vnet0 bridge virbr0 virtio 52:54:00:65:4d:a5
vnet1 network default rtl8139 52:54:00:9a:18:f7
Add network card
[[email protected] ~]# virsh attach-interface centos7.6-1 \
--type network \
--source default \
--model virtio \
--config
Successfully attached interface
[[email protected] ~]# virsh domiflist centos7.6-1
Interface type Source model MAC
-------------------------------------------------------
vnet0 bridge virbr0 virtio 52:54:00:65:4d:a5
vnet1 network default rtl8139 52:54:00:9a:18:f7
restart ( You need to shut down first , Reboot , To take effect )
[[email protected] ~]# virsh domiflist centos7.6-1
Interface type Source model MAC
-------------------------------------------------------
vnet0 bridge virbr0 virtio 52:54:00:65:4d:a5
vnet1 network default rtl8139 52:54:00:9a:18:f7
vnet2 network default virtio 52:54:00:83:7b:f1
- Profile add
Profile address
[[email protected] ~]# cd /etc/libvirt/qemu/
[[email protected] 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>
Create a virtual network
virt-manager Add network
- Verify network availability
[[email protected] ~]# ip a
8: virbr1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
link/ether 52:54:00:b6:35:e2 brd ff:ff:ff:ff:ff:ff
inet 192.168.10.1/24 brd 192.168.10.255 scope global virbr1
valid_lft forever preferred_lft forever
- xshell Connect to the newly created network
- take effect : Forced shutdown , Power on again
see ip Address
[[email protected] ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::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 1000
link/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 1000
link/ether 52:54:00:da:57:16 brd ff:ff:ff:ff:ff:ff
inet 192.168.10.150/24 brd 192.168.10.255 scope global noprefixroute dynamic eth1
valid_lft 2714sec preferred_lft 2714sec
inet6 fe80::82c0:907:6163:5dd8/64 scope link noprefixroute
valid_lft forever preferred_lft forever
Check out the gateway
[[email protected] ~]# 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 100
ping gateway
[[email protected] ~]# ping 192.168.10.1150
ping The host machine
[[email protected] ~]# ping 192.168.139.50
ping Gateway of host
[[email protected] ~]# ping 192.168.139.2
ping domain name
[[email protected] ~]# ping www.baidu.com
Virtual machine connection
[[email protected] ~]# ssh [email protected]
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. [email protected]'s password:
Last login: Sun Jan 2 19:48:52 2022
[[email protected] ~]#
Generate network through configuration file
- Write a network configuration file
Get the template file of Network Writing
[[email protected] ~]# cd /etc/libvirt/qemu/networks/
[[email protected] networks]# cp network1.xml network2.xml
[[email protected] networks]# ls
autostart default.xml network1.xml network2.xml
Generate UUID
[[email protected] networks]# uuidgen
e63b6f45-8c1a-4378-8d46-18c8faab3271
Generate MAC Address
[[email protected] networks]# openssl rand -hex 6 |sed -r 's/(..)/\1:/g;s/.$//'
25:a4:ac:61:62:96
# The device is named 52:54:00:xx:xx:xx, You can only change the latter part
Modify the configuration file
[[email protected] networks]# vim network2.xml
<network>
<name>network2</name> Customize
<uuid>e63b6f45-8c1a-4378-8d46-18c8faab3271</uuid> Self generation
<forward mode='nat'/> Network mode
<bridge name='virbr2' stp='on' delay='0'/> Custom bridge name
<mac address='52:54:00:61:62:96'/> Self generation
<domain name='network2'/> Same as custom name
<ip address='192.168.20.1' netmask='255.255.255.0'>
<dhcp>
<range start='192.168.20.10' end='192.168.20.250'/>
</dhcp>
</ip>
</network>
- Generate network based on profile
[[email protected] networks]# virsh net-define network2.xml
from network2 Defining network network2.xml
Turn on the Internet
[[email protected] networks]# virsh net-start network2
The Internet network2 Started
Boot from boot
[[email protected] networks]# virsh net-autostart network2
The Internet network2 Marked as auto start
see
[[email protected] networks]# virsh net-list --all
name state Automatic start persistent
----------------------------------------------------------
default Activities no no
network1 Activities yes yes
network2 Activities yes yes
Bridging mode
- Discontinue use NetworkManager And back up the network card file
[[email protected] ~]# systemctl stop NetworkManager
[[email protected] ~]# systemctl disable NetworkManager
[[email protected] ~]# cp /etc/sysconfig/network-scripts/ifcfg-ens33 /root/
- To create a bridge
- see
[[email protected] ~]# cd /etc/sysconfig/network-scripts/
[[email protected] network-scripts]# ls ifcfg-br1
ifcfg-br1
[[email protected] network-scripts]# cat ifcfg-br1
DEVICE="br1"
ONBOOT="no"
HOTPLUG="yes"
TYPE="Bridge"
BOOTPROTO="none"
IPADDR="192.168.139.50"
NETMASK="255.255.255.0"
GATEWAY="192.168.139.2"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
DHCPV6C="no"
STP="on"
DELAY="0.0"
[[email protected] network-scripts]# cat ifcfg-ens33
DEVICE="ens33"
ONBOOT="no"
HOTPLUG="yes"
BRIDGE="br1"
# The file has been modified , So back up before
- The client uses a bridge
Modify the network card file
[[email protected]~]# cd /etc/sysconfig/network-scripts/
[[email protected] network-scripts]# vim ifcfg-eth0
[[email protected] network-scripts]# systemctl restart network
Bridge mode changed to net Pattern
- Client interface changes
- The host stops the bridge interface
- Delete relevant network card files
[[email protected] network-scripts]# rm -rf ifcfg-br1
[[email protected] network-scripts]# rm -rf ifcfg-ens33
- Restore the original network card file
[[email protected] network-scripts]# mv /root/ifcfg-ens33 ./
Restart the network
[[email protected] network-scripts]# systemctl restart network
start-up NetworkManager
[[email protected] network-scripts]# systemctl start NetworkManager
[[email protected] network-scripts]# systemctl enable NetworkManager
Add hard disk ( Hot plug )
virt-manager Graphically add
[[email protected] ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 1024M 0 rom
vda 252:0 0 5G 0 disk
├─vda1 252:1 0 1G 0 part /boot
└─vda2 252:2 0 4G 0 part
├─centos-root 253:0 0 3.5G 0 lvm /
└─centos-swap 253:1 0 512M 0 lvm [SWAP]
vdb 252:16 0 2G 0 disk
virsh Command addition
- Create and use
[[email protected] ~]# virsh list
Id name state
----------------------------------------------------
1 my1 running
[[email protected] ~]# virsh domblklist my1
The goal is Source
------------------------------------------------
vda /var/lib/libvirt/images/my1.qcow2
vdb /var/lib/libvirt/images/my1-1.qcow2
hdb -
create disk
[[email protected] ~]# qemu-img create -f qcow2 /root/disk.img 1G
Formatting '/root/disk.img', fmt=qcow2 size=1073741824 encryption=off cluster_size=65536 lazy_refcounts=off
# Or use dd Command mode dd if=/dev/zero of=/root/disk.img bs=1M count=1024
Additional disks
[[email protected] ~]# virsh attach-disk my1 --source=/root/disk.img --target vdc --cache writeback --subdriver qcow2
Successfully attached disk
see
[[email protected] ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 1024M 0 rom
vda 252:0 0 5G 0 disk
├─vda1 252:1 0 1G 0 part /boot
└─vda2 252:2 0 4G 0 part
├─centos-root 253:0 0 3.5G 0 lvm /
└─centos-swap 253:1 0 512M 0 lvm [SWAP]
vdb 252:16 0 2G 0 disk
vdc 252:32 0 1G 0 disk
- Delete disk
[[email protected] ~]# virsh detach-disk my1 vdc
Successfully detached the disk
- Persistent additional disks
[[email protected] ~]# virsh attach-disk my1 --source=/root/disk.img --target vdc --cache writeback --subdriver qcow2 --persistent
Successfully attached disk
Delete
[[email protected] ~]# virsh detach-disk my1 vdc
Successfully detached the disk
Storage pool management
Look at the storage pool
[[email protected] ~]# virsh pool-list --all
name state Automatic start
-------------------------------------------
default Activities yes
root Activities yes
Add local storage pool
- Create directory
[[email protected] ~]# mkdir /home/storage
- add to
Add network storage pool
Network storage end
[[email protected] ~]# yum install -y nfs-utils.x86_64
[[email protected] ~]# systemctl start nfs-server
[[email protected] ~]# mkdir /home/nfs-storage
[[email protected] ~]# vim /etc/exports
[[email protected] ~]# cat /etc/exports
/home/nfs-storage 192.168.139.0/24(rw,sync,no_root_squash)
KVM virtual machine
[[email protected] ~]# showmount -e 192.168.139.10
Export list for 192.168.139.10:
/home/nfs-storage 192.168.139.0/24
[[email protected] ~]# mkdir /home/remote-storage
- Add network storage pool
边栏推荐
- Share the newly released web application development framework based on blazor Technology
- De debugging (set the main thread as hidden debugging to destroy the debugging Channel & debugger detection)
- 有个疑问 flink sql cdc 的话可以设置并行度么, 并行度大于1会有顺序问题吧?
- Three line by line explanations of the source code of anchor free series network yolox (a total of ten articles, which are guaranteed to be explained line by line. After reading it, you can change the
- Yyds dry goods inventory intelligent fan based on CC2530 design
- [deep learning] deep learning reference materials
- 看 TDengine 社区英雄线上发布会,听 TD Hero 聊开发者传奇故事
- C file in keil cannot be compiled
- Subversive cognition: what does SRE do?
- Azkaban overview
猜你喜欢
Huawei MPLS experiment
How to define a unified response object gracefully
Devtools的简单使用
About MySQL database connection exceptions
[groovy] string (string splicing | multi line string)
Anchor free series network yolox source code line by line explanation Part 2 (a total of 10, ensure to explain line by line, after reading, you can change the network at will, not just as a participan
Azkaban实战
腾讯云,实现图片上传
Sqoop命令
New interesting test applet source code_ Test available
随机推荐
Use of kubesphere configuration set (configmap)
Flume configuration 4 - customize mysqlsource
glibc strlen 实现方式分析
Usage scenarios and solutions of ledger sharing
Google Chrome CSS will not update unless the cache is cleared - Google Chrome CSS doesn't update unless clear cache
How to define a unified response object gracefully
Pdf things
Anchor free series network yolox source code line by line explanation Part 2 (a total of 10, ensure to explain line by line, after reading, you can change the network at will, not just as a participan
Pat class a 1160 forever (class B 1104 forever)
This + closure + scope interview question
[positioning in JS]
Voice chip wt2003h4 B008 single chip to realize the quick design of intelligent doorbell scheme
LeetCode 234. Palindrome linked list
有个疑问 flink sql cdc 的话可以设置并行度么, 并行度大于1会有顺序问题吧?
Sqoop安装
单项框 复选框
this+闭包+作用域 面试题
Use UDP to send a JPEG image, and UPD will convert it into the mat format of OpenCV after receiving it
[summary of two registration methods]
Basic authorization command for Curl