Linux学习与应用技巧

Linux_084_配置阿里云yum

2022-03-18  本文已影响0人  为宇绸缪

配置yum源

确保有wget命令 yum install wget -y
安装阿里云和epel镜像
epel.repo centos-base.repo 指定了yum仓库的网站地址

1.备份现有repo仓库
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

2.下载新的repo文件
CentOS 6
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo

CentOS 7
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

3.清空旧yum缓存,生成新的缓存
yum clean all
yum makecache

4.针对阿里云镜像,可能出现无法解析地址的异常
sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo

5.配置epel源
epel(RHEL 7)
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
epel(RHEL 6)
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
epel(RHEL 5)
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-5.repo

再使用 yum clean all 和 yum makecache 来清除缓存和新建缓存

上一篇下一篇

猜你喜欢

热点阅读