centos6 更换可用yum源

报错提示:yum 使用报错

 [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"
Trying other mirror.

 linux官方自 2020 年 11 月底起不再维护 CentOS 6 了,所以之前的 yum 存储库也不能用了:

解决办法

1、进入到 /etc/yum.repos.d目录下

cd /etc/yum.repos.d

2、先备份原来的 CentOS-Base.repo 文件

cp CentOS-Base.repo CentOS-Base.repo.old

3、修改 CentOS-Base.repo 文件

vi CentOS-Base.repo

主要修改 baseurl 的值,包括 [base]、[updates] 和 [extras]

下面这两个应该都可以直接粘过去用 ,第二个可以第一个忘了

[base]  
name=CentOS-$releasever - Base        #注意这里的relasever指的是你的系统版本号 解决不了手打上去
release=$releasever&arch=$basearch&repo=os&infra=$infra

baseurl=https://mirrors.aliyun.com/centos-vault/6.10/os/$basearch/  #这个网站是通的就不会404
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6


[updates]
name=CentOS-$releasever - Updates
release=$releasever&arch=$basearch&repo=updates&infra=$infra

baseurl=https://mirrors.aliyun.com/centos-vault/6.10/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6


[extras]
name=CentOS-$releasever - Extras
release=$releasever&arch=$basearch&repo=extras&infra=$infra

baseurl=https://mirrors.aliyun.com/centos-vault/6.10/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/6.4/os/Source/
gpgcheck=1
gpgkey=http://mirrors.aliyuncs.com/centos-vault/RPM-GPG-KEY-CentOS-6
#released updates 
[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos-vault/6.4/os/Source/
gpgcheck=1
gpgkey=http://mirrors.aliyuncs.com/centos-vault/RPM-GPG-KEY-CentOS-6

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority

baseurl=https://mirrors.aliyun.com/centos-vault/6.4/os/Source/
gpgcheck=1
gpgkey=http://mirrors.aliyuncs.com/centos-vault/RPM-GPG-KEY-CentOS-6

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos-vault/6.4/os/Source/
gpgcheck=1
gpgkey=http://mirrors.aliyuncs.com/centos-vault/RPM-GPG-KEY-CentOS-6

enabled=1

#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos-vault/6.4/os/Source/
gpgcheck=1
gpgkey=http://mirrors.aliyuncs.com/centos-vault/RPM-GPG-KEY-CentOS-6

enabled=1

这也是一个 

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

[os]
name=Qcloud centos os - $basearch
baseurl=https://mirrors.cloud.tencent.com/centos/$releasever/os/$basearch/
enabled=1
gpgcheck=1
gpgkey=https://mirrors.cloud.tencent.com/centos/RPM-GPG-KEY-CentOS-6

[updates]
name=Qcloud centos updates - $basearch
baseurl=https://mirrors.cloud.tencent.com/centos/$releasever/updates/$basearch/
enabled=1
gpgcheck=1
gpgkey=https://mirrors.cloud.tencent.com/centos/RPM-GPG-KEY-CentOS-6

[centosplus]
name=Qcloud centosplus - $basearch
baseurl=https://mirrors.cloud.tencent.com/centos/$releasever/centosplus/$basearch/
enabled=0
gpgcheck=1
gpgkey=https://mirrors.cloud.tencent.com/centos/RPM-GPG-KEY-CentOS-6

[contrib]
name=Qcloud centos contrib - $basearch
baseurl=https://mirrors.cloud.tencent.com/centos/$releasever/contrib/$basearch/
enabled=0
gpgcheck=1
gpgkey=https://mirrors.cloud.tencent.com/centos/RPM-GPG-KEY-CentOS-6

[cr]
name=Qcloud centos cr - $basearch
baseurl=https://mirrors.cloud.tencent.com/centos/$releasever/cr/$basearch/
enabled=0
gpgcheck=1
gpgkey=https://mirrors.cloud.tencent.com/centos/RPM-GPG-KEY-CentOS-6

[extras]
name=Qcloud centos extras - $basearch
baseurl=https://mirrors.cloud.tencent.com/centos/$releasever/extras/$basearch/
enabled=1
gpgcheck=1
gpgkey=https://mirrors.cloud.tencent.com/centos/RPM-GPG-KEY-CentOS-6

[fasttrack]
name=Qcloud centos fasttrack - $basearch
baseurl=https://mirrors.cloud.tencent.com/centos/$releasever/fasttrack/$basearch/
enabled=0
gpgcheck=1
gpgkey=https://mirrors.cloud.tencent.com/centos/RPM-GPG-KEY-CentOS-6

清楚缓存

yum clean all

生成缓存

yum makecache

centos6配置epel源

rpm -Uvh http://mirrors.ustc.edu.cn/centos-vault/7.0.1406/extras/x86_64/Packages/epel-release-7-5.noarch.rpm 

centos6 配置epel源报错的话可以把几条配置改为如下

baseurl=http://mirrors.sohu.com/fedora-epel/6/$basearch
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

如下是我centos6配置yum源和epel的截图

yum源

centos6 更换可用yum源_第1张图片

epel

centos6 更换可用yum源_第2张图片

你可能感兴趣的:(centos,linux,运维)