Offline Package Installation

When I was working on the upgrade DS k8s installer issue, I ran into the problem that I need to install ansible, docker and kubeadm offline. In the production environment, we may not have internet access, that means we need to prepare the rpms and dependencies needed and create a self-contained installer.

Download package without installing it

Note: This method is for package that hasn't been installed yet, more details please see this link

First let's install the utility:

yum install -y yum-plugin-downloadonly
yum install --downloadonly --downloaddir=<directory> <package:version>

For example, I want to get all rpms for vim editor, reside them in /root/vim folder

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

Offline Package Installation

List the target folder:

Offline Package Installation

If the package is already installed, you can first install yum-utils by running

yum install -y yum-utils

then

yumdownloader --reslove --destdir=/root/vim vim

This method will only download the outer most rpm, not all.

Install local rpms

Now the problem is how to install these rpms in correct order. Actually you can get the dependency relationship by running:

rpm -ivh <rpm name>

This command will install a single rpm if it meets all dependencies, otherwise install will fail and the output will give you the lower level rpms missed.

Offline Package Installation

This way is obviously infeasible because such as docker and ansible have too many, install them one by one is very time consuming. One solution is put all rpms of one application in a dedicated folder, then run:

yum --disablerepo=* -y install <dedicated folder>/*.rpm

Search rpm installed

These two both works:

rpm -qa | grep <package name>
yum list installed | grep <package name>
上一篇:防抖和节流


下一篇:vue自定义指令函数节流和防抖