How to Avoid IOhang in Linux

Source: Internet
Author: User
For DBServer, deleting a large table is tricky. To delete a large table, you can create a hard link to The. ibd file of the original table. When multiple file names direct to the same Node, deleting any file name is very fast, because the physical file directly connected is not deleted, but only a pointer is deleted. When the number of Node references is 1, you need to delete all file-related For DB servers, deleting large tables is tricky. To delete a large table, you can create a hard link to The. ibd file of the original table. When multiple file names direct to the same Node, deleting any file name is very fast. Because the physical file for direct connection is not deleted, it is just a pointer. When the number of Node references is 1, delete all data blocks related to the file.
Today we will only discuss how to avoid IO hang when deleting a large file by using the above method to create a hard link file?
The answer is the truncate tool in the coreutils tool set.
Truncate to shrink or expand the file to the specified size
Syntax: truncate option... file...
If the file does not exist, it will be created.
If the size of a file is greater than the specified size, the file will be truncated and lost as part of the data. If the size is smaller than the specified size, it will be filled with 0 bytes.
Option:
-C
-- No-create: if the file does not exist, it will not be created.
-O
-- Io-blocks: the size of the file is treated as an I/O block.
-R rfile
-- Reference = file Base the size of each file on the size of rfile
-S size
-- Size = size adjust the file size according to the following options
'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.
Adjust the size according to the following symbols according to their own size.
+ Expansion
-Zoom out
<Up
> At least
/A multiple of rounding down
% Multiples of up
Simple Example:
Touch abc
Truncate-s + 1KB abc
Truncate-s + 1KB abc
Ll abc
Related Article

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.