一、GuestOS信息
rhel 8.1
二、配置yum镜像源
1. 配置yum.repo配置文件(把下面的配置,加到 /etc/yum.repos.d/redhat.repo 文件的末尾)
[BaseOS]
name=BaseOS
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/8.0.1905/BaseOS/$basearch/os/
gpgcheck=0
enabled=1
gpgkey=https://mirrors.tuna.tsinghua.edu.cn/centos/RPM-GPG-KEY-CentOS-Official
[AppStream]
name=AppStream
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/8.0.1905/AppStream/$basearch/os/
gpgcheck=0
enabled=1
gpgkey=https://mirrors.tuna.tsinghua.edu.cn/centos/RPM-GPG-KEY-CentOS-Official
[PowerTools]
name=PowerTools
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/8.0.1905/PowerTools/$basearch/os/
gpgcheck=0
enabled=1
gpgkey=https://mirrors.tuna.tsinghua.edu.cn/centos/RPM-GPG-KEY-CentOS-Official
[extras]
name=extras
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/8.0.1905/extras/$basearch/os/
gpgcheck=0
enabled=1
gpgkey=https://mirrors.tuna.tsinghua.edu.cn/centos/RPM-GPG-KEY-CentOS-Official
[centosplus]
name=centosplus
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos-vault/8.0.1905/centosplus/$basearch/os/
gpgcheck=0
enabled=1
gpgkey=https://mirrors.tuna.tsinghua.edu.cn/centos/RPM-GPG-KEY-CentOS-Official
2. 执行如下命令,清理yum缓存和重新生成yum缓存
yum clean all
yum makecache
三、测试一下
3.1 举个例子
1. 指定一个详细的包名 进行下载
yum download audit-libs-3.0-0.10.20180831git0047a6c.el8.x86_64 --destdir /root/test/
2. 指定工具名
yum download vim --destdir /root/test
3.2 使用场景
这个有操作有什么用呢?
比如我安装了一个软件,后面我想在离线场景下进行安装,我想把这些包都弄下来,放到本地,方便以后进行离线安装,我就可以这样做。
举个例子:我有一个软件包containerd.io-1.6.18-3.1.el7.x86_64.rpm,我在可以访问公网镜像源的场景下,执行安装,在安装过程中,他会自动安装依赖,这个时候我们就可以把这些依赖也全部下载下来,方便后续离线安装。
1. 通过yum install -y containerd.io-1.6.18-3.1.el7.x86_64.rpm
2. 当任务完成以后,我们把下面的信息记住
3.这个时候我们通过 yum download policycoreutils-python-utils-2.8-16.1.el8.noarch --destdir /root/test/ 就可以把我安装这个rpm的所有依赖给下载下来,本地保存。以后我们离线安装的时候,就可以把这些包弄进去直接安装。
备注:
如果你是centos的话也是一样的操作,只是命令有点差异
[centos]
yum install --downloadonly --downloaddir=/root fuse-overlayf
[rhel]
# 下面两种都可以使用
dnf/yum install --downloadonly --downloaddir=/root fuse-overlayf # 这个如果软件已经安装了就不会下载了
dnf/yum download fuse-overlayf --destdir /root/test/ # 这个软件安装了也会去下载