自己最近使用CentOS7 X64 先用yum 安装下 tree,一直提示下面错误,网上查了很多方式一直都没解决,幸好**** 大牛多多,找了这篇文章:/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 ]# rpm -qa|grep yum
yum-metadata-parser-1.1.4-10.el7.x86_64
yum-utils-1.1.31-45.
PackageKit-yum-1.1.5-1..x86_64
yum-3.4.3-158.
yum-langpacks-0.4.2-7.
yum-plugin-fastestmirror-1.1.31-45.
[root@localhost ]# rpm -e yum-plugin-fastestmirror-1.1.31-45. --nodeps
[root@localhost ]# rpm -e yum-metadata-parser-1.1.4-10.el7.x86_64
[root@localhost ]# rpm -e yum-metadata-parser-1.1.4-10.el7.x86_64 --nodeps
[root@localhost ]# rpm -e yum-3.4.3-158. --nodeps
[root@localhost ]# rpm -e yum-utils-1.1.31-45. --nodeps
[root@localhost ]# rpm -e yum-langpacks-0.4.2-7. --nodeps
warning: /etc/yum// saved as /etc/yum//
注意,上面的 --nodeps 要带上,否则会报错。
查看对应系统yum包,并从CenOS镜像网站下载
查看版本如下:
[root@localhost ]# cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
[root@localhost ]# 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镜像网站地址:
/
根据自己的版本进行下载对应软件包
wget /7.5.1804/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-45.
wget /7.5.1804/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget /7.5.1804/os/x86_64/Packages/yum-3.4.3-158.
下面两个也下载了一下,刚开始网页刷新慢,就只看到下面2个(-_-b),毕竟Packages是按照字母顺序排列显示的。
wget /7.5.1804/os/x86_64/Packages/PackageKit-yum-1.1.5-1..x86_64.rpm
wget /7.5.1804/os/x86_64/Packages/PackageKit-yum-plugin-1.1.5-1..x86_64.rpm
安装yum依赖包
[root@localhost tools]# rpm -ivh yum-*
warning: yum-3.4.3-158.: 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. ################################# [100%]
更新CentOS系统 repo 文件
查看/etc// ,发现用的是 ,而不是。不过还是按照文章做法,改为用。
[root@localhost ]# ls
[root@localhost ]# vim
这部分需要从 /help/ 下载,根据操作系统,选择CenOS7
#
#
# 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=/?release=$releasever&arch=$basearch&repo=os
baseurl=/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=/?release=$releasever&arch=$basearch&repo=updates
baseurl=/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=/?release=$releasever&arch=$basearch&repo=extras
baseurl=/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=/?release=$releasever&arch=$basearch&repo=centosplus
baseurl=/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 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 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 -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