MongoDB解压报错gzip: stdin: not in gzip format的解决方法

MongoDB解压报错gzip: stdin: not in gzip format的解决方法

在安装MongoDB时出现如下报错:

[root@vm172-31-0-6 mongodb]# tar -zxvf mongodb-linux-x86_64-4.1.8.tgz 

gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now

出现这种错误的排查方法如下:

1.用重命名的方法

mv tar xf mongodb-linux-x86_64-4.1.8.tgz tar xf mongodb-linux-x86_64-4.1.8.tar.gz

进行解压

[root@vm172-31-0-6 mongodb]# tar –zxvf mongodb-linux-x86_64-4.1.8.tar.gz

gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now

发现报错依旧存在。

2.查看下载的安装包是否本身就是损坏的

[root@vm172-31-0-6 tools]# ls -lht
total 74M
-rw-r--r-- 1 root root 505K Feb 27 16:57 mongodb-linux-x86_64-4.1.8.tar.gz

发现安装包只有505k,明显是下载的安装包就是损坏的,

3.查看文件的属性是什么

[root@vm172-31-0-6 tools]# file mongodb-linux-x86_64-4.1.8.tar.gz 
mongodb-linux-x86_64-4.1.8.tar.gz: HTML document, UTF-8 Unicode text, with very long lines, with CR, LF line terminators

发现文件属性是HTML,所以一直解压失败。

说明:

文件的下载链接不是直接指向文件,而是先指向一个页面,在这个页面里才是真的下载链接,所以在前一个页面上直接保存文件,实际上保存的是一个页面。

假如属性是bz文件,就用bz文件的解压方式。

解决方法:

复制下载地址,直接去浏览器重新下载即可。

原文地址:https://www.cnblogs.com/heyongboke/p/10445237.html