Linux.CentOS 7 镜像源配置
在CentOS 7中配置Linux镜像源可以提高软件包安装和更新的速度。以下是如何配置镜像源的步骤:
- 备份当前的Yum仓库配置。
sudo cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
- 编辑CentOS-Base.repo文件。
sudo vi /etc/yum.repos.d/CentOS-Base.repo
- 替换文件中的baseurl和mirrorlist。以下是一个示例,使用阿里云的镜像源:
[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
- 清除Yum缓存并生成新的缓存。
sudo yum clean all
sudo yum makecache
现在您已经配置了新的镜像源,可以使用yum update
来进行更新测试。
评论已关闭