目录
一、准备工作
1、首先找一台可以访问互联网的机器,系统版本需要和离线环境一致,推荐安装一台虚拟机
2、配置网络YUM源
二、安装
1、安装插件
1)命令
2)实例
2、查询yum仓库中的软件版本(以查询VirtualBox软件为例)
1)命令
2)实例
3、使用插件下载软件与依赖包存放置指定目录下(该命令仅下载不实际安装)
1)命令
2)实例
4.、安装createrepo软件包,该软件包提供制作repodata软件仓库所需的文件
1)命令
2)实例
5、生成repodata 文件夹,选择之前下载软件包的文件夹作为资源库的路径
1)命令
2)实例
6、将/opt/VirtualBox-6.1 文件夹拷贝到新的离线环境的服务器
7、编写YUM仓库配置文件
1)命令
2)实例
8、重新生成缓存
1)命令
2)实例
9、离线安装软件
1)命令
2)实例
一、准备工作
1、首先找一台可以访问互联网的机器,系统版本需要和离线环境一致,推荐安装一台虚拟机
详细可参考此链接
2、配置网络YUM源
详细可参考此链接
二、安装
1、安装插件
1)命令
yum -y install yum-plugin-downloadonly
2)实例
[root@localhost ~]# yum -y install yum-plugin-downloadonly
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
... ... ...
2、查询yum仓库中的软件版本(以查询VirtualBox软件为例)
1)命令
yum list VirtualBox* --showduplicates
#yum list 一般会列出该软件最新版本,加上 --showduplicates参数,列出所有版本
2)实例
[root@localhost ~]# yum list VirtualBox* --showduplicates
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Available Packages
VirtualBox-4.3.x86_64 4.3.26_98988_el7-1 virtualbox
... ... ...
VirtualBox-4.3.x86_64 4.3.40_110317_el7-1 virtualbox
VirtualBox-5.0.x86_64 5.0.4_102546_el7-1 virtualbox
VirtualBox-5.0.x86_64 5.0.6_103037_el7-1 virtualbox
... ... ...
VirtualBox-6.0.x86_64 6.0.16_135674_el7-1 virtualbox
... ... ...
VirtualBox-6.0.x86_64 6.0.24_139119_el7-1 virtualbox
VirtualBox-6.1.x86_64 6.1.0_135406_el7-1 virtualbox
... ... ...
VirtualBox-6.1.x86_64 6.1.28_147628_el7-1 virtualbox
VirtualBox-6.1.x86_64 6.1.30_148432_el7-1 virtualbox
VirtualBox-6.1.x86_64 6.1.32_149290_el7-1 virtualbox
3、使用插件下载软件与依赖包存放置指定目录下(该命令仅下载不实际安装)
1)命令
yum install VirtualBox-6.1.x86_64 --downloadonly --downloaddir=/opt/VirtualBox-6.1
# --downloadonly参数下载所需软件及依赖包
# --downloaddir 指定下载位置
2)实例
[root@localhost ~]# yum install VirtualBox-6.1.x86_64 --downloadonly --downloaddir=/opt/VirtualBox-6.1
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package VirtualBox-6.1.x86_64 0:6.1.32_149290_el7-1 will be installed
--> Processing Dependency: libSDL-1.2.so.0()(64bit) for package: VirtualBox-6.1-6.1.32_149290_el7-1.x86_64
--> Running transaction check
---> Package SDL.x86_64 0:1.2.15-17.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=======================================================================================
Package Arch Version Repository Size
=======================================================================================
Installing:
VirtualBox-6.1 x86_64 6.1.32_149290_el7-1 virtualbox 97 M
Installing for dependencies:
SDL x86_64 1.2.15-17.el7 base 206 k
Transaction Summary
=======================================================================================
Install 1 Package (+1 Dependent package)
Total download size: 97 M
Installed size: 220 M
Background downloading packages, then exiting:
(1/2): SDL-1.2.15-17.el7.x86_64.rpm | 206 kB 00:00:00
warning: /opt/VirtualBox-6.1/VirtualBox-6.1-6.1.32_149290_el7-1.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 98ab5139: NOKEY
Public key for VirtualBox-6.1-6.1.32_149290_el7-1.x86_64.rpm is not installed
(2/2): VirtualBox-6.1-6.1.32_149290_el7-1.x86_64.rpm | 97 MB 00:01:04
---------------------------------------------------------------------------------------
Total 1.5 MB/s | 97 MB 01:05
exiting because "Download Only" specified
4.、安装createrepo软件包,该软件包提供制作repodata软件仓库所需的文件
1)命令
yum -y install createrepo
2)实例
[root@localhost ~]# yum -y install createrepo
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
... .... ...
5、生成repodata 文件夹,选择之前下载软件包的文件夹作为资源库的路径
1)命令
createrepo /opt/VirtualBox-6.1
2)实例
[root@localhost ~]# createrepo /opt/VirtualBox-6.1
Spawning worker 0 with 2 pkgs
Workers Finished
Saving Primary metadata
Saving file lists metadata
Saving other metadata
Generating sqlite DBs
Sqlite DBs complete
6、将/opt/VirtualBox-6.1 文件夹拷贝到新的离线环境的服务器
[root@localhost ~]# ls -d /opt/VirtualBox-6.1
/opt/VirtualBox-6.1
#博主这里拷贝到/opt下,具体位置看需求
7、编写YUM仓库配置文件
1)命令
vim /etc/yum.repos.d/VirtualBox-6.1.repo
#在/etc/yum.repos.d/路径下写yum配置文件.repo结尾
2)实例
[root@localhost ~]# vim /etc/yum.repos.d/VirtualBox-6.1.repo
[VirtualBox-6.1]
name=VirtualBox-6.1
baseurl=file:///opt/VirtualBox-6.1
enabled=1
gpgcheck=0
8、重新生成缓存
1)命令
yum clean all && yum makecache
#清除并重新生成缓存
2)实例
[root@localhost ~]# yum clean all && yum repolist
Loaded plugins: fastestmirror, langpacks
Cleaning repos: base extras updates virtualbox
Cleaning up list of fastest mirrors
Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors
... ... ...
9、离线安装软件
1)命令
yum -y install VirtualBox-6.1
2)实例
[root@localhost ~]# yum -y install VirtualBox-6.1
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
... ... ...