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 avoid IO hang implementation for Linux

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

Share

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

This article is about how Linux can avoid IO hang implementation. Xiaobian thinks it is quite practical, so share it with everyone for reference. Let's follow Xiaobian and have a look.

For DB Server, dropping large tables can be tricky. If you delete a large table, you can create a hard link to the original table's.ibd file. When multiple file names point to the same Node, deleting any file name is fast, because the directly connected physical file is not deleted, just a pointer is deleted. When the Node reference number is 1, deleting the file requires deleting all the data blocks associated with the file.

If we use the above method to create a hard link file, then delete the large file, how to avoid IO hang?

The answer is the truncate tool in the coreutils toolset

truncate shrinks or extends a file to a specified size

Syntax: truncate option... file ...

If the file doesn't exist, it's created.

If the size of a file is larger than the specified size, the file will be truncated to lose some data, if the size is smaller than the specified size, then it will be filled with 0 bytes.

option:

-c

--no-create If there is no file, it will not be created.

-o

--io-blocks Size of files treated as I/O blocks

-r rfile

--reference=file Base the size of each file on the size of rfile

-s size

--size=size Adjust file size according to options below

KB=> 1000 (KiloBytes)

K=> 1024 (KibiBytes)

MB => 1000*1000 (MegaBytes)

M => 1024*1024 (MebiBytes)

GB => 1000*1000*1000 (GigaBytes)

G => 1024*1024*1024 (GibiBytes)

or T, P, E, Z, something like that.

According to the symbols below, resize them according to their own size

+ extended

- narrow

< 至多 >

least

/Multiple of rounding down

Multiples of % Up

A simple example:

touch abc

truncate -s +1KB abc

truncate -s +1KB abc

ll abc

-rwxrwxrwx 1 root root 2000 November 28 05:31 abc

Thank you for reading! About "Linux how to avoid IO hang implementation" This article is shared here, I hope the above content can have some help for everyone, so that everyone can learn more knowledge, if you think the article is good, you can share it to let more people 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