当前位置: 首页 > 工具软件 > pigz > 使用案例 >

pigz在centos6.8下的编译安装

上官高翰
2023-12-01

pigz是压缩命令gzip的并行版,默认线程数是cpu个数。在centos7中可以用yum安装,在centos6,yum源中没有找到,使用下面的命令安装:
1、安装基础包:
yum install zlib-devel gcc gcc-c++ -y
2、下载pigz包:
wget http://www.zlib.net/pigz/pigz-2.4.tar.gz
3、解压,编译:
tar xvf pigz-2.4.tar.gz
cd pigz-2.4
make
echo $?
ln -s /etc/yum.repos.d/pigz-2.4/pigz /bin/pigz
4、验证:

[root@centos6 pigz-2.4]# pigz
Usage: pigz [options] [files ...]
  will compress files in place, adding the suffix '.gz'. If no files are
  specified, stdin will be compressed to stdout. pigz does what gzip does,
  but spreads the work over multiple processors and cores when compressing.

Options:
  -0 to -9, -11        Compression level (level 11, zopfli, is much slower)
  --fast, --best       Compression levels 1 and 9 respectively
  -b, --blocksize mmm  Set compression block size to mmmK (default 128K)
  -c, --stdout         Write all processed output to stdout (won't delete)
  -d, --decompress     Decompress the compressed input
  -f, --force          Force overwrite, compress .gz, links, and to terminal
  -F  --first          Do iterations first, before block split for -11
  -h, --help           Display a help screen and quit
  -i, --independent    Compress blocks independently for damage recovery
  -I, --iterations n   Number of iterations for -11 optimization
  -J, --maxsplits n    Maximum number of split blocks for -11
  -k, --keep           Do not delete original file after processing
  -K, --zip            Compress to PKWare zip (.zip) single entry format
  -l, --list           List the contents of the compressed input
  -L, --license        Display the pigz license and quit
  -m, --no-time        Do not store or restore mod time
  -M, --time           Store or restore mod time
  -n, --no-name        Do not store or restore file name or mod time
  -N, --name           Store or restore file name and mod time
  -O  --oneblock       Do not split into smaller blocks for -11
  -p, --processes n    Allow up to n compression threads (default is the
                       number of online processors, or 8 if unknown)
  -q, --quiet          Print no messages, even on error
  -r, --recursive      Process the contents of all subdirectories
  -R, --rsyncable      Input-determined block locations for rsync
  -S, --suffix .sss    Use suffix .sss instead of .gz (for compression)
  -t, --test           Test the integrity of the compressed input
  -v, --verbose        Provide more verbose output
  -V  --version        Show the version of pigz
  -Y  --synchronous    Force output file write to permanent storage
  -z, --zlib           Compress to zlib (.zz) instead of gzip format
  --                   All arguments after "--" are treated as files

[root@centos6 test2]# du -sh test1.txt
261M	test1.txt
[root@centos6 test2]# 
[root@centos6 test2]# time gzip test1.txt

real	0m1.811s
user	0m1.711s
sys	0m0.101s
[root@centos6 test2]# 
[root@centos6 test2]# time gzip -d test1.txt

real	0m1.074s
user	0m0.893s
sys	0m0.180s
[root@centos6 test2]# 
[root@centos6 test2]# time pigz test1.txt

real	0m1.231s
user	0m0.288s
sys	0m2.139s
[root@centos6 test2]# 
[root@centos6 test2]# time pigz -d test1.txt

real	0m0.593s
user	0m0.060s
sys	0m0.836s
[root@centos6 test2]# grep "model name" /proc/cpuinfo |wc -l
2
[root@centos6 test2]# 

5、在redhat6.0编译失败:

[root@server2 pigz-2.4]# cat /etc/redhat-release 
Red Hat Enterprise Linux Server release 6.0 (Santiago)

[root@server2 pigz-2.4]# make
gcc -O3 -Wall -Wextra -Wno-unknown-pragmas   -c -o pigz.o pigz.c
pigz.c:3587: warning: expected [error|warning|ignored] after ‘#pragma GCC diagnostic’
pigz.c:3588: warning: unknown option after ‘#pragma GCC diagnostic’ kind
pigz.c:3616: warning: expected [error|warning|ignored] after ‘#pragma GCC diagnostic’
gcc -O3 -Wall -Wextra -Wno-unknown-pragmas   -c -o yarn.o yarn.c
gcc -O3 -Wall -Wextra -Wno-unknown-pragmas   -c -o try.o try.c
gcc -O3 -Wall -Wextra -Wno-unknown-pragmas -c zopfli/src/zopfli/deflate.c
gcc -O3 -Wall -Wextra -Wno-unknown-pragmas -c zopfli/src/zopfli/blocksplitter.c
gcc -O3 -Wall -Wextra -Wno-unknown-pragmas -c zopfli/src/zopfli/tree.c
gcc -O3 -Wall -Wextra -Wno-unknown-pragmas -c zopfli/src/zopfli/lz77.c
gcc -O3 -Wall -Wextra -Wno-unknown-pragmas -c zopfli/src/zopfli/cache.c
gcc -O3 -Wall -Wextra -Wno-unknown-pragmas -c zopfli/src/zopfli/hash.c
gcc -O3 -Wall -Wextra -Wno-unknown-pragmas -c zopfli/src/zopfli/util.c
gcc -O3 -Wall -Wextra -Wno-unknown-pragmas -c zopfli/src/zopfli/squeeze.c
gcc -O3 -Wall -Wextra -Wno-unknown-pragmas -c zopfli/src/zopfli/katajainen.c
gcc  -o pigz pigz.o yarn.o try.o deflate.o blocksplitter.o tree.o lz77.o cache.o hash.o util.o squeeze.o katajainen.o -lm -lpthread -lz
pigz.o: In function `compress_thread':
pigz.c:(.text+0x260d): undefined reference to `deflatePending'
pigz.c:(.text+0x266f): undefined reference to `deflatePending'
pigz.o: In function `single_compress':
pigz.c:(.text+0x93b4): undefined reference to `deflatePending'
pigz.c:(.text+0x96db): undefined reference to `deflatePending'
collect2: ld returned 1 exit status
make: *** [pigz] Error 1
[root@server2 pigz-2.4]# 

参考网址:linux下多线程压缩命令pigz

 类似资料: