Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the six skills of running the Linux virtual machine efficiently?

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces you to run Linux virtual machine efficiently six tips are what, the content is very detailed, interested friends can refer to, I hope to help you.

Linux has been popular in enterprise data centers for years. LAMP services, Web servers, proxy servers, firewalls, and load balancers are just a few of the use cases Linux provides for the base operating system. Over the past decade, many Linux distributions have seen a significant increase in usage as usability and documentation have improved. During the growth phase, we also introduced virtualization technology into the data center. At the same time, there are a few caveats to keep in mind when running Linux virtual machines.

logical volume management

Many recent Linux distributions include Logical Volume Management (LVM) because it is disk and partition management and allows administrators to perform a large number of tasks. Some segmentation features--scaling or segmenting data across multiple disks--may not be common in a virtualized world where users typically store data in the same storage area network or datastore. In addition to these, LVM offers other interesting features. By enabling LVM, administrators can extend network file systems, extending different partitions and file systems at work while keeping file systems online and accessible. With strict compliance requirements, LVM allows us to perform volume-based snapshots for backup and recovery without invoking the capabilities that come with vSphere.

My advice is to partition LVM with virtual machines if you have a strict availability policy under your workload and take advantage of online tuning. If you don't need a lot of uptime or don't plan on installing Linux to run in separate partitions, the complexity of LVM will far outweigh the benefits and eventually disable LVM.

partition options

The default installation of Linux usually prompts the user to use only all files of one partition. This is true in some cases, but when you're trying to tweak and improve VM security and performance, it makes more sense to have separate partitions for each file such as/tmp,/var,/home,/usr-especially if you want different installation options for each partition. By utilizing the/etc/fstab file, you can specify installation options for different partitions on the appropriate lines, as follows:

UUID=0aef28b9-3d11-4ab4-a0d4-d53d7b4d3aa4 /tmp ext4 defaults,noexec 1 2

For example, Web servers, one of the most common use cases is Linux virtual machines, and we will soon discover that some "default" installation options ultimately undermine security and performance planning.

Noatime/atime/relatime: These installation options determine how timestamps contained on partition files are handled. In older Linux distributions, the default was "once," meaning that for every read and write, the operating system wrote a timestamp for file metadata-yes, just the number of read calls. You can imagine the overhead of using a Web server that serves files to the outside world all the time. By specifying "noatime" on the partition where the Web server data resides, you can reduce server overhead by not updating access times. The default option for the new release is "relatime," which is powerful enough to update only the access time if the modification time is updated.

Noexec/exec: Disable or enable binary execution in a given partition. For the Web server example, installing the/tmp partition with "noexec" makes a lot of sense. In fact, many hardening guidelines recommend using this option to improve security.

Users must be careful when changing access time parameters. Some applications, such as mail-related features, require a full "one-time" installation option. In the Web server example, Web server data can be installed with "noatime" as long as the security guidelines allow it. In the case of noexec, when used wisely, many automatic installers and packages unzip to/tmp and execute from there. It's easy to turn on and off, but I can at least add noexec for/tmp.

VMXNET3 and PVSCSI

VMXNET3 network adapters and hypervirtualized disk adapters have long been recommended for use in virtual machines. In Windows based virtual machines, we can specify only those drivers that are automatically installed using VMware tools. With this hardware, Linux presents some challenges. First, newer Linux distributions typically have their own VMXNET3 adapters and drivers, even if VMware tools are installed, as default drivers.

Older Linux distributions may contain an outdated version of VMXNET3 drivers and may not provide you with the full feature set included in VMware tool releases. KB2020567 for VMware outlines how to enable certain features in VMXNET drivers. If you want to install VMXNET3 drivers in VMware Tools, you can specify the following options at VMware Tools installation time:

./ vmware-install.pl –clobber-kernel-modules=vmxnet3

Low-cost CPUs want to get some extra throughput, and hypervirtualized SCSI adapters are a good way to do that. Be sure to check the list of supported operating systems before making this choice to ensure that the hypervirtualized SCSI adapter supports kernel or distribution.

If possible, I recommend that administrators use VMXNET3 and PVSCSI. If you are using an older kernel, install VMware Tools VMXNET version 3. If you use a newer kernel, use native Linux drivers in the distribution.

memory management

Linux operating systems constantly move memory pages from physical memory pages to local swap partitions, which is determined by design. In fact, VMware is doing the same thing with memory management. But Linux memory management behaves a little differently, moving memory pages even though physical memory-virtual memory is currently available. To reduce internal swapping activity in Linux VMs, we can adjust a value for "swapiness." Higher values indicate more motion, while lower values indicate memory does not move. To adjust this value, simply add "Vm. happiness =##" to/etc/sysctl.conf and replace "##" with the value you want after restarting.

I like to replace this value with a number lower than the default value of 60. It makes no sense to use both the operating system and vSphere to manage your memory swap. Also, it depends on the application, but I usually set this value between 15 and 20.

I/O scheduler

ESXi plays a big role in managing memory, and when it belongs to the I/O scheduler and writes to disk, it assumes another state. In addition, some of these functions are repeated internally within the Linux operating system. 2.6 Most distributions already utilize Completely Fair Queuing as the default I/O scheduler. The others available are NOOP, Anticipatory and Deadline. VMware only explains how to change this value and why you want to change it, scheduling I/O twice makes no sense. In short, the switch can be made using the Linux kernel's default I/O scheduler by attaching a machine to the grub kernel entry.

There is no need to schedule the operating system first and then the hypervisor. I recommend using the NOOP I/O scheduler because it does not optimize disk I/O and allows vSphere full authority to manage.

Remove unused hardware and disable unnecessary services

How many times in the past year have you used virtual floppy disks and internal computer speakers in virtual machines? If you don't plan on using these devices, blacklist them. The command to delete a floppy disk is as follows:

echo "blacklist floppy" | tee /etc/modprobe.d/blacklist-floppy.conf rmmod floppy update-initramfs -u

There is no need to worry about unused hardware. If you are still using it, disable any virtual consoles. This can be done in/etc/inittab by:

1:2345:respawn:/sbin/getty 38400 tty1 2:23:respawn:/sbin/getty 38400 tty2#3:23:respawn:/sbin/getty 38400 tty3#4:23:respawn:/sbin/getty 38400 tty4#5:23:respawn:/sbin/getty 38400 tty5#6:23:respawn:/sbin/getty 38400 tty6

I suggest you remove the floppy disk. Keep in mind that you must also remove the hardware configuration of the virtual machine and disable it in the BIOS of the virtual machine. Other services you can blacklist include monitoring disk array configuration (mptctl), pcspker, snd_pcm, snd_page_alloc, snd_timer, snd, snd_soundcore, coretemp, parport and parport_pc.

Before blacklisting these services, make sure you are not using them. At the same time, I always have a few virtual consoles open that I might use, but six is a bit much.

Here are some considerations for running Linux virtual machines. Given the performance gains, everyone should be on their own terms. Make a few minor adjustments and you may see more performance improvements and some performance degradation. As usual, changes are tested in a lab environment before they are made. Technology is constantly changing, so it can be tested in advance.

About the efficient operation of Linux virtual machine six skills are what to share here, I hope the above content can be of some help to everyone, you can learn more knowledge. If you think the article is good, you can share it so that more people can see it.

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report