众所周知,centos 7 在2024年6月30日,生命周期结束,官方不再进行支持维护,而很多环境一时之间无法完全更新替换操作系统,因此对于yum源还是需要的,特别是对于互联网环境来说,在线yum源使用方便很多,而不需要去搭建本地yum源和内网yum源。
这里以阿里云为例,其他国内开源镜像站类似。此处主要以7.9为例。
1. 备份默认的repo文件
cd /etc/yum.repos.dmkdir backupmv *.repo backup
2.配置阿里云的yum源
cat > CentOS-aliyun-lhr.repo << 'EOF'[base]name=CentOS-$releasever - Base - mirrors.aliyun.comfailovermethod=prioritybaseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/ http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/ http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/gpgcheck=1gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 #released updates [updates]name=CentOS-$releasever - Updates - mirrors.aliyun.comfailovermethod=prioritybaseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/ http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/ http://mirrors.cloud.aliyuncs.com/centos/$releasever/updates/$basearch/gpgcheck=1gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 #additional packages that may be useful[extras]name=CentOS-$releasever - Extras - mirrors.aliyun.comfailovermethod=prioritybaseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/ http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/ http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/gpgcheck=1gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 #additional packages that extend functionality of existing packages[centosplus]name=CentOS-$releasever - Plus - mirrors.aliyun.comfailovermethod=prioritybaseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/ http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/ http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/gpgcheck=1enabled=0gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7 #contrib - packages by Centos Users[contrib]name=CentOS-$releasever - Contrib - mirrors.aliyun.comfailovermethod=prioritybaseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/ http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/ http://mirrors.cloud.aliyuncs.com/centos/$releasever/contrib/$basearch/gpgcheck=1enabled=0gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7EOF
cat > epel-aliyun.repo <<'EOF'[epel]name=Extra Packages for Enterprise Linux 7 - $basearchbaseurl=http://mirrors.aliyun.com/epel/7/$basearchfailovermethod=priorityenabled=1gpgcheck=0gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 [epel-debuginfo]name=Extra Packages for Enterprise Linux 7 - $basearch - Debugbaseurl=http://mirrors.aliyun.com/epel/7/$basearch/debugfailovermethod=priorityenabled=0gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7gpgcheck=0 [epel-source]name=Extra Packages for Enterprise Linux 7 - $basearch - Sourcebaseurl=http://mirrors.aliyun.com/epel/7/SRPMSfailovermethod=priorityenabled=0gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7gpgcheck=0EOF
3. 检查验证
yum clean allyum makecache fastyum install vim lrzsz wget curl net-tools
4. 其他可用yum源搜集
1)官方yum源
cat > CentOS-Base.repo <<'EOF'[base]name=CentOS-7.9.2009enabled=1failovermethod=prioritybaseurl=https://vault.centos.org/7.9.2009/os/$basearch/gpgcheck=1gpgkey=https://vault.centos.org/RPM-GPG-KEY-CentOS-7[updates]name=CentOS-7.9.2009enabled=1failovermethod=prioritybaseurl=https://vault.centos.org/7.9.2009/updates/$basearch/gpgcheck=1gpgkey=https://vault.centos.org/RPM-GPG-KEY-CentOS-7[extras]name=CentOS-7.9.2009enabled=1failovermethod=prioritybaseurl=https://vault.centos.org/7.9.2009/extras/$basearch/gpgcheck=1gpgkey=https://vault.centos.org/RPM-GPG-KEY-CentOS-7EOF
2)官方epel扩展源
cat > epel.repo <<'EOF'[epel]name=Extra Packages for Enterprise Linux 7 - $basearch#baseurl=http://download.fedoraproject.org/pub/epel/7/$basearchmetalink=https://mirrors.fedoraproject.org/metalink?repo=epel-7&arch=$basearchfailovermethod=priorityenabled=1gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7[epel-debuginfo]name=Extra Packages for Enterprise Linux 7 - $basearch - Debug#baseurl=http://download.fedoraproject.org/pub/epel/7/$basearch/debugmetalink=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-7&arch=$basearchfailovermethod=priorityenabled=0gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7gpgcheck=1[epel-source]name=Extra Packages for Enterprise Linux 7 - $basearch - Source#baseurl=http://download.fedoraproject.org/pub/epel/7/SRPMSmetalink=https://mirrors.fedoraproject.org/metalink?repo=epel-source-7&arch=$basearchfailovermethod=priorityenabled=0gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7gpgcheck=1EOF
cat > epel-testing.repo <<'EOF'[epel-testing]name=Extra Packages for Enterprise Linux 7 - Testing - $basearch#baseurl=http://download.fedoraproject.org/pub/epel/testing/7/$basearchmetalink=https://mirrors.fedoraproject.org/metalink?repo=testing-epel7&arch=$basearchfailovermethod=priorityenabled=0gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7[epel-testing-debuginfo]name=Extra Packages for Enterprise Linux 7 - Testing - $basearch - Debug#baseurl=http://download.fedoraproject.org/pub/epel/testing/7/$basearch/debugmetalink=https://mirrors.fedoraproject.org/metalink?repo=testing-debug-epel7&arch=$basearchfailovermethod=priorityenabled=0gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7gpgcheck=1[epel-testing-source]name=Extra Packages for Enterprise Linux 7 - Testing - $basearch - Source#baseurl=http://download.fedoraproject.org/pub/epel/testing/7/SRPMSmetalink=https://mirrors.fedoraproject.org/metalink?repo=testing-source-epel7&arch=$basearchfailovermethod=priorityenabled=0gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7gpgcheck=1EOF
3) 清华大学yum源
cat > CentOS-tsinghua.repo <<'EOF'[base]name=CentOS-7.9.2009enabled=1failovermethod=prioritybaseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/7.9.2009/os/$basearch/gpgcheck=1gpgkey=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/RPM-GPG-KEY-CentOS-7[updates]name=CentOS-7.9.2009enabled=1failovermethod=prioritybaseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/7.9.2009/updates/$basearch/gpgcheck=1gpgkey=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/RPM-GPG-KEY-CentOS-7[extras]name=CentOS-7.9.2009enabled=1failovermethod=prioritybaseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/7.9.2009/extras/$basearch/gpgcheck=1gpgkey=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/RPM-GPG-KEY-CentOS-7[epel]name=Extra Packages for Enterprise Linux 7 - enabled=1failovermethod=prioritybaseurl=https://mirrors.tuna.tsinghua.edu.cn/epel/7/$basearch/gpgcheck=0gpgkey=https://mirrors.tuna.tsinghua.edu.cn/epel/RPM-GPG-KEY-EPEL-7EOF
4)中科大yum源
cat > CentOS-ustc.repo <<'EOF'[base]name=CentOS- - Basebaseurl=https://mirrors.ustc.edu.cn/centos-vault/centos/7.9.2009/os/$basearch/gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7[updates]name=CentOS- - Updatesbaseurl=https://mirrors.ustc.edu.cn/centos-vault/centos/7.9.2009/updates/$basearch/gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7[extras]name=CentOS- - Extrasbaseurl=https://mirrors.ustc.edu.cn/centos-vault/centos/7.9.2009/extras/$basearch/gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7[centosplus]name=CentOS- - Plusbaseurl=https://mirrors.ustc.edu.cn/centos-vault/centos/7.9.2009/centosplus/$basearch/gpgcheck=1enabled=0gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7EOF
5)网易yum源
cat > CentOS-163.repo <<'EOF'[base]name=CentOS-$releasever - Base - 163.com#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=osbaseurl=http://mirrors.163.com/centos-vault/7.9.2009/os/$basearch/gpgcheck=1gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7#released updates[updates]name=CentOS-$releasever - Updates - 163.com#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updatesbaseurl=http://mirrors.163.com/centos-vault/7.9.2009/updates/$basearch/gpgcheck=1gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7#additional packages that may be useful[extras]name=CentOS-$releasever - Extras - 163.com#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extrasbaseurl=http://mirrors.163.com/centos-vault/7.9.2009/extras/$basearch/gpgcheck=1gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7#additional packages that extend functionality of existing packages[centosplus]name=CentOS-$releasever - Plus - 163.combaseurl=http://mirrors.163.com/centos-vault/7.9.2009/centosplus/$basearch/gpgcheck=1enabled=0gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7EOF
6) 腾讯yum源
cat > CentOS7-tencent-x86-64.repo << 'EOF'[base]name=CentOS-$releasever - base - mirrors.cloud.tencent.combaseurl=https://mirrors.cloud.tencent.com/centos-vault/centos/$releasever/os/$basearch/enabled=1gpgcheck=1gpgkey=https://mirrors.cloud.tencent.com/centos-vault/RPM-GPG-KEY-CentOS-7 [updates]name=CentOS-$releasever - updates - mirrors.cloud.tencent.combaseurl=https://mirrors.cloud.tencent.com/centos-vault/centos/$releasever/updates/$basearch/enabled=1gpgcheck=1gpgkey=https://mirrors.cloud.tencent.com/centos-vault/RPM-GPG-KEY-CentOS-7 [extras]name=CentOS-$releasever - extras - mirrors.cloud.tencent.combaseurl=https://mirrors.cloud.tencent.com/centos-vault/centos/$releasever/extras/$basearch/enabled=1gpgcheck=1gpgkey=https://mirrors.cloud.tencent.com/centos-vault/RPM-GPG-KEY-CentOS-7 [centosplus]name=CentOS-$releasever - centosplus - mirrors.cloud.tencent.combaseurl=https://mirrors.cloud.tencent.com/centos-vault/centos/$releasever/centosplus/$basearch/enabled=0gpgcheck=1gpgkey=https://mirrors.cloud.tencent.com/centos-vault/RPM-GPG-KEY-CentOS-7 [fasttrack]name=CentOS-$releasever - fasttrack - mirrors.cloud.tencent.combaseurl=https://mirrors.cloud.tencent.com/centos-vault/centos/$releasever/fasttrack/$basearch/enabled=0gpgcheck=1gpgkey=https://mirrors.cloud.tencent.com/centos-vault/RPM-GPG-KEY-CentOS-7[atomic]name=CentOS-$releasever - atomic - mirrors.cloud.tencent.combaseurl=https://mirrors.cloud.tencent.com/centos-vault/centos/$releasever/atomic/$basearch/enabled=0gpgcheck=1gpgkey=https://mirrors.cloud.tencent.com/centos-vault/RPM-GPG-KEY-CentOS-7[dotnet]name=CentOS-$releasever - dotnet - mirrors.cloud.tencent.combaseurl=https://mirrors.cloud.tencent.com/centos-vault/centos/$releasever/dotnet/$basearch/enabled=0gpgcheck=1gpgkey=https://mirrors.cloud.tencent.com/centos-vault/RPM-GPG-KEY-CentOS-7[rt]name=CentOS-$releasever - rt - mirrors.cloud.tencent.combaseurl=https://mirrors.cloud.tencent.com/centos-vault/centos/$releasever/rt/$basearch/enabled=0gpgcheck=1gpgkey=https://mirrors.cloud.tencent.com/centos-vault/RPM-GPG-KEY-CentOS-7[sclo-rh]name=CentOS-$releasever - sclo-rh - mirrors.cloud.tencent.combaseurl=https://mirrors.cloud.tencent.com/centos-vault/centos/$releasever/sclo/$basearch/rh/enabled=0gpgcheck=1gpgkey=https://mirrors.cloud.tencent.com/centos-vault/RPM-GPG-KEY-CentOS-7[sclo-sclo]name=CentOS-$releasever - sclo-sclo - mirrors.cloud.tencent.combaseurl=https://mirrors.cloud.tencent.com/centos-vault/centos/$releasever/sclo/$basearch/sclo/enabled=0gpgcheck=1gpgkey=https://mirrors.cloud.tencent.com/centos-vault/RPM-GPG-KEY-CentOS-7EOF
7) 荆楚理工学院yum源
cat > CentOS7-jcut-x86-64.repo << 'EOF'[base]name=CentOS-$releasever - base - mirrors.jcut.edu.cnbaseurl=https://mirrors.jcut.edu.cn/centos-vault/centos/$releasever/os/$basearch/enabled=1gpgcheck=1gpgkey=https://mirrors.jcut.edu.cn/centos-vault/RPM-GPG-KEY-CentOS-7 [updates]name=CentOS-$releasever - updates - mirrors.jcut.edu.cnbaseurl=https://mirrors.jcut.edu.cn/centos-vault/centos/$releasever/updates/$basearch/enabled=1gpgcheck=1gpgkey=https://mirrors.jcut.edu.cn/centos-vault/RPM-GPG-KEY-CentOS-7 [extras]name=CentOS-$releasever - extras - mirrors.jcut.edu.cnbaseurl=https://mirrors.jcut.edu.cn/centos-vault/centos/$releasever/extras/$basearch/enabled=1gpgcheck=1gpgkey=https://mirrors.jcut.edu.cn/centos-vault/RPM-GPG-KEY-CentOS-7 [centosplus]name=CentOS-$releasever - centosplus - mirrors.jcut.edu.cnbaseurl=https://mirrors.jcut.edu.cn/centos-vault/centos/$releasever/centosplus/$basearch/enabled=0gpgcheck=1gpgkey=https://mirrors.jcut.edu.cn/centos-vault/RPM-GPG-KEY-CentOS-7 [fasttrack]name=CentOS-$releasever - fasttrack - mirrors.jcut.edu.cnbaseurl=https://mirrors.jcut.edu.cn/centos-vault/centos/$releasever/fasttrack/$basearch/enabled=0gpgcheck=1gpgkey=https://mirrors.jcut.edu.cn/centos-vault/RPM-GPG-KEY-CentOS-7[atomic]name=CentOS-$releasever - atomic - mirrors.jcut.edu.cnbaseurl=https://mirrors.jcut.edu.cn/centos-vault/centos/$releasever/atomic/$basearch/enabled=0gpgcheck=1gpgkey=https://mirrors.jcut.edu.cn/centos-vault/RPM-GPG-KEY-CentOS-7[dotnet]name=CentOS-$releasever - dotnet - mirrors.jcut.edu.cnbaseurl=https://mirrors.jcut.edu.cn/centos-vault/centos/$releasever/dotnet/$basearch/enabled=0gpgcheck=1gpgkey=https://mirrors.jcut.edu.cn/centos-vault/RPM-GPG-KEY-CentOS-7[rt]name=CentOS-$releasever - rt - mirrors.jcut.edu.cnbaseurl=https://mirrors.jcut.edu.cn/centos-vault/centos/$releasever/rt/$basearch/enabled=0gpgcheck=1gpgkey=https://mirrors.jcut.edu.cn/centos-vault/RPM-GPG-KEY-CentOS-7[sclo-rh]name=CentOS-$releasever - sclo-rh - mirrors.jcut.edu.cnbaseurl=https://mirrors.jcut.edu.cn/centos-vault/centos/$releasever/sclo/$basearch/rh/enabled=0gpgcheck=1gpgkey=https://mirrors.jcut.edu.cn/centos-vault/RPM-GPG-KEY-CentOS-7[sclo-sclo]name=CentOS-$releasever - sclo-sclo - mirrors.jcut.edu.cnbaseurl=https://mirrors.jcut.edu.cn/centos-vault/centos/$releasever/sclo/$basearch/sclo/enabled=0gpgcheck=1gpgkey=https://mirrors.jcut.edu.cn/centos-vault/RPM-GPG-KEY-CentOS-7EOF
8) 南阳理工学院yum源
cat > CentOS7-nyist-x86-64.repo << 'EOF'[base]name=CentOS-$releasever - base - mirrors.nyist.edu.cnbaseurl=https://mirrors.nyist.edu.cn/centos-vault/centos/$releasever/os/$basearch/enabled=1gpgcheck=1gpgkey=https://mirrors.nyist.edu.cn/centos-vault/RPM-GPG-KEY-CentOS-7 [updates]name=CentOS-$releasever - updates - mirrors.nyist.edu.cnbaseurl=https://mirrors.nyist.edu.cn/centos-vault/centos/$releasever/updates/$basearch/enabled=1gpgcheck=1gpgkey=https://mirrors.nyist.edu.cn/centos-vault/RPM-GPG-KEY-CentOS-7 [extras]name=CentOS-$releasever - extras - mirrors.nyist.edu.cnbaseurl=https://mirrors.nyist.edu.cn/centos-vault/centos/$releasever/extras/$basearch/enabled=1gpgcheck=1gpgkey=https://mirrors.nyist.edu.cn/centos-vault/RPM-GPG-KEY-CentOS-7 [centosplus]name=CentOS-$releasever - centosplus - mirrors.nyist.edu.cnbaseurl=https://mirrors.nyist.edu.cn/centos-vault/centos/$releasever/centosplus/$basearch/enabled=0gpgcheck=1gpgkey=https://mirrors.nyist.edu.cn/centos-vault/RPM-GPG-KEY-CentOS-7 [fasttrack]name=CentOS-$releasever - fasttrack - mirrors.nyist.edu.cnbaseurl=https://mirrors.nyist.edu.cn/centos-vault/centos/$releasever/fasttrack/$basearch/enabled=0gpgcheck=1gpgkey=https://mirrors.nyist.edu.cn/centos-vault/RPM-GPG-KEY-CentOS-7[atomic]name=CentOS-$releasever - atomic - mirrors.nyist.edu.cnbaseurl=https://mirrors.nyist.edu.cn/centos-vault/centos/$releasever/atomic/$basearch/enabled=0gpgcheck=1gpgkey=https://mirrors.nyist.edu.cn/centos-vault/RPM-GPG-KEY-CentOS-7[dotnet]name=CentOS-$releasever - dotnet - mirrors.nyist.edu.cnbaseurl=https://mirrors.nyist.edu.cn/centos-vault/centos/$releasever/dotnet/$basearch/enabled=0gpgcheck=1gpgkey=https://mirrors.nyist.edu.cn/centos-vault/RPM-GPG-KEY-CentOS-7[rt]name=CentOS-$releasever - rt - mirrors.nyist.edu.cnbaseurl=https://mirrors.nyist.edu.cn/centos-vault/centos/$releasever/rt/$basearch/enabled=0gpgcheck=1gpgkey=https://mirrors.nyist.edu.cn/centos-vault/RPM-GPG-KEY-CentOS-7[sclo-rh]name=CentOS-$releasever - sclo-rh - mirrors.nyist.edu.cnbaseurl=https://mirrors.nyist.edu.cn/centos-vault/centos/$releasever/sclo/$basearch/rh/enabled=0gpgcheck=1gpgkey=https://mirrors.nyist.edu.cn/centos-vault/RPM-GPG-KEY-CentOS-7[sclo-sclo]name=CentOS-$releasever - sclo-sclo - mirrors.nyist.edu.cnbaseurl=https://mirrors.nyist.edu.cn/centos-vault/centos/$releasever/sclo/$basearch/sclo/enabled=0gpgcheck=1gpgkey=https://mirrors.nyist.edu.cn/centos-vault/RPM-GPG-KEY-CentOS-7EOF
其他centos版本的yum源配置:
CentOS 6 在线可用yum源配置——筑梦之路_centos6可用yum源-CSDN博客
CentOS 8 停止维护后换可用yum源——筑梦之路_centos yum 阿里云镜像还支持吗-CSDN博客
参考资料:
https://www.cnblogs.com/yeziwinone/p/17916626.html
centos镜像_centos下载地址_centos安装教程-阿里巴巴开源镜像站