In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
The commonly used formats are:
Tar, tar.gz (tgz), tar.bz2
The CPU time and compression ratio of compression and decompression are also quite different in different ways.
1. Tar
It's just packaging, which is equivalent to archiving, without compression, and so is decompression, just releasing the archived file.
(1) packing and archiving format:
Tar-cvf examples.tar files | dir# description:-c,-- create create a new archive creates an archive file-v,-- verbose verbosely list files processed shows the process of creating the archive file-f,-- file=ARCHIVE use archive file or device ARCHIVE is immediately followed by the file name to be processed, such as-- file=examples.tar# example: tar-cvf file.tar file1 # file1 file tar-cvf file.tar file1 file2 # file1 File2 file tar-cvf file.tar dir # dir directory
(2) release and decompression format:
Tar-xvf examples.tar (extract to current directory) tar-xvf examples.tar-C / path (/ path extract to other path) # description:-x,-- extract, extract files from an archive extract files from an archive # example: tar-xvf file.tartar-xvf file.tar-C / temp # extract to temp directory
2. Tar.gz tgz (tar.gz and tgz are just two different ways of writing, the latter is a simplified writing, equivalent to processing)
This format is a very common compression method used in Linux.
Takes into account both compression time (cost CPU) and compression space (compression ratio)
In fact, this is the compression of the tar package by gzip algorithm.
(1) package and compress format:
Tar-zcvf examples.tgz examples (directory under the current execution path of examples) description:-z,-- gzip filter the archive through gzip archives files in the form of gzip compression for example: tar-zcvf file.tgz dir # dir directory
(2) release and decompression format:
Tar-zxvf examples.tar (extracted to the current execution directory) tar-zxvf examples.tar-C / path (/ path extracted to another path) for example: tar-zcvf file.tgztar-zcvf file.tgz-C / temp
3 tar.bz
The compression ratio of Linux is higher than that of tgz, that is, it takes up less space after compression, which makes the compression package look smaller.
But at the same time, the process of compression and decompression is very time-consuming CPU.
(1) package and compress format:
Tar-jcvf examples.tar.bz2 examples (examples is the directory under the current execution path) description:-j,-- bzip2 filter the archive through bzip2 archives files in the form of bzip2 compression for example: tar-jcvf file.tar.bz2 dir # dir directory
(2) release and decompression:
Tar-jxvf examples.tar.bz2 (extracted to the current execution directory) tar-jxvf examples.tar.bz2-C / path (/ path extracted to another path) for example: tar-jxvf file.tar.bz2tar-jxvf file.tar.bz2-C / temp
4 gz
Compression:
Gzip-d examples.gz examples
Decompress:
Gunzip examples.gz
5 zip
Zip format is open and free, so it is widely used in Windows, Linux, MacOS platforms. If zip has any disadvantages, its compression ratio is not very high, not as good as rar and tar.gz formats.
Compression:
Zip-r examples.zip examples (examples is the directory)
Decompress:
Zip examples.zip
6 .rar
Compression:
Rar-an examples.rar examples
Decompress:
Rar-x examples.rar
Compression ratio, occupancy time comparison
In order to make the compression ratio more obvious, we need to select a directory with more content and more space as the test of this experiment.
Find a directory with about 23g to test, first of all, make it clear that due to the change of the execution environment, the error is inevitable.
First of all, clarify a concept:
Compression ratio = original content size / post-compression size, the higher the compression ratio, the smaller the compressed packet takes up space after compression.
.tar
Packaging: time tar-cvf test.tar / usr/test time: real 3m20.709suser 0m3.477ssys 0m42.595s size: before packaging: 23214680 after packaging: 22202984 time: 3m20.709s compression ratio: 22202984amp 23214680 decompression: time tar-xvf test.tar size: before decompression: 22202984 after decompression: 23211064 time: real 2m47.548suser 0m4.999ssys 1m14.186s
.tgz
Packaging compression: time tar-zcvf test.tgz / usr/test time: real 16m30.767suser 16m1.394ssys 1m7.391s size: before packaging: 23211064 after packaging: 18949032 time consuming: compression ratio: decompression: tar-zxvf test.tar size: before decompression: 18949032 after decompression: 23211064 time consuming: real 3m52.418suser 2m46.325ssys 1m21.442s
.tar.bz2
Packing compression: time tar-jcvf test.tar.bz2 / usr/test time: real 80m39.422suser 80m14.599ssys 0m58.623s size: before packaging: 23211064 after packaging: 18728904 time consuming: 80m39.422s compression ratio: decompression: time tar-jxvf test.tar.bz2 time: real 27m54.525suser 27m44.108ssys 1m43.645s size: before decompression: 18728904 after decompression: 23211064
Based on the results, the preliminary conclusions are as follows:
Taken together, in terms of compression ratio: tar.bz2 > tgz > tar
Footprint is inversely proportional to compression ratio: tar.bz2tar
Decompress: tar.bz2 > tar > tgz
In terms of efficiency, of course, the shorter the time, the better.
Therefore, tgz format is often chosen for the tradeoff between space consumption and time consumption under Linux, which not only has a higher compression ratio, but also takes faster time to pack and decompress, so it is an ideal choice.
Conclusion:
It once again confirms the contradiction between physical space and time (if you want to take up less space and get a high compression ratio, you must sacrifice a longer time; on the contrary, if time is more precious and requires speed, then the resulting compression ratio must be smaller. Of course, it will take up more space).
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.