Linux avoids IO hang method

  

For DB Server, deleting large tables is tricky. If you delete a large table, you can create a hard link to the .ibd file of the original table. When multiple file names point to the same Node, deleting any file name is very fast, because the directly connected physical file is not deleted but just deletes a pointer. When the number of Node references is 1, deleting a file requires deleting all the data blocks associated with the file. Today we only discuss, if we use the above method to create a hard link file, then how to avoid IO hang when deleting the large file? The answer is the truncate tool in the coreutils toolset truncate shrinks or expands the file to the specified size Syntax: truncate option ... file ... will be created if the file does not exist. If the size of a file is larger 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, then it will be filled with 0 bytes. Option: -c --no-create If there is no such file, it will not be created -o --io-blocks The size of the file is treated as I/O block -r rfile --reference=file Base the size of each File on the size of rfile -s size --size=size Adjust the size of the file according to the 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 units such as TPEZ are resized according to their own size according to the following symbols + Extended - Reduced < At most > At least /Rounded down multiples % Up multiples Simple example: touch abc truncate -s + 1KB abc truncate -s +1KB abc ll abc -rwxrwxrwx 1 root root 2000 November 28 05:31 abc

Copyright © Windows knowledge All Rights Reserved