Centos 7镜像源
一个适用于 CentOS 7 的完整的镜像源配置。CentOS 7 使用 yum
包管理器来安装和更新软件包。你可以通过编辑 /etc/yum.repos.d/CentOS-Base.repo
文件来配置你的镜像源。
完整的 CentOS 7 镜像源配置
方法一:使用阿里云镜像源
阿里云提供了快速稳定的镜像源,以下是配置文件的内容:
# 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 date and 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 - Aliyun
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$releasever - Updates - Aliyun
baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - Aliyun
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - Aliyun
baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - Aliyun
baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
方法二:使用其他常用镜像源
如果你更倾向于使用其他镜像源,如清华大学开源软件镜像站、网易等,可以参考以下配置:
清华大学镜像源
[base]
name=CentOS-$releasever - Base - Tsinghua
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=https://mirrors.tuna.tsinghua.edu.cn/centos/RPM-GPG-KEY-CentOS-7
[updates]
name=CentOS-$releasever - Updates - Tsinghua
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=https://mirrors.tuna.tsinghua.edu.cn/centos/RPM-GPG-KEY-CentOS-7
[extras]
name=CentOS-$releasever - Extras - Tsinghua
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=https://mirrors.tuna.tsinghua.edu.cn/centos/RPM-GPG-KEY-CentOS-7
网易镜像源
[base]
name=CentOS-$releasever - Base - 163
baseurl=http://mirrors.163.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
[updates]
name=CentOS-$releasever - Updates - 163
baseurl=http://mirrors.163.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
[extras]
name=CentOS-$releasever - Extras - 163
baseurl=http://mirrors.163.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
应用新的镜像源配置
完成上述配置后,请执行以下命令以清理缓存并生成新的元数据:
sudo yum clean all
sudo yum makecache
这将确保你能够立即使用新配置的镜像源进行软件包的安装和更新。
总结
通过替换 /etc/yum.repos.d/CentOS-Base.repo
文件中的内容为上述任意一个镜像源配置,你可以显著提高 yum
操作的速度和稳定性。选择最接近你地理位置或网络条件最好的镜像源可以获得最佳效果。