centos8stream配置阿里云yum源
配置阿里云 YUM 源于 CentOS 8 Stream
修改 yum 文件
对于 CentOS 8 Stream 的用户来说,可以通过编辑 /etc/yum.repos.d/
下的相关 .repo
文件来实现阿里云 YUM 源的配置。具体操作如下:
通过命令行工具可以批量处理这些文件中的 URL 地址变更,从而指向阿里云提供的镜像站点[^3]。
minorver=8-stream
sudo sed -e "s|^mirrorlist=|#mirrorlist=|g" \
-e "s|^#baseurl=http://mirror.centos.org/\$contentdir/\$stream|baseurl=https://mirrors.aliyun.com/centos-vault/$minorver|g" \
-i.bak \
/etc/yum.repos.d/CentOS-*.repo
上述脚本会自动备份原有配置并更新 baseurl
字段至阿里云服务器地址。这一步骤适用于所有以 CentOS-
开头的仓库定义文件,确保了 AppStream、BaseOS 及 Extras 等多个官方库均能正常访问国内加速节点[^2]。
完成以上更改之后,建议清理本地缓存并重新加载元数据以使新设置生效:
sudo yum clean all
sudo yum makecache fast
这样就可以利用更快速稳定的网络连接获取软件包及其依赖项了。
centos9配置阿里云yum源
CentOS 9 配置阿里云 YUM 源
对于CentOS 9而言,官方已经停止了对CentOS作为社区支持的操作系统的维护,并转向了CentOS Stream。因此,在CentOS 9上配置阿里云YUM源的方法可能与之前的版本有所不同。
方法一:通过 wget
下载并替换默认仓库文件
可以尝试使用如下命令来获取适用于新版本的阿里云YUM源配置文件:
sudo wget -O /etc/yum.repos.d/CentOS-Linux-AppStream.repo https://mirrors.aliyun.com/repo/Centos-vault-9.2.0/AppStream/x86_64/os/
sudo wget -O /etc/yum.repos.d/CentOS-Linux-BaseOS.repo https://mirrors.aliyun.com/repo/Centos-vault-9.2.0/BaseOS/x86_64/os/
这会覆盖现有的 /etc/yum.repos.d/
文件夹中的对应文件[^1]。
方法二:手动编辑 .repo
文件
另一种方法是直接修改已有的.repo
文件或者创建新的.repo
文件,比如名为aliyun.repo
:
[base]
name=Aliyun Base $releasever - $basearch
mirrorlist=https://mirrors.aliyun.com/centos/$releasever-stream/BaseOS/$basearch/os/
gpgcheck=1
enabled=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
[appstream]
name=Aliyun AppStream $releasever - $basearch
mirrorlist=https://mirrors.aliyun.com/centos/$releasever-stream/AppStream/$basearch/os/
gpgcheck=1
enabled=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
保存上述内容至 /etc/yum.repos.d/aliyun.repo
后即可生效[^3]。
完成以上任一步骤之后,请记得清理缓存以使更改立即生效:
sudo yum clean all && sudo yum makecache fast
centos8 stream下载阿里云软件源
好的,您可以按照以下步骤下载阿里云软件源:
备份 CentOS-Base.repo 文件:
sudo mv /etc/yum.repos.d/CentOS-Stream-Base.repo /etc/yum.repos.d/CentOS-Stream-Base.repo.bak
下载阿里云的 CentOS-Stream-Base.repo 文件:
sudo wget -O /etc/yum.repos.d/CentOS-Stream-Base.repo http://mirrors.aliyun.com/repo/Centos-stream-8.repo
清除缓存:
sudo yum clean all
更新软件包列表:
sudo yum makecache
现在您的 CentOS 8 Stream 系统将使用阿里云的软件源。
相关推荐
















