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

How to optimize Linux disk

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

In order to solve this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.

Overview

Share the optimization of linux disk Ibind 0 and insert a rac error solution in the middle.

File system optimization

* * dynamically adjust the number of request queues to improve efficiency. The default number of request queues is 128, and 512 can be configured * *

[root@bo queue] # cat / sys/block/sda/queue/nr_requests128

* * read_ahead, which improves the disk read operation by pre-reading data and recording it to random access memory. Default value: 128. Configuration: 8192 * *

[root@bo queue] # cat / sys/block/sda/queue/read_ahead_kb128

* * turn off the timestamp of one access to a file (directory) * *

For example:

Mount-t xfs-o defaults,noatime,nodiratime / dev/sda5 / data

* * xfs file system is recommended for large files, large capacity and large number of files * *

Adjust Ipaw O scheduling algorithm

Disk IO scheduling algorithm

[root@bo queue] # cat / sys/block/sda/queue/scheduler noop anticipatory deadline [cfq]

Centos6.x defaults to cfq

Adjust to deadline

[root@bo queue] # echo deadline > / sys/block/sda/queue/scheduler [root@bo queue] # cat / sys/block/sda/queue/scheduler noop anticipatory [deadline] cfq

PS: when deploying rac with redhat6, if there is no configuration, you will be prompted with the warning of "scheduler 0". You can solve this problem by following the configuration above.

Ipar 0 scheduler error report

How many disks are written?

* * introduction to Icano scheduling algorithm * *

CFQ (fully Fair queuing Iram O Scheduler) default

Features:

CFQ attempts to evenly distribute the access to the bandwidth of deadline O to avoid starvation and achieve lower latency, which is a compromise between deadline and as schedulers.

CFQ assigns a priority to the Icano request, which is independent of the process priority, and the read and write of the high priority process can not automatically inherit the high Icano priority.

How it works:

CFQ builds a queue for each process / thread to manage the requests generated by the process, that is, each process has a queue, and scheduling between queues uses time slices

This ensures that each process can be well allocated to the I / O bandwidth I / O scheduler to execute four requests for one process at a time.

NOOP (elevator dispatcher)

Features:

In Linux2.4 or earlier versions of the scheduler, there was only one Imax O scheduling algorithm.

NOOP implements a simple FIFO queue, which organizes Imax O requests like the elevator master method. When a new request arrives, it merges the request after the most recent request to ensure that the request is the same medium.

NOOP tends to starve to death and is good for writing.

NOOP is the choice for flash devices, RAM, embedded systems.

Explanation of Elevator algorithm starvation request:

Because it is easier to write a request than to read it.

Write requests go through the file system cache, and do not need to wait for a write to complete before starting the next write operation. Write requests are merged and piled into the Imando O queue.

The read request needs to wait until all previous reads are completed before it can proceed to the next read. There are milliseconds between read operations, and write requests come in between, starving the rest of the read requests.

Deadline (deadline Scheduler)

Features:

Sorting by time and hard disk area, this classification and merge requires a scheduler similar to noop.

Deadline ensures that requests are served within a deadline, which is adjustable, while the default read period is shorter than the write deadline. This prevents write operations from starving to death because they cannot be read.

Deadline is the choice of database environment (ORACLE RAC,MYSQL, etc.).

AS (expected Imax O scheduler)

Features:

It is essentially the same as Deadline, but after a read operation, you have to wait for 6ms before you can continue to schedule other Ibind O requests.

A new read request can be booked from the application to improve the execution of read operations, but at the expense of some writes.

It inserts a new Icano operation in each 6ms and merges some small write streams into one large write stream, trading write latency for write throughput.

AS is suitable for environments with more writes, such as file servers

AS performs poorly in the database environment.

* * Summary of Icano scheduling algorithm * *

Anticipatory I scheduler is suitable for most environments, but not suitable for database applications.

Deadline I scheduler O scheduler is usually the same as Anticipatory, but more concise and compact, more suitable for database applications, DATA/SAS disk

CFQ I scheduler O scheduler allocates the same amount of bandwidth to all processes, which is suitable for desktop multitasking and multimedia applications. The default IO scheduler

NOOP I scheduler O scheduler is suitable for SSD disk, with raid card and READ disk.

* * sysctl.conf is optimized for disk * *

Vm.swappiness = [0-10] default is 60, which is too high. If it is a cache server, it is recommended to configure it to 0.

Optimized for solid state disk

1. Turn off the log function

2. Add the mount parameter data=writeback to fstab

3. Enable TRIM function

The Linux kernel provides TRIM support since 2.6.33, so first run the "uname-a" command to check your own kernel version. If the kernel version is lower than 2.6.33, please upgrade the kernel first.

Then run "hdparm-I / dev/sda" to see if your hard drive supports TRIM technology. If so, you will see

Data Set Management TRIM supported

If the above two conditions are met, you can add discard to fstab to enable the TRIM feature, such as:

Original UUID=2f6be0cf-2f54-4646-b8c6-5fb0aa01ef23 / ext4 defaults,errors=remount-ro 01

Modified UUID=2f6be0cf-2f54-4646-b8c6-5fb0aa01ef23 / ext4 discard,defaults,errors=remount-ro 01

This is the answer to the question on how to optimize the Linux disk iSplink O. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel for more related knowledge.

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