CentOS使用网易yum源

CentOS默认使用官方yum的话国内速度实在太慢,不过我们可以替换为其他第三方yum源,比如网易、阿里云、中科大等。这篇文章分享下CentOS 6怎样替换为网易yum源。

CentOS 6

备份配置

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

下载repo文件

wget http://mirrors.163.com/.help/CentOS6-Base-163.repo

CentOS社区于2020年11月30日结束对CentOS 6的维护支持(EOL)。CentOS社区不再提供针对CentOS 6的安全补丁更新及镜像源支持,相应的镜像源软件包已经从CentOS 6的源地址http://mirror.centos.org/centos-6/中移除,第三方镜像中也均已移除CentOS 6的源。

需要修改CentOS6-Base.repo内容为:

[base]
name=CentOS-6.8 -Base -vault.centos.org
failovermethod=priority
baseurl=http://vault.centos.org/6.8/os/$basearch/
gpgcheck=1
gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-6

#released updates
[updates]
name=CentOS-6.8 -Updates -vault.centos.org
failovermethod=priority
baseurl=http://vault.centos.org/6.8/updates/$basearch/
gpgcheck=1
gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-6
#additional packages that may be useful

[extras]
name=CentOS-6.8 -Extras -vault.centos.org
failovermethod=priority
baseurl=http://vault.centos.org/6.8/extras/$basearch/
gpgcheck=1
gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-6
#additional packages that extend functionality of existing packages

[centosplus]
name=CentOS-6.8 -Plus -vault.centos.org
failovermethod=priority
baseurl=http://vault.centos.org/6.8/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-6
#contrib -packages by Centos Users

[contrib]
name=CentOS-6.8 -Contrib -vault.centos.org
failovermethod=priority
baseurl=http://vault.centos.org/6.8/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-6

其中6.8改成你自己的操作系统版本,可通过cat /etc/redhat-release查看。如果是国内网络,可以修改为清华大学镜像:

[base]
name=CentOS-6.8 -Base -mirrors.tuna.tsinghua.edu.cn/centos-vault
failovermethod=priority
baseurl=http://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.8/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.tuna.tsinghua.edu.cn/centos-vault/RPM-GPG-KEY-CentOS-6

#released updates
[updates]
name=CentOS-6.8 -Updates -mirrors.tuna.tsinghua.edu.cn/centos-vault
failovermethod=priority
baseurl=http://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.8/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.tuna.tsinghua.edu.cn/centos-vault/RPM-GPG-KEY-CentOS-6
#additional packages that may be useful

[extras]
name=CentOS-6.8 -Extras -mirrors.tuna.tsinghua.edu.cn/centos-vault
failovermethod=priority
baseurl=http://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.8/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.tuna.tsinghua.edu.cn/centos-vault/RPM-GPG-KEY-CentOS-6
#additional packages that extend functionality of existing packages

[centosplus]
name=CentOS-6.8 -Plus -mirrors.tuna.tsinghua.edu.cn/centos-vault
failovermethod=priority
baseurl=http://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.8/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.tuna.tsinghua.edu.cn/centos-vault/RPM-GPG-KEY-CentOS-6
#contrib -packages by Centos Users

[contrib]
name=CentOS-6.8 -Contrib -mirrors.tuna.tsinghua.edu.cn/centos-vault
failovermethod=priority
baseurl=http://mirrors.tuna.tsinghua.edu.cn/centos-vault/6.8/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.tuna.tsinghua.edu.cn/centos-vault/RPM-GPG-KEY-CentOS-6

生成缓存

yum clean all
yum makecache

CentOS 7

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
cd /etc/yum.repos.d/
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
yum makecache
yum -y update

详细说明请参考官方:http://mirrors.163.com/.help/centos.html

标签: centos教程 yum

发表评论: