标题: "yum install"时遭遇"HTTP Error 416" 创建: 2019-08-15 12:30 更新: 链接: https://scz.617.cn/unix/201908151230.txt $ yum install gcc gcc-c++ ... gcc-4.8.5-36.el7_6.2.x86_64.rp FAILED http://.../centos/7.6.1810/updates/x86_64/Packages/gcc-4.8.5-36.el7_6.2.x86_64.rpm: [Errno 14] HTTP Error 416 - Requested Range Not Satisfiable ... 安装gcc时提示"HTTP Error 416"。 $ curl -I http://.../centos/7.6.1810/updates/x86_64/Packages/gcc-4.8.5-36.el7_6.2.x86_64.rpm HTTP/1.1 200 OK Server: openresty Date: Thu, 15 Aug 2019 02:59:08 GMT Content-Type: application/x-redhat-package-manager Content-Length: 16960856 Last-Modified: Mon, 29 Apr 2019 15:44:50 GMT Connection: keep-alive ETag: "5cc71bf2-102cd58" Accept-Ranges: bytes curl表明文件大小是16960856字节。 $ wget http://.../centos/7.6.1810/updates/x86_64/Packages/gcc-4.8.5-36.el7_6.2.x86_64.rpm --2019-08-15 10:59:43-- http://.../centos/7.6.1810/updates/x86_64/Packages/gcc-4.8.5-36.el7_6.2.x86_64.rpm Resolving ... (...)... 218.104.71.170, 2001:da8:d800:95::110 Connecting to ... (...)|218.104.71.170|:80... connected. HTTP request sent, awaiting response... 302 Found Location: http://45.252.224.79/files/A10400000E43495A/ftp2.scientificlinux.org/linux/scientific/7.6/x86_64/updates/fastbugs/gcc-4.8.5-36.el7_6.2.x86_64.rpm [following] --2019-08-15 10:59:43-- http://45.252.224.79/files/A10400000E43495A/ftp2.scientificlinux.org/linux/scientific/7.6/x86_64/updates/fastbugs/gcc-4.8.5-36.el7_6.2.x86_64.rpm Connecting to 45.252.224.79:80... connected. HTTP request sent, awaiting response... 200 OK Length: 14526904 (14M) [application/octet-stream] Saving to: ‘gcc-4.8.5-36.el7_6.2.x86_64.rpm’ ... 2019-08-15 11:00:15 (436 KB/s) - ‘gcc-4.8.5-36.el7_6.2.x86_64.rpm’ saved [14526904/14526904] wget只下载了14526904字节。 $ ls -l gcc-4.8.5-36.el7_6.2.x86_64.rpm -rw-r--r--. 1 root root 14526904 Jul 23 08:41 gcc-4.8.5-36.el7_6.2.x86_64.rpm 下面是位于yum缓存中的文件: $ ls -l /var/cache/yum/x86_64/\$releasever/updates/packages/gcc-4.8.5-36.el7_6.2.x86_64.rpm -rw-r--r--. 1 root root 14526904 Jul 23 08:41 /var/cache/yum/x86_64/$releasever/updates/packages/gcc-4.8.5-36.el7_6.2.x86_64.rpm 文件大小应该是16960856,下回来却只有14526904。又是"邪恶的Cache服务"惹的祸, 这次的EvilCache位于45.252.224.79。 参看: 《"apt-get install"时遭遇"Hash Sum mismatch"》 https://scz.617.cn/unix/201806011639.txt 临时解决办法是挂加密代理手工下载正确版本,放到如下目录: /var/cache/yum/x86_64/\$releasever/updates/packages/ 或者用HTTPS下载: $ wget https://.../centos/7.6.1810/updates/x86_64/Packages/gcc-4.8.5-36.el7_6.2.x86_64.rpm $ rpm -Uvh gcc-4.8.5-36.el7_6.2.x86_64.rpm 或者 $ rpm -Uvh https://.../centos/7.6.1810/updates/x86_64/Packages/gcc-4.8.5-36.el7_6.2.x86_64.rpm 可以配置yum使用代理: $ vi /etc/yum.conf -------------------------------------------------------------------------- [main] ... #proxy=http://: #proxy_username= #proxy_password= proxy=http://192.168.65.1:8080 -------------------------------------------------------------------------- 重新执行"yum install gcc"即可。