阿里巴巴开源镜像站
Page:https://developer.aliyun.com/mirror/
使用说明
CentOS旧版本镜像地址为:https://mirrors.aliyun.com/centos-vault/
- 备份配置文件:
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
- 下载新的CentOS-Base.repo 到/etc/yum.repos.d/
CentOS6:wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
CentOS7:wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
华为开源镜像站
Page:https://mirrors.huaweicloud.com/
使用说明
CentOS旧版本镜像地址为:https://repo.huaweicloud.com/centos-vault/
- 备份配置文件:
cp -a /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
- 修改CentOS-Base.repo文件,取消baseurl开头的行的注释,并增加mirrorlist开头的行的注释。将文件中的http://mirror.centos.org替换成https://mirrors.huaweicloud.com,可以参考如下命令:
sed -i "s/#baseurl/baseurl/g" /etc/yum.repos.d/CentOS-Base.repo
sed -i "s/mirrorlist=http/#mirrorlist=http/g" /etc/yum.repos.d/CentOS-Base.repo
sed -i "s@http://mirror.centos.org@https://repo.huaweicloud.com@g" /etc/yum.repos.d/CentOS-Base.repo
清华大学开源镜像站
Page:https://mirrors.tuna.tsinghua.edu.cn/
使用说明
CentOS旧版本镜像地址为:https://mirrors.tuna.tsinghua.edu.cn/centos-vault/
- 备份配置文件:
cp -a /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
- 修改CentOS-Base.repo文件,取消baseurl开头的行的注释,并增加mirrorlist开头的行的注释。将文件中的http://mirror.centos.org替换成http://mirrors.tuna.tsinghua.edu.cn,可以参考如下命令:
sed -i "s|#baseurl|baseurl|g" /etc/yum.repos.d/CentOS-Base.repo
sed -i "s|^mirrorlist=|#mirrorlist=|g" /etc/yum.repos.d/CentOS-Base.repo
sed -i "s|http://mirror.centos.org|https://mirrors.tuna.tsinghua.edu.cn|g" /etc/yum.repos.d/CentOS-Base.repo
RHEL使用CentOS源
※ 免责声明:以下内容仅作参考!
- 删除RedHat自带的yum源
查看:rpm -qa | grep ^yum
删除:rpm -qa | grep yum | xargs rpm -e --nodeps
- 下载CentOS镜像的yum包
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-158.el7.centos.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-rhn-plugin-2.0.1-10.el7.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-45.el7.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
- 安装yum包提示“rpm >= 0:4.11.3-22 is needed by yum-3.4.3-158.el7.centos.noarch”
rpm -qa | grep ^rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/rpm-4.11.3-32.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/rpm-libs-4.11.3-32.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/rpm-python-4.11.3-32.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/rpm-build-libs-4.11.3-32.el7.x86_64.rpm
rpm -Uvh rpm-*.rpm
- 安装CentOS镜像的yum包
rpm -ivh yum-*.rpm
- 替换.repo文件中的$releasever版本为7
sed -i "s/\$releasever/7/g" /etc/yum.repos.d/CentOS-Base.repo
- 安装EPEL源
yum install epel-release
- 检查yum源可用性
yum repolist && yum list all
- yum update提示"Error: initscripts conflicts with redhat-release-server"
yum check-update && yum update --skip-broken
吐槽:在RHEL 7.3系统上仅执行5,7,8步骤可以使用yum update,重装与不重装yum包都会提示“This system is not registered to Red Hat Subscription Management.”(CentOS 7.5 YUM源),可以跳过1,2,3,4步骤。
重建本地YUM缓存
- repo 文件下载链接,CentOS-7包含epel源
centos6-aliyun.repo
centos7-epel-aliyun.repo
centos6-huaweicloud.repo
centos7-epel-huaweicloud.repo - 清理本地YUM缓存
yum clean all && yum makecache
CentOS Mirror Status
http://mirror-status.centos.org/
从镜像状态统计来看,“华为开源镜像站、阿里巴巴开源镜像站”实时更新良好。
文章出自: 本站技术文章均为原创,版权归 "Desen往事 - 个人博客" 所有;部分图片来源于 Yandex ,转载本站文章请注明来源。
本文标题:CentOS国内YUM源及配置
感谢-感谢-感谢!
要说技术哪家强,咱们中国的网站就是强!