赞
踩
众所周知,centos 7 在2024年6月30日,生命周期结束,官方不再进行支持维护,而很多环境一时之间无法完全更新替换操作系统,因此对于yum源还是需要的,特别是对于互联网环境来说,在线yum源使用方便很多,而不需要去搭建本地yum源和内网yum源。
这里以阿里云为例,其他国内开源镜像站类似。
- cd /etc/yum.repos.d
-
- mkdir backup
-
- mv *.repo backup
- cat > CentOS-aliyun-lhr.repo <<EOF
- [base]
- name=CentOS-7.9.2009
- enabled=1
- failovermethod=priority
- baseurl=http://mirrors.aliyun.com/centos-vault/7.9.2009/os/$basearch/
- gpgcheck=1
- gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-7
- [updates]
- name=CentOS-7.9.2009
- enabled=1
- failovermethod=priority
- baseurl=http://mirrors.aliyun.com/centos-vault/7.9.2009/updates/$basearch/
- gpgcheck=1
- gpgkey=http://mirrors.aliyun.comm/centos-vault/RPM-GPG-KEY-CentOS-7
- [extras]
- name=CentOS-7.9.2009
- enabled=1
- failovermethod=priority
- baseurl=http://mirrors.aliyun.com/centos-vault/7.9.2009/extras/$basearch/
- gpgcheck=1
- gpgkey=http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-7
- [epel]
- name=Extra Packages for Enterprise Linux 6 - $basearch
- enabled=1
- failovermethod=priority
- baseurl=http://mirrors.aliyun.com/epel-archive/6/$basearch
- gpgcheck=0
- gpgkey=http://mirrors.aliyun.com/epel-archive/RPM-GPG-KEY-EPEL-7
- EOF
- yum clean all
-
- yum makecache fast
-
-
- yum install vim lrzsz wget curl net-tools
- cat > CentOS-Base.repo <<EOF
- [base]
- name=CentOS-7.9.2009
- enabled=1
- failovermethod=priority
- baseurl=https://vault.centos.org/7.9.2009/os/$basearch/
- gpgcheck=1
- gpgkey=https://vault.centos.org/RPM-GPG-KEY-CentOS-7
- [updates]
- name=CentOS-7.9.2009
- enabled=1
- failovermethod=priority
- baseurl=https://vault.centos.org/7.9.2009/updates/$basearch/
- gpgcheck=1
- gpgkey=https://vault.centos.org/RPM-GPG-KEY-CentOS-7
- [extras]
- name=CentOS-7.9.2009
- enabled=1
- failovermethod=priority
- baseurl=https://vault.centos.org/7.9.2009/extras/$basearch/
- gpgcheck=1
- gpgkey=https://vault.centos.org/RPM-GPG-KEY-CentOS-7
- [epel]
- name=Extra Packages for Enterprise Linux 7 - $basearch
- enabled=1
- failovermethod=priority
- baseurl=https://vault.centos.org/epel-archive/7/$basearch
- gpgcheck=0
- gpgkey=https://vault.centos.org/epel-archive/RPM-GPG-KEY-EPEL-7
- EOF
- cat > CentOS-tsinghua.repo <<EOF
- [base]
- name=CentOS-7.9.2009
- enabled=1
- failovermethod=priority
- baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/7.9.2009/os/$basearch/
- gpgcheck=1
- gpgkey=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/RPM-GPG-KEY-CentOS-7
- [updates]
- name=CentOS-7.9.2009
- enabled=1
- failovermethod=priority
- baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/7.9.2009/updates/$basearch/
- gpgcheck=1
- gpgkey=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/RPM-GPG-KEY-CentOS-7
- [extras]
- name=CentOS-7.9.2009
- enabled=1
- failovermethod=priority
- baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/7.9.2009/extras/$basearch/
- gpgcheck=1
- gpgkey=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/RPM-GPG-KEY-CentOS-7
- [epel]
- name=Extra Packages for Enterprise Linux 7 - $basearch
- enabled=1
- failovermethod=priority
- baseurl=https://mirrors.tuna.tsinghua.edu.cn/epel-archive/7/$basearch
- gpgcheck=0
- gpgkey=https://mirrors.tuna.tsinghua.edu.cn/epel-archive/RPM-GPG-KEY-EPEL-7
- EOF
- cat > CentOS-ustc.repo <<EOF
- # 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.
- #
- #
- [base]
- name=CentOS-$releasever - Base
- #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$infra
- baseurl=https://mirrors.ustc.edu.cn/centos-vault/centos/$releasever/os/$basearch/
- gpgcheck=1
- gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
- #released updates
- [updates]
- name=CentOS-$releasever - Updates
- #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
- baseurl=https://mirrors.ustc.edu.cn/centos-vault/centos/$releasever/updates/$basearch/
- gpgcheck=1
- gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
- #additional packages that may be useful
- [extras]
- name=CentOS-$releasever - Extras
- #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=$infra
- baseurl=https://mirrors.ustc.edu.cn/centos-vault/centos/$releasever/extras/$basearch/
- gpgcheck=1
- gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
- #additional packages that extend functionality of existing packages
- [centosplus]
- name=CentOS-$releasever - Plus
- #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
- baseurl=https://mirrors.ustc.edu.cn/centos-vault/centos/$releasever/centosplus/$basearch/
- gpgcheck=1
- enabled=0
- gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
- EOF
其他centos版本的yum源配置:
CentOS 6 在线可用yum源配置——筑梦之路_centos6可用yum源-CSDN博客
CentOS 8 停止维护后换可用yum源——筑梦之路_centos yum 阿里云镜像还支持吗-CSDN博客
参考资料:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。