1. 压缩
tar -cjvf xxx.tar.bz2 xxxx
2. 解压
(解压到指定目录)
tar -xjvf 2018-10-21.tar.bz2 -C /mysql/
3. 归档
tar -czvf xxxx.tar.gz xxxx
4. 解压
tar -xzvf xxxx.tar.gz
5. pigz
压缩:
time tar -cf - /tmp/hadoop | pigz -6 -p 8 -k> hadoop.tgz
-0 to -9, -11 : 压缩级别
-p n : 指定压缩核心数,默认8个
-k :压缩后保留原文件
解压:
time pigz -p 8 -d hadoop.tgz
6. lz4压缩、解压
压缩:tar cvf - path/to/dir | lz4 - dir.tar.lz4
解压:lz4 -d dir.tar.lz4 | tar -xv
7. curl
## 上传文件 curl -XPOST http://100.67.76.9:10030/v2/UploadScripts?token={token} -F "file=@./monitor.tgz" ## 带有body curl -X POST http://100.67.76.9:10030/v2/UploadScripts?token={token} -H "Content-type: application/json" -d '{"key1": "value1", "key2": "value2"}' curl -X POST http://100.67.76.9:10030/v2/UploadScripts?token={token} -H "Content-type: application/json" -d@data.json
8. 清空history
echo "" > ~/.zsh_history & exec $SHELL -l history -c
# 压缩对比
**pigz:** 压缩-CPU消耗800% 解压-70%~100%
```
#time tar -cf - registry2 | pigz -p 8 > registry2.tgz
real 2m22.652s
user 17m19.212s
sys 0m53.646s
```
|压缩方式|解压方式|CPU消耗|压缩耗时|解压耗时|原文件大小|压缩后大小|线程数|RAM消耗|
|----|----|----|----|----|----|----|---|---|
|pigz(tar -cf - registry2 | pigz -p 8 > registry2.tgz)|pigz(pigz -p 8 -d registry2.tgz)|压缩:170%~800%;解压:70%~100%|real: 2m22.652s user: 17m19.212s sys: 0m53.646s|real 3m0.696s user: 1m9.691s sys:0m51.298s|25G|25G|8||
|lz4(time tar cvf - registry2 | lz4 - registry2.tar.lz4)|lz4 -d xxx.tar.lz4|压缩:50%左右;解压:90%~100%|real:3m1.640s user:0m15.820s sys:0m53.462s|real:0m35.325s user:0m0.633s sys:0m33.864s|25G|25G|1||