In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
1. What is virtualization management?
Put some things in the real host of linux on the virtual machine to manage, and then manage the virtual machine and the machine. In fact, the virtual machine and the real machine have the same function, but the real machine is the operating system, takes up a lot of disk space, and the virtual machine is a piece of software that takes up less space.
two。 Why virtualization management?
The number of servers in the actual enterprise is very large, and the heat dissipation of the server is very large when it is running. For the sake of safety, a large number of refrigeration devices are needed, and the power consumption of refrigeration is related to the number of servers. In order to reduce energy consumption, enterprises should reduce the number of servers as much as possible, so install virtual machines on servers and use virtual machines to replace part of the work of other servers. In this way, the number of servers can be reduced. Enterprise energy is mainly consumed in refrigeration. Now energy is important in enterprises, and low-carbon and green development is advocated.
3. What conditions are required for virtualization management
Check whether the real server meets the criteria for virtualization management: see if the cpu of your system supports full virtualization
Method: cat / proc/cpuinfo to see if there is an instruction set of virtualization
4. Manually install the virtual machine
1. The installation image of the virtual machine has been downloaded, and the path where it is stored should be clear.
two。 Enter virt-manager in the shell in the real machine (must be a super user)
3 > Click the small TV in the upper left corner, and the following interface will appear. Select local installation.
4 > Select the storage path of the virtual machine image
5 > Select the size of allocated memory and cpu
6 > Select to allocate hard disk size
7 > fill in the virtual machine name
8 > set the hard disk and network card of the virtual machine to virtualization, and start the installation
9 > Select the installation version
10 > Select the language of the installation process
11 > set relevant parameters
12 > set password
5. How to install a virtual machine with commands
1. In / var/bin vim xx.sh
two。 Write shell script newline character\ No spaces
1 > the parameters are described as follows:
#! / bin/bash
Header of the shell script
Virt-install\
Use commands and newline characters
-name $1\
Name, $1 environment variable, and newline character
-cdrom / home/kiosk/Downloads/rhel-server-7.3-x86_64-dvd.iso\
Storage path and newline character of the image
-ram 1024\
Occupied memory size and newline character
-vcpus 1\
Occupies cpu size and newline character
-disk / var/lib/libvirt/images/$1.qcow2,size=6,bus=virtio\
Related information and newline characters of physical hard disk
-network bridge=br0,model=virtio & > / dev/null &
Information about the network and directing the error to the trash can to keep it from occupying the terminal
3. Enter the name of the sh xx.sh virtual machine directly into the shell of the real machine, and you can see the virtual machine
5. Management of virtual machine
Command: virsh
Virsh list
List all virtual machines that are being turned on
Virsh list-all lists all virtual machines, including those that are on and off
Virsh list lists all virtual machines that are being turned on
Virsh start xx enables the xx virtual machine
Virsh destroy shuts down the virtual machine
Virsh undefine name permanently shuts down the virtual machine
Virsh create xx.xml one-time use of replicated virtual machines, turn it off and there will be no more
Virsh define xx.xml permanently uses the virtual machine, the shutdown is still in
6. Replication of virtual machine
1. Copy the hard disk information scp root@ip:/var/lib/libvirt/images/xx.qcow2 / mnt/ of the other virtual machine (note: here is the address where you want to create it)
two。 Copy the hardware information of each other's virtual machine scp root@ip:/etc/libvirt/qemu/westos.xml / mnt/
3. Put the hard disk information and hardware information in the same directory mv / mnt/generic.qcow2 / var/lib/libvirt/images/
4.virsh create / mnt/xx.xml
Virsh define / mnt/westos.xml permanently uses the virtual machine, the shutdown is still in
7. Snapshot of the virtual machine
Reason: the virtual machine is broken and cannot be restored. It is troublesome and irreversible to reinstall it.
Photo processing, the virtual machine we use is a photo, not a real virtual machine. When you use it, you can take a picture of the real virtual machine, and the snapshot is reversible.
two。 Create manually: 1. Cd / var/lib/libvirt/images/, for later use of relative paths under real machine root
Note: check the files under this path, check the hard disk information of the virtual machine, and see if there is a xx.qcow2.
two。 Take a snapshot of the virtual machine xx, and use the command qemu-img
Qemu-img create-f qcow2-b / var/lib/libvirt/images/xx.qcow2 / var/lib/libvirt/imag / cc.qcow2
-f We want to build the hard disk format of the virtual machine snapshot
-b backup the hard disk information of the virtual machine
3.ls to see if cc.qcow2 is generated (virtual machine snapshot hard disk format)
4.du-sh cc.qcow2 checks the size of the snapshot file, which is generally smaller than the real virtual machine file
5. Click on the TV, then import the path to the snapshot and change the name
The next steps are the same as before.
Note: after entering the snapshot virtual machine, delete the root, rm-rf / destroy the snapshot virtual machine, and then break down. You can see that some files cannot be deleted, because these files are running by the snapshot virtual machine. In memory, throw away the snapshot and re-take, rm-rf cc.qcow2, re-establish the snapshot, that is, the above is the manual establishment of virtual machine snapshot method 3. Script creation: (in fact, the subsequent is based on the previous one) 1. Enter / var/bin 2.vim xx.sh 3. Write a script #! / bin/bash
The script is a binary file
Cd / var/lib/libvirt/images
For the convenience of using relative paths below
Qemu-img create-f qcow2-b $1.qcow2 $2.qcow2 & orientation / dev/dull
Create a snapshot of the virtual machine and redirect the output to the trash can
Virt-install\
Use the command
-name $2\
Name of the virtual machine snapshot
-ram 1024\
Memory size of the snapshot
-vcpus 1\
Cpu size of the snapshot
-disk / var/lib/libvirt/images/$2.qcow2,bus=virtio\
Hard disk information of the snapshot
-network bridge=br0,model=virtio\
Network information of snapshot
-import & > / dev/null &
Import the path of the snapshot and redirect the output to the trash can to run the process in the background
4 > exit and save, the same as later
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.