redhat系列的yum源配置

一、Linux更改yum源为阿里云源

  一)原yum源备份

cp -rp /etc/yum.repos.d/CentOS-Base.repo{,.bak}
cp -rp /etc/yum.repos.d/epel.repo{,.bak}

  二)更改为阿里云源 

  1、更改yum base源

  下载新的CentOS-Base.repo 到/etc/yum.repos.d/

  http://mirrors.aliyun.com/repo

    1)CentOS5.x
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
或者
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
    2)CentOS6.x
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
    3)CentOS7.x
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
    4)CentOS8.x
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo
或者
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo

  2、更改yum epel源
    1)CentOS6.x
wget -O /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-archive-6.repo

    2)CentOS7.x
wget -O /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo
    3)CentOS8.x
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*

  三)配置完毕,运行yum makecache生成缓存

  清除旧缓存

yum clean all

  生成新的缓存

yum makecach

二、内网自建yum源

  一)自建yum仓库

  参考链接地址:[Linux]-搭建基于内部网络yum仓库 - Cheney& - 博客园

  添加rpm包,更新yum仓库

createrepo --update .

  二)同步开源yum源到本地yum仓库

  参考链接地址:自建Yum源并与科大开源镜像站进行同步_51CTO博客_大学开源镜像站

  三)yum下载RPM包及依赖包的两种方式

  downloadonly和yumdownloade

  yum下载RPM包及依赖包的两种方式_rpm nano-优快云博客

三、yum缓存包到本地

yum install --downloadonly --downloaddir=/root/mypackages/ vim

  说明:

--downloadonly  只下载
--downloaddir  下载包存放的路径
/root/mypackages  下载包存放的位置
vim  下载的包

   rpm -ivh ./*.rpm --nodeps --force

  说明:

  安装所有包,因为通过第一个命令下载后有很多rpm包,他们之前有依赖关系,一个一个安装不实际

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值