Restricting the access of KVM virtual machines to resources in CENTOS7

Source: Internet
Author: User

Recently through the arduous degree Niang (I want to use Google, but, you understand), finally understand how to limit the KVM virtual machine access to resources in the CENTOS7.
Degrees Niang gives the results, most of them are very right, however, it is difficult to do, the main reason is two points:
1, the online version is mostly for centos6.x and write, but Centos7 and CENTOS6 operation somewhat different.
For example, the command to start a service in CENTOS6 is the start method of the corresponding service in the/etc/init.d/directory, and the management of the service in Centos7 is by systemctl this command.
2, some parameters of the command is not clear enough to explain, or even no explanation, throw a command directly up, and then say that the command can play a role.
For articles that conform to this, I am generally referred to as the technical stereotyped writing. Unfortunately, most of the online articles are technical stereotyped writing.
Let's write down the steps I've implemented.
In general, upgrade your system. Upgrading the system can update the software in the system to the latest state, so as to minimize some puzzling problems. The command is as follows:
Yum Update-y
The parameter-y is to update the system without prompting the direct installation. If you like to press the keyboard every time, do not take this parameter.
Also, if you are not the root user, use sudo:
sudo yum update-y
Then install Libcgroup and Libcgroup-devel. These two are for the system to add Cgroup function, specific each package is what, I do not know.
Yum Install Libcgroup libcgroup-devel-y
After the installation is complete, a service called Cgconfig is added to the system.
This service is generally required to be started on the Internet. But my test is that it is possible not to start the service.
To be consistent with the Web, start the service.
Start this service with Systemctl:
Systemctl Start Cgconfig

If you want to see the status of this service, you can look at the following command:
Systemctl status Cgconfig
Look at the status of other services also with this command.
If you see the word "active:active (exited)", it means that the boot was successful.
The Internet generally requires that this service be set to start automatically, since I feel useless, it is not set.
on the Internet generally said that after the service started in the root directory to see the Cgropu directory, but I did not see. But this seems to me this beginner does not have a half gross money relationship, can use on the line.
The following is the setting of control over disk resources. This is mostly done by Virsh the subcommands in this command Blkiotune and Blkdeviotune. Blkdeviotune No research does not explain. Blkiotune set is a virtual machine access to resources, the online data said can set weights (weight), but I did not find any role in setting, so I still forced to set the read and write speed. There are a total of six items that can be set. View the current settings for the specified name's virtual machine using the following command:
Virsh blkiotune win2k8r2
Output is as follows:
weight         : 0
device_weight :
device_read_iops_sec:
device_write_iops_sec:
Device_read_bytes_sec:
Device_write_bytes_sec:

The "win2k8r2" in the command is the name of the virtual machine to be set.
Here you can see six things to set. I only set device_read_bytes_sec this one. Set the command as follows:
Virsh Blkiotune win2k8r2--device-read-bytes-sec/dev/sda2,5000000
This allows the WIN2K8R2-named virtual machine to limit the read speed of the/DEV/SDA2 device to 5 m. Note here that the "-" in the argument, preceded by the word "--", two minus, the word is "-", a minus sign, and the previous command shows the corresponding item, with an underscore.
It is important to note that although we limit the read speed to 5 m, it may actually fluctuate up and down at this speed.
The way to see if the settings are successful is to use the Iotop tool, which is similar to top, and does not explain it.

Finally, this article is only suitable for beginners, if you are Daniel, please ignore.

Restricting the access of KVM virtual machines to resources in CENTOS7

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.