Linux Avoid Io Hang method

Source: Internet
Author: User

For DB Server, it's tricky to delete a large table. If you delete a large table, you can establish a hard link to the. ibd file of the existing table. When multiple file names point to the same node, deleting any one of the filenames is very quick, because the physical files are not deleted, just a pointer is removed. When the node reference number is 1, deleting the file requires that all data blocks associated with the file be deleted.
Today we'll just talk about how to avoid IO hang if we use the above method to create a hard link file, and then delete that large file. The
answer is the Truncate tool in the Coreutils toolset
Truncate shrink or extend file to a specified size
Syntax: Truncate option ... file ...
If the file does not exist, it will be created.
If the size of a file is larger than the specified size, the file is truncated to a subset of the data, and if size is smaller than specified, he will be populated with 0 bytes.
Option:
-C
--no-create If this file is not created
-o
--io-blocks treats the size of the file with I/O block for
-R rfile
--reference=file Base the size of each file on the size of Rfile
-S size
--size=size adjusts the size of the file
' KB ' according to the options below > 1000 (kilobytes)
' K ' => 1024 (kibibytes)
' MB ' => 1000*1000 (megabytes)
' M ' => 1024*1024 (mebi Bytes)
' GB ' => 1000*1000*1000 (gigabytes)
' G ' => 1024*1024*1024 (gibibytes)
or a unit such as T P E Z is based on the following The symbol of the face, depending on their size to resize
+ expand
-Reduce the
< at most
> at least
/down-round multiple
% up to a multiple
Simple example:
Touch aBC
truncate-s +1kb ABC
truncate-s +1KB ABC
LL ABC
-rwxrwxrwx 1 root root 2000 November 05:31 ABC

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.