CDN加速

文档中心 云服务器 常见问题 Linux操作运维类 20. CentOS 6 无法yum安装怎么办

20. CentOS 6 无法yum安装怎么办

更新时间:2021-05-08 15:21:34

由于CentOS社区不再为CentOS 6版本提供安全更新,网宿云将不再提供CentOS6操作系统相关的技术支持并适时停止提供CentOS6的公有镜像。
建议您升级操作系统至CentOS 7及以上,如果您的业务过渡期仍需要使用CentOS 6系统中的一些安装包,请根据以下操作步骤切换CentOS 6的源。

操作步骤

1.运行以下命令编辑CentOS-Base.repo 文件。

vi /etc/yum.repos.d/CentOS6-Base-Wangsu.repo 

2.按i进入编辑模式,将代码替换成以下内容切换源。

# 	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.
#
#

[wangsu-base]
name=CentOS-6 - Base - wangsucloud.com
baseurl=http://mirrors.cloud.wangsucloud.com/centos-vault/6/os/$basearch/
#mirrorlist=http://mirrors.cloud.wangsucloud.com/?release=6&arch=$basearch&repo=os
gpgcheck=1
gpgkey=http://mirrors.cloud.wangsucloud.com/centos-vault/RPM-GPG-KEY-CentOS-6

#released updates 
[wangsu-updates]
name=CentOS-6 - Updates - wangsucloud.com
baseurl=http://mirrors.cloud.wangsucloud.com/centos-vault/6/updates/$basearch/
#mirrorlist=http://mirrors.cloud.wangsucloud.com/?release=6&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=http://mirrors.cloud.wangsucloud.com/centos-vault/RPM-GPG-KEY-CentOS-6

#additional packages that may be useful
[wangsu-extras]
name=CentOS-6 - Extras - wangsucloud.com
baseurl=http://mirrors.cloud.wangsucloud.com/centos-vault/6/extras/$basearch/
#mirrorlist=http://mirrors.cloud.wangsucloud.com/?release=6&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=http://mirrors.cloud.wangsucloud.com/centos-vault/RPM-GPG-KEY-CentOS-6

#additional packages that extend functionality of existing packages
[wangsu-centosplus]
name=CentOS-6 - Plus - wangsucloud.com
baseurl=http://mirrors.cloud.wangsucloud.com/centos-vault/6/centosplus/$basearch/
#mirrorlist=http://mirrors.cloud.wangsucloud.com/?release=6&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=http://mirrors.cloud.wangsucloud.com/centos-vault/RPM-GPG-KEY-CentOS-6

#contrib - packages by Centos Users
[wangsu-contrib]
name=CentOS-6 - Contrib - wangsucloud.com
baseurl=http://mirrors.cloud.wangsucloud.com/centos-vault/6/contrib/$basearch/
#mirrorlist=http://mirrors.cloud.wangsucloud.com/?release=6&arch=$basearch&repo=contrib
gpgcheck=1
enabled=0
gpgkey=http://mirrors.cloud.wangsucloud.com/centos-vault/RPM-GPG-KEY-CentOS-6

priority=1

编辑完成后,按Esc键,并输入:wq保存退出文件。
3.执行以下命令,清理原缓存

yum clean all

yum源切换完成后,即可使用yum install命令在实例上安装您所需要的软件包。