In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the knowledge of "how to install and create a virtual machine in KVM". Many people will encounter this dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
System: CentOS7.3
Action:
1. Turn off the NetworkManager service
Systemctl stop NetworkManagersystemctl disable NetworkManager
two。 Install softwar
Yum-y install libvirt qemu-kvm virt-manager virt-viewer virt-install
3. Set up a bridge br0
Virsh iface-bridge eno1 br0
4. Installation startup
Create a storage file
Qemu-img create-f qcow2-o size=20G / virtual/mom/centos6.qcow2
two。 Installation startup
-making the web script vi / ETC _ qemuMuifup script in Qemu-Kvm mode [- n "$1"] Then ip link set $1 up sleep 1 brctl addif $bridge $1 [$?-eq 0] & & exit 0 | | exit 1else echo "Error: no interfacespecified." Exit 1fivi / EtcAccording to QemuMuiFUFUFUBUBING B0if [- n "$1"]; then brctl delif $bridge $1 ip link set $1 down exit 0else echo "Error: no interfacespecified." Exit 1fichmod + x / etc/qemu-ifupchmod + x / etc/qemu-ifdown install CentOS qemu-kvm-name centos6-smp 1-m 1024\-drive file=/virtual/mom/centos6.qcow2,if=virtio,media=disk,index=0,format=qcow2\-drive file=/virtual/iso/CentOS6.iso,index=1,media=cdrom\-net nic,model=virtio\-net tap,ifname=vnet0,script=/etc/qemu-ifup Downscript=/etc/qemu-down\-vga cirrus-balloon virtioWindows qemu-kvm-name win7-smp 1-m 2048\-drive file=/virtual/mom/win7.qcow2\-drive file=/virtual/iso/Windows7.iso,index=1,media=cdrom\-drive file=/virtual/iso/Virtio.iso,index=2,media=cdrom\-net nic,model=virtio\-net tap,ifname=vnet0,script=/etc/qemu-ifup,downscript=/etc/qemu-down\-vga cirrus-balloon virtio after execution is complete Use VNC connection installation to start qemu-kvm-boot c centos6.qcow2- -Virsh virt-install\-- connect qemu:///system\-n centos6\-r 2048\-disk path=/virtual/mom/centos6.qcow2 Size=20,bus=virtio,sparse\-- vcpus=1\-- os-type linux\-- os-variant=rhel6\-- network bridge=br0\-- graphics spice,listen=0.0.0.0,password=111111\-- video qxl\-- channel spicevmc\-- cdrom / virtual/iso/CentOS6.isovirt-install\-- connect qemu:///system\-n win7\-r 2048\-- disk path=/home/virtual/mom/win7.qcow2,size=20 Sparse\-- vcpus=1\-- os-type windows\-- os-variant=win7\-- network bridge=br0\-- graphics spice,listen=0.0.0.0,password=111111\-- video qxl\-- channel spicevmc\-- cdrom / home/virtual/iso/Windows7.iso is completed and remotely installed using the remote-viewer connection Start the virtual machine locally with virt-viewer installation: virsh start centos6 powered off virtual machine: virsh destroy centos6 delete virtual machine: virsh undefine centos6 -configuration file location: / etc/libvirt/qemu/centos6.xml runtime configuration file location: / var/run/libvirt/qemu/centos6.xml
5. Other actions
1.KVM hangs USB interface
The host checks the USB port and finds the id lsusb Bus 002 Device 007: ID 0781Device 5581 SanDisk Corp. Ultra configuration file to add cd / etc/libvirt/qemu vi add.xml: use the command to add: virsh attach-device centos6 add.xml uninstall: virsh detach-device centos6 add.xml
two。 Difference plate
1. Create a difference disk qemu-img create-f qcow2-o backing_file=/virtual/mom/centos6.qcow2 / virtual/diff/cfg.qcow22. Start qemu-kvm via differential disk qemu-kvm-boot c cfg.qcow2 virsh virt-install\-- connect qemu:///system\-- import\-- name=cfg\-- vcpus=1-ram=1024\-- disk path=/home/virtual/diff/cfg.qcow2\-- network bridge=br0\-- graphics spice,listen=0.0.0.0 Password=111111\-os-type linux\-os-variant=rhel6
3. Create a bridge br0 from a file
1) copy ifcfg-eno1 to ifcfg-br0 cd / etc/sysconfig/network-scripts cp ifcfg-eno1 ifcfg-br02) modify ifcfg-eno1 and ifcfg-br0 ifcfg-eno1 DEVICE=eno1 BRIDGE=br0 TYPE=Ethernet UUID=aca327fa-50e8-4977-908d-2723dd26dd97 ONBOOT=yes NM_CONTROLLED=yes HWADDR=D8:CB:8A:33:E5:BB DEFROUTE=yes IPV4_FAILURE_FATAL=yes IPV6INIT=no NAME= "System eno1" ifcfg-br0 DEVICE=br0 TYPE=Bridge ONBOOT=yes NM_CONTROLLED=yes BOOTPROTO=static IPADDR=10.3.132.136 NETMASK=255.255.255 .0 PREFIX=24 GATEWAY=10.3.132.254 DNS1=114.114.114.114 DNS2=8.8.8.8 DEFROUTE=yes IPV4_FAILURE_FATAL=yes IPV6INIT=no NAME= "System br0" 3) restart the server reboot, "how to install and create a virtual machine by KVM", that's all. Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.