centos阿里yum源配置

一、elrepo源

简介
The ELRepo Project focuses on hardware related packages to enhance your experience with Enterprise Linux. This includes filesystem drivers, graphics drivers, network drivers, sound drivers, webcam and video drivers.

Elrepo是国外的一个只对Linux操作系统的第三方免费软件资源库,支持Linux和CentOS操作系统的软件安装和升级。

下载地址:https://mirrors.aliyun.com/elrepo/

配置方法
首先按照官网的安装说明,配置 ELRepo:

> rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
接着,按照你的系统版本,如果是 RHEL-8 或者 CentOS-8 则运行:

> yum install https://www.elrepo.org/elrepo-release-8.el8.elrepo.noarch.rpm
RHEL-7, SL-7 或者 CentOS-7> yum install https://www.elrepo.org/elrepo-release-7.el7.elrepo.noarch.rpm
RHEL-6, SL-6 或者 CentOS-6> yum install https://www.elrepo.org/elrepo-release-6.el6.elrepo.noarch.rpm
建议先备份 /etc/yum.repos.d/elrepo.repo :

sudo cp /etc/yum.repos.d/elrepo.repo /etc/yum.repos.d/elrepo.repo.bak
然后编辑 /etc/yum.repos.d/elrepo.repo 文件,在 mirrorlist= 开头的行前面加 # 注释掉;并将 elrepo.org/linux 替换为 mirrors.aliyun.com/elrepo。

最后,更新软件包缓存

sudo yum makecache
注:配置方法参考自清华镜像
elrepo

二、epel源

简介
EPEL(Extra Packages for Enterprise Linux), 是由Fedora Special Interest Group维护的Enterprise Linux(RHEL、CentOS)中经常用到的包。

下载地址:https://mirrors.aliyun.com/epel/

相关仓库
epel过期源(epel-archive):https://developer.aliyun.com/mirror/epel-archive
配置方法
1. 备份(如有配置其他epel源)
mv /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel.repo.backup
mv /etc/yum.repos.d/epel-testing.repo /etc/yum.repos.d/epel-testing.repo.backup
2. 下载新repo 到/etc/yum.repos.d/
epel(RHEL 8)
1)安装 epel 配置包

yum install -y https://mirrors.aliyun.com/epel/epel-release-latest-8.noarch.rpm
2)将 repo 配置中的地址替换为阿里云镜像站地址

sed -i 's|^#baseurl=https://download.example/pub|baseurl=https://mirrors.aliyun.com|' /etc/yum.repos.d/epel*
sed -i 's|^metalink|#metalink|' /etc/yum.repos.d/epel*
epel(RHEL 7)

wget -O /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo
epel(RHEL 6) (epel6官方源已下线,建议切换epel-archive源)

wget -O /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-archive-6.repo
相关链接
官方主页:https://fedoraproject.org/wiki/EPEL
epel

三、base源

配置方法
通知:CentOS 8操作系统版本结束了生命周期(EOL),Linux社区已不再维护该操作系统版本。建议您切换到Anolis或Alinux。如果您的业务过渡期仍需要使用CentOS 8系统中的一些安装包,请根据下文切换CentOS 8的源。

1. 备份
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
2. 下载新的 CentOS-Base.repo 到 /etc/yum.repos.d/
centos8(centos8官方源已下线,建议切换centos-vault源)
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
或者

curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
centos6(centos6官方源已下线,建议切换centos-vault源)

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-6.10.repo
或者

curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-6.10.repo
CentOS 7

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
或者

curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
3. 运行 yum makecache 生成缓存
4. 其他
非阿里云ECS用户会出现 Couldn't resolve host 'mirrors.cloud.aliyuncs.com' 信息,不影响使用。用户也可自行修改相关配置: eg:

sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo


CentOS 8 结束生命周期如何切换源
公网用户:
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
yum clean all && yum makecache
阿里云ecs用户:
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.cloud.aliyuncs.com/repo/Centos-vault-8.5.2111.repo
sed -i 's/mirrors.cloud.aliyuncs.com/url_tmp/g' /etc/yum.repos.d/CentOS-Base.repo && sed -i 's/mirrors.aliyun.com/mirrors.cloud.aliyuncs.com/g' /etc/yum.repos.d/CentOS-Base.repo && sed -i 's/url_tmp/mirrors.aliyun.com/g' /etc/yum.repos.d/CentOS-Base.repo
yum clean all && yum makecache
base

 

posted on 2024-07-16 08:36  HowOldAreYou  阅读(34)  评论(0编辑  收藏  举报

导航