Centos7 安装 zip 软件失败,更换yum 源方法
centos7 , 使用 yum 安装 zip 报错:
[root@localhost frontend]# yum install zip
Loaded plugins: fastestmirror
Determining fastest mirrors
http://mirrors.163.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
Trying other mirror.
To address this issue please refer to the below wiki article
https://wiki.centos.org/yum-errors
If above article doesn't help to resolve this issue please use https://bugs.centos.org/.
docker-ce-stable | 3.5 kB 00:00:00
http://mirrors.163.com/centos/7/extras/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
Trying other mirror.
http://mirrors.163.com/centos/7/updates/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found
Trying other mirror.
docker-ce-stable/7/x86_64/primary_db | 152 kB 00:00:01
Resolving Dependencies
--> Running transaction check
---> Package zip.x86_64 0:3.0-11.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
============================================================================================================================================================================================================================================================================== Package Arch Version Repository Size
Installing:
zip x86_64 3.0-11.el7 base 260 k
Transaction Summary
Install 1 Package
Total download size: 260 k
Installed size: 796 k
Is this ok [y/d/N]: y
Downloading packages:
zip-3.0-11.el7.x86_64.rpm FAILED
http://mirrors.163.com/centos/7/os/x86_64/Packages/zip-3.0-11.el7.x86_64.rpm: [Errno 14] HTTP Error 404 - Not Found 0% [ ] 0.0 B/s | 0 B --:--:-- ETA
Trying other mirror.
Error downloading packages:
zip-3.0-11.el7.x86_64: [Errno 256] No more mirrors to try.
这个错误提示表明 yum 在尝试下载 zip 包时从 mirrors.163.com 镜像站点失败了,错误是 HTTP 404,即找不到文件。这通常是因为镜像站点的某些文件或版本不可用或过时。你可以尝试以下几种方法来解决这个问题:
1. 更换镜像源
yum 的镜像源可能是过时的,导致无法下载必要的文件。你可以尝试更换为其他可用的镜像源。以下是如何更换镜像源的方法:
1. 备份原始的 CentOS 源文件:
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
2. 下载并配置一个新的镜像源(比如使用阿里云的镜像):
可以访问 阿里云镜像源 来获取 CentOS 7 的镜像源配置文件。或者你可以手动配置:
- 下载阿里云的 CentOS-Base.repo 文件:
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
更新 yum 缓存:
yum clean all
yum makecache
3. 再次尝试安装 zip:
yum install zip
但是这步又报错了:
[root@localhost frontend]# yum install zip
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
base: mirrors.aliyun.com
extras: mirrors.aliyun.com
updates: mirrors.aliyun.com base | 3.6 kB 00:00:00
docker-ce-stable | 3.5 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/6): base/7/x86_64/group_gz | 153 kB 00:00:00
docker-ce-stable/7/x86_64/upda FAILED
https://download.docker.com/linux/centos/7/x86_64/stable/repodata/65c4f66e2808d328890505c3c2f13bb35a96f457d1c21a6346191c4dc07e6080-updateinfo.xml.gz: [Errno 14] curl#35 - "TCP connection reset by peer" ] 0.0 B/s | 0 B --:--:-- ETA Trying other mirror. docker-ce-stable/7/x86_64/prim FAILED
https://download.docker.com/linux/centos/7/x86_64/stable/repodata/aa1f3958af9cb5f1f6c34b5725f63de4f5e3e46c236205b598fecfec6ad506f6-primary.sqlite.bz2: [Errno 14] curl#35 - "TCP connection reset by peer" ] 0.0 B/s | 0 B --:--:-- ETA Trying other mirror. (2/6): extras/7/x86_64/primary_db | 253 kB 00:00:00
base/7/x86_64/primary_db FAILED 39% [===========================================- ] 470 kB/s | 14 MB 00:00:44 ETA http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/6d0c3a488c282fe537794b5946b01e28c7f44db79097bb06826e1c0c88bad5ef-primary.sqlite.bz2: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/6d0c3a488c282fe537794b5946b01e28c7f44db79097bb06826e1c0c88bad5ef-primary.sqlite.bz2: (28, 'Connection timed out after 30002 milliseconds') Trying other mirror. (3/6): base/7/x86_64/primary_db | 6.1 MB 00:00:25
(4/6): updates/7/x86_64/primary_db | 27 MB 00:01:13
docker-ce-stable/7/x86_64/prim FAILED
https://download.docker.com/linux/centos/7/x86_64/stable/repodata/aa1f3958af9cb5f1f6c34b5725f63de4f5e3e46c236205b598fecfec6ad506f6-primary.sqlite.bz2: [Errno 14] curl#35 - "TCP connection reset by peer" ] 0.0 B/s | 0 B --:--:-- ETA Trying other mirror. https://download.docker.com/linux/centos/7/x86_64/stable/repodata/aa1f3958af9cb5f1f6c34b5725f63de4f5e3e46c236205b598fecfec6ad506f6-primary.sqlite.bz2: [Errno 14] curl#35 - "TCP connection reset by peer" Trying other mirror.
One of the configured repositories failed (Docker CE Stable - x86_64),
and yum doesn't have enough cached data to continue. At this point the only
safe thing yum can do is fail. There are a few ways to work "fix" this:
1. Contact the upstream for the repository and get them to fix the problem.
2. Reconfigure the baseurl/etc. for the repository, to point to a working
upstream. This is most often useful if you are using a newer
distribution release than is supported by the repository (and the
packages for the previous distribution release still work).
3. Run the command with the repository temporarily disabled
yum --disablerepo=docker-ce-stable ...
4. Disable the repository permanently, so yum won't use it by default. Yum
will then just ignore the repository until you permanently enable it
again or use --enablerepo for temporary usage:
yum-config-manager --disable docker-ce-stable
or
subscription-manager repos --disable=docker-ce-stable
5. Configure the failing repository to be skipped, if it is unavailable.
Note that yum will try to contact the repo. when it runs most commands,
so will have to try and fail each time (and thus. yum will be be much
slower). If it is a very temporary problem though, this is often a nice
compromise:
yum-config-manager --save --setopt=docker-ce-stable.skip_if_unavailable=true
failure: repodata/aa1f3958af9cb5f1f6c34b5725f63de4f5e3e46c236205b598fecfec6ad506f6-primary.sqlite.bz2 from docker-ce-stable: [Errno 256] No more mirrors to try.
https://download.docker.com/linux/centos/7/x86_64/stable/repodata/aa1f3958af9cb5f1f6c34b5725f63de4f5e3e46c236205b598fecfec6ad506f6-primary.sqlite.bz2: [Errno 14] curl#35 - "TCP connection reset by peer"
这个错误信息显示,yum 在尝试访问 Docker 官方的镜像源时发生了 TCP connection reset by peer 错误,且无法下载相关数据。这个错误通常是由于网络问题或者镜像源的暂时不可用导致的。
解决方法
可以尝试以下几种方法来解决问题:
1. 临时禁用 Docker CE 镜像源
由于错误只出现在 docker-ce-stable 仓库,你可以在安装 zip 时,临时禁用该仓库,避免影响安装过程。
yum --disablerepo=docker-ce-stable install zip
这样 yum 将只从其他可用的仓库(例如 base 和 extras)获取 zip 包,绕过 Docker 仓库。
2. 手动安装 zip 包
如果你无法通过 yum 安装,可以手动下载并安装 .rpm 包。
1. 下载 zip 包:
访问 CentOS 7 官方镜像站 或其他可靠的源,下载适合 CentOS 7 的 zip-3.0-11.el7.x86_64.rpm 包。
或者,你可以直接使用 wget 下载:
wget http://mirror.centos.org/centos/7/os/x86_64/Packages/zip-3.0-11.el7.x86_64.rpm
2. 使用 rpm 命令安装:
下载后,使用 rpm 命令进行安装:
rpm -ivh zip-3.0-11.el7.x86_64.rpm
3. 检查并修复镜像站点的错误
如果你仍然希望使用 yum,可以尝试手动修复 yum 镜像站点的错误,或者临时禁用出错的镜像源。
- 禁用出错的镜像源:
在 /etc/yum.repos.d/CentOS-Base.repo 中找到 baseurl 和 mirrorlist 配置,注释掉出错的镜像源并启用其他镜像源。
例如,编辑 /etc/yum.repos.d/CentOS-Base.repo 文件,注释掉 mirrorlist 和启用 baseurl:
sudo vi /etc/yum.repos.d/CentOS-Base.repo
将对应的镜像源行修改为类似以下内容:
[base]
name=CentOS-7 - Base
baseurl=http://mirror.centos.org/centos/7/os/x86_64/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
保存并退出后,执行:
yum clean all
yum makecache