解決Redhat 7 不能用yum安裝軟體
1.check yum在linux所安裝的包
#rpm -qa| grep yum
yum-utils-1.1.31-24.el7.noarch
yum-langpacks-0.4.2-3.el7.noarch
yum-metadata-parser-1.1.4-10.el7.x86_64
yum-rhn-plugin-2.0.1-4.el7.noarch
PackageKit-yum-0.8.9-11.el7.x86_64
yum-3.4.3-118.el7.noarch
2.刪除相應的包
#rpm -e yum-3.4.3-118.el7.noarch --nodeps
# rpm -e yum-utils-1.1.31-24.el7.noarch --nodeps
# rpm -e yum-rhn-plugin-2.0.1-4.el7.noarch --nodeps
# rpm -e yum-metadata-parser-1.1.4-10.el7.x86_64 --nodeps
# rpm -e yum-langpacks-0.4.2-3.el7.noarch --nodeps
# rpm -e PackageKit-yum-0.8.9-11.el7.x86_64 --nodeps
3.確認其主機能上網
4.下載以下包
5、找到自己所需要的版本下載:
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-150.el7.centos.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-utils-1.1.31-40.el7.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-updateonboot-1.1.31-40.el7.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-40.el7.noarch.rpm
6.安裝相應的yum包,但會出錯:
# rpm -ivh yum-*
warning: yum-3.4.3-150.el7.centos.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
error: Failed dependencies:
python-urlgrabber >= 3.10-8 is needed by yum-3.4.3-150.el7.centos.noarch
7. 連結:http://rpm.pbone.net/, 不報錯版本安裝包:
yum-3.4.3-132.el7.centos.0.1.noarch.rpm
yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
yum-plugin-fastestmirror-1.1.31-34.el7.noarch.rpm
yum-updateonboot-1.1.31-34.el7.noarch.rpm
yum-utils-1.1.31-34.el7.noarch.rpm
8.安裝下載的包
# ls
yum-3.4.3-132.el7.centos.0.1.noarch.rpm yum-updateonboot-1.1.31-34.el7.noarch.rpm
yum-metadata-parser-1.1.4-10.el7.x86_64.rpm yum-utils-1.1.31-34.el7.noarch.rpm
yum-plugin-fastestmirror-1.1.31-34.el7.noarch.rpm
# rpm -ivh yum-*
warning: yum-3.4.3-132.el7.centos.0.1.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:yum-metadata-parser-1.1.4-10.el7 ################################# [ 20%]
2:yum-plugin-fastestmirror-1.1.31-3################################# [ 40%]
3:yum-3.4.3-132.el7.centos.0.1 ################################# [ 60%]
4:yum-updateonboot-1.1.31-34.el7 ################################# [ 80%]
5:yum-utils-1.1.31-34.el7 ################################# [100%]
9.建repo配置檔案:
# vim /etc/yum.repos.d/CentOS-Base.repo
#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-$7 - Base - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$7&arch=$basearch&repo=os
baseurl=http://mirrors.163.com/centos/7/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$7 - Updates - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$7&arch=$basearch&repo=updates
baseurl=http://mirrors.163.com/centos/7/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$7 - Extras - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$7&arch=$basearch&repo=extras
baseurl=http://mirrors.163.com/centos/7/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$7 - Plus - 163.com
baseurl=http://mirrors.163.com/centos/7/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
10.清除緩衝
# yum clean all