Centos7系统安装yum遇到问题 [Errno 256] No more mirrors to try.

自己最近使用CentOS7 X64 先用yum 安装下 tree,一直提示下面错误,网上查了很多方式一直都没解决,幸好优快云 大牛多多,找了这篇文章:https://blog.youkuaiyun.com/Homewm/article/details/80642851  按照提示步骤终于成功了,这里表示非常感谢。

http://192.168.100.115/CentOS7/Packages/tree-1.6.0-10.el7.x86_64.rpm: [Errno 12] Timeout on http://192.168.100.115/CentOS7/Packages/tree-1.6.0-10.el7.x86_64.rpm: (28, 'Connection timed out after 30001 milliseconds')
Trying other mirror.
Error downloading packages:
  tree-1.6.0-10.el7.x86_64: [Errno 256] No more mirrors to try.
 

自己为了避免后面再次遇到此类问题,这里也记录下操作步骤,供大家参考。

卸载旧得软件包

先查看有哪些软件包

[root@localhost yum.repos.d]# rpm -qa|grep yum
yum-metadata-parser-1.1.4-10.el7.x86_64
yum-utils-1.1.31-45.el7.noarch
PackageKit-yum-1.1.5-1.el7.centos.x86_64
yum-3.4.3-158.el7.centos.noarch
yum-langpacks-0.4.2-7.el7.noarch
yum-plugin-fastestmirror-1.1.31-45.el7.noarch

 

[root@localhost yum.repos.d]# rpm -e yum-plugin-fastestmirror-1.1.31-45.el7.noarch --nodeps
[root@localhost yum.repos.d]# rpm -e  yum-metadata-parser-1.1.4-10.el7.x86_64
[root@localhost yum.repos.d]# rpm -e  yum-metadata-parser-1.1.4-10.el7.x86_64 --nodeps
[root@localhost yum.repos.d]# rpm -e yum-3.4.3-158.el7.centos.noarch --nodeps
[root@localhost yum.repos.d]# rpm -e yum-utils-1.1.31-45.el7.noarch --nodeps
[root@localhost yum.repos.d]# rpm -e yum-langpacks-0.4.2-7.el7.noarch --nodeps
warning: /etc/yum/pluginconf.d/langpacks.conf saved as /etc/yum/pluginconf.d/langpacks.conf.rpmsave

注意,上面的 --nodeps 要带上,否则会报错。

查看对应系统yum包,并从CenOS镜像网站下载

查看版本如下:

[root@localhost yum.repos.d]# cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core) 
[root@localhost yum.repos.d]# file /bin/ls
/bin/ls: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, BuildID[sha1]=c5ad78cfc1de12b9bb6829207cececb990b3e987, stripped


CentOS镜像网站地址:

http://vault.centos.org/

根据自己的版本进行下载对应软件包

wget http://vault.centos.org/7.5.1804/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-45.el7.noarch.rpm
wget http://vault.centos.org/7.5.1804/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget http://vault.centos.org/7.5.1804/os/x86_64/Packages/yum-3.4.3-158.el7.centos.noarch.rpm

下面两个也下载了一下,刚开始网页刷新慢,就只看到下面2个(-_-b),毕竟Packages是按照字母顺序排列显示的。
 

wget http://vault.centos.org/7.5.1804/os/x86_64/Packages/PackageKit-yum-1.1.5-1.el7.centos.x86_64.rpm
wget http://vault.centos.org/7.5.1804/os/x86_64/Packages/PackageKit-yum-plugin-1.1.5-1.el7.centos.x86_64.rpm

安装yum依赖包

[root@localhost tools]# rpm -ivh yum-*
warning: yum-3.4.3-158.el7.centos.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:yum-metadata-parser-1.1.4-10.el7 ################################# [ 33%]
   2:yum-plugin-fastestmirror-1.1.31-4################################# [ 67%]
   3:yum-3.4.3-158.el7.centos         ################################# [100%]

 

更新CentOS系统 repo 文件

查看/etc/yum.repos.d/ ,发现用的是CentOS7-Lan.repo  ,而不是CentOS-Base.repo。不过还是按照文章做法,改为用entOS-Base.repo。

[root@localhost yum.repos.d]# ls
CentOS7-Lan.repo      CentOS-CR.repo         CentOS-fasttrack.repo  CentOS-Sources.repo
CentOS-Base.repo.bak  CentOS-Debuginfo.repo  CentOS-Media.repo      CentOS-Vault.repo
[root@localhost yum.repos.d]# vim CentOS-Base.repo

 

这部分需要从 http://mirrors.ustc.edu.cn/help/centos.html  下载,根据操作系统,选择CenOS7

# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#

[base]
name=CentOS-$releasever - Base
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
baseurl=https://mirrors.ustc.edu.cn/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-$releasever - Updates
# mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
baseurl=https://mirrors.ustc.edu.cn/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
# mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
baseurl=https://mirrors.ustc.edu.cn/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
# mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
baseurl=https://mirrors.ustc.edu.cn/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
 

清除缓存,搞定

然后才是网上查到最对的两行命令:

yum clean all
yum makecache

附上操作结果
 

[root@localhost yum.repos.d]# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: base extras updates
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
Cleaning up list of fastest mirrors
[root@localhost yum.repos.d]# yum makecache 
Loaded plugins: fastestmirror
Determining fastest mirrors
base                                                                           | 3.6 kB  00:00:00     
extras                                                                         | 2.9 kB  00:00:00     
updates                                                                        | 2.9 kB  00:00:00     
(1/10): base/7/x86_64/group_gz                                                 | 165 kB  00:00:08     
(2/10): base/7/x86_64/filelists_db                                             | 7.3 MB  00:00:10     
(3/10): extras/7/x86_64/filelists_db                                           | 210 kB  00:00:00     
(4/10): extras/7/x86_64/primary_db                                             | 159 kB  00:00:00     
(5/10): extras/7/x86_64/other_db                                               | 103 kB  00:00:00     
(6/10): updates/7/x86_64/primary_db                                            | 6.7 MB  00:00:05     
(7/10): updates/7/x86_64/other_db                                              | 480 kB  00:00:01     
(8/10): updates/7/x86_64/filelists_db                                          | 4.0 MB  00:00:12     
(9/10): base/7/x86_64/other_db                                                 | 2.6 MB  00:00:13     
(10/10): base/7/x86_64/primary_db                                              | 6.0 MB  00:00:16     
Metadata Cache Created
[root@localhost yum.repos.d]# yum -y install screen
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package screen.x86_64 0:4.1.0-0.25.20120314git3c2946.el7 will be installed
--> Finished Dependency Resolution

 

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值